protected function doSend(MessageInterface
$message): SentMessage
{ if (!
$message instanceof SmsMessage
) { throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::
class,
$message);
} $options =
$message->
getOptions()?->
toArray() ??
[];
$options['text'
] =
$message->
getSubject();
$options['src'
] =
$message->
getFrom() ?:
$this->from;
$options['dst'
] =
$message->
getPhone();
if (!
preg_match('/^[a-zA-Z0-9\s]{2,11}$/',
$options['src'
]) && !
preg_match('/^\+?[1-9]\d{1,14}$/',
$options['src'
])) { throw new InvalidArgumentException(sprintf('The "From" number "%s" is not a valid phone number, shortcode, or alphanumeric sender ID. Phone number must contain only numbers and optional + character.',
$options['src'
]));
} $endpoint =
sprintf('https://%s/v1/Account/%s/Message/',
$this->
getEndpoint(),
$this->authId
);
$response =
$this->client->
request('POST',
$endpoint,
[ 'auth_basic' =>
[$this->authId,
$this->authToken
],
'json' =>
array_filter($options),
]);