40 if (isset(
$fields[
'subject_id']))
45 if (!isset(
$fields[InternalOption::API_KEY],
$fields[InternalOption::SENDER_ID]))
47 return (
new Result())->addError(
new Error(Loc::getMessage(
'MESSAGESERVICE_SENDER_SMS_EDNARU_EMPTY_REQUIRED_FIELDS')));
49 $this->optionManager->setOption(InternalOption::API_KEY, (
string)
$fields[InternalOption::API_KEY]);
52 foreach (explode(
';', (
string)
$fields[InternalOption::SENDER_ID]) as $senderId)
54 $senderId = trim($senderId);
57 $subjectIdList[] = (int)$senderId;
60 if (!$this->utils->checkActiveChannelBySubjectIdList($subjectIdList, $this->channelType))
62 $this->optionManager->clearOptions();
64 return (
new Result())->addError(
new Error(Loc::getMessage(
'MESSAGESERVICE_EDNARU_INACTIVE_CHANNEL_ERROR')));
67 foreach ($subjectIdList as $subjectId)
69 $setCallbackResult = $this->utils->setCallback(
74 if (!$setCallbackResult->isSuccess())
76 $this->optionManager->clearOptions();
78 $errorData = $setCallbackResult->getData();
80 if (isset($errorData[
'detail']))
82 return (
new Result())->addError(
new Error($errorData[
'detail']));
85 return $setCallbackResult;
89 $this->optionManager->setOption(InternalOption::SENDER_ID, $subjectIdList);
90 $this->optionManager->setOption(InternalOption::MIGRATED_TO_STANDART_SETTING_NAMES,
'Y');
132 return (
new Result())->addError(
new Error(
'It is impossible to reinstall the callback url because the provider is not registered'));
138 foreach (explode(
';', (
string)
$fields[InternalOption::SENDER_ID][0]) as $senderId)
140 $senderId = trim($senderId);
141 if ($senderId !==
'')
143 $subjectIdList[] = (int)$senderId;
147 if (!$this->utils->checkActiveChannelBySubjectIdList($subjectIdList, $this->channelType))
149 return (
new Result())->addError(
new Error(Loc::getMessage(
'MESSAGESERVICE_EDNARU_INACTIVE_CHANNEL_ERROR')));
152 foreach ($subjectIdList as $subjectId)
154 $setCallbackResult = $this->utils->setCallback(
159 if (!$setCallbackResult->isSuccess())
161 $errorData = $setCallbackResult->getData();
163 if (isset($errorData[
'detail']))
165 return (
new Result())->addError(
new Error($errorData[
'detail']));
168 return $setCallbackResult;