27 $this->optionManager->getOption(Providers\
Constants\InternalOption::API_KEY),
29 $this->optionManager->getSocketTimeout(),
30 $this->optionManager->getStreamTimeout()
36 $cascadeResult = $this->getSenderFromSubject($messageFields[
'MESSAGE_FROM']);
37 if (!$cascadeResult->isSuccess())
39 return $cascadeResult;
43 'requestId' => uniqid(
'',
true),
44 'cascadeId' => $cascadeResult->getData()[
'cascadeId'],
45 'subscriberFilter' => [
46 'address' => str_replace(
'+',
'', $messageFields[
'MESSAGE_TO']),
50 $params[
'content'] = $this->getMessageContent($messageFields);
52 return (
new Result())->setData($params);
57 return Providers\Edna\Constants\Method::SEND_MESSAGE;
74 private function getMessageContent(array $messageFields): array
78 'contentType' => Providers\Edna\Constants\ContentType::TEXT,
84 private function getSenderFromSubject($subject):
Result
86 $cascadeResult =
new Result();
87 if (is_numeric($subject))
89 $cascadeResult = $this->utils->getCascadeIdFromSubject(
91 static function(array $externalSubjectData,
int $internalSubject)
93 return $externalSubjectData[
'id'] === $internalSubject;
97 elseif (is_string($subject))
99 $cascadeResult = $this->utils->getCascadeIdFromSubject(
101 static function(array $externalSubjectData,
string $internalSubject)
103 return $externalSubjectData[
'subject'] === $internalSubject;
109 $cascadeResult->addError(
new Error(
'Invalid subject id'));
112 return $cascadeResult;