3namespace Bitrix\MessageService\Sender\Sms;
6use Bitrix\MessageService\Providers\Base\Option;
7use Bitrix\MessageService\Providers\CacheManager;
8use Bitrix\MessageService\Providers\Constants\InternalOption;
9use Bitrix\MessageService\Providers\Edna;
10use Bitrix\MessageService\Providers\Edna\SMS;
11use Bitrix\MessageService\Sender;
15 use Sender\Traits\RussianProvider;
19 public const ID =
'smsednaru';
25 $this->utils =
new SMS\Utils($this->
getId(), $this->optionManager);
29 $this->initializeOldApiComponents();
33 $this->initializeNewApiComponents();
40 return $this->informant->getId();
45 return $this->informant->getName();
50 return $this->informant->getShortName();
55 return $this->informant->getType();
60 return $this->informant->getManageUrl();
65 return $this->informant->getExternalId();
70 return $this->registrar->isRegistered();
86 return $this->registrar->getOwnerInfo();
91 return $this->registrar->getExternalManageUrl();
96 return $this->registrar->getCallbackUrl();
101 return $this->registrar->isConfirmed();
106 return $this->registrar->confirmRegistration(
$fields);
111 return $this->registrar->sendConfirmationCode();
119 return $this->initiator->getFromList();
128 $this->utils->updateSavedChannelList($this->initiator->getChannelType());
133 return $this->initiator->isCorrectFrom($from);
138 return $this->initiator->getDefaultFrom();
143 return $this->initiator->getDefaultFrom();
158 return $this->sender->prepareMessageBodyForSave(
$text);
163 return $this->utils->getMessageTemplates($subject);
168 return $this->utils->getSentTemplateMessage($from, $to);
190 return 'https://edna.ru/sms-bitrix/';
196 if ($isMigratedToNewAPI ===
'Y')
201 $currentDateTime = time();
202 $migratedDateTime = gmmktime(-3, 15,0, 12,1,2022);
204 return $currentDateTime >= $migratedDateTime;
207 private function initializeOldApiComponents(): void
210 $this->initiator =
new SMS\Old\Initiator($this->optionManager, $this->registrar, $this->utils, $this->
getId());
211 $this->sender =
new SMS\Old\Sender($this->optionManager,$this->registrar, $this->utils);
214 private function initializeNewApiComponents(): void
216 $this->registrar =
new SMS\Registrar($this->
getId(), $this->optionManager, $this->utils);
217 $this->initiator =
new SMS\Initiator($this->optionManager, $this->registrar, $this->utils, $this->
getId());
218 $this->sender =
new SMS\Sender($this->optionManager,$this->registrar, $this->utils);
225 if (!$this->
canUse() && !$oldRegistrar->canUse())
230 if ($this->
getOption(InternalOption::SENDER_ID) !==
null)
235 $channelListResult = $this->utils->getChannelList(
Edna\
Constants\ChannelType::SMS);
238 foreach ($channelListResult->getData() as $channel)
240 if (isset($channel[
'active'], $channel[
'subjectId']) && $channel[
'active'] ===
true)
242 $subjectIdList[] = $channel[
'subjectId'];
243 $this->utils->setCallback(
248 $channel[
'subjectId']
252 $this->
setOption(InternalOption::SENDER_ID, $subjectIdList);
261 private function getMigratingOptionName(): string
263 return $this->
getId() .
'_' . InternalOption::NEW_API_AVAILABLE;
276 \CAgent::AddAgent(static::class .
"::refreshFromListAgent();",
'messageservice',
'Y', $period);
286 if (!$sender::isSupported() || !
$sender->isRegistered())
293 return __METHOD__ .
'();';
static get($moduleId, $name, $default="", $siteId=false)
static set($moduleId, $name, $value="", $siteId="")
const CHANNEL_CACHE_ENTITY_ID
setOption($optionName, $optionValue)
getOption($optionName, $defaultValue=null)
addRefreshFromListAgent()
getSentTemplateMessage(string $from, string $to)
confirmRegistration(array $fields)
setSocketTimeout(int $socketTimeout)
prepareMessageBodyForSave(string $text)
setStreamTimeout(int $streamTimeout)
getMessageTemplates(string $subject='')
sendMessage(array $messageFields)
static refreshFromListAgent()
static resolveStatus($serviceStatus)
getMessageStatus(array $messageFields)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)