/**
* @param Message $message
* @param PhoneNumber $recipient
* @throws SenderException
* @return bool
*/
public function send(Message $message, PhoneNumber $recipient)
{
$params = ['api_key' => $this->apiKey, 'api_secret' => $this->apiSecret, 'from' => $this->senderName, 'to' => $recipient->getCountryCode() . $recipient->getNationalNumber(), 'text' => $message->getContent(), 'type' => $message->getType() === Message::TYPE_UNICODE ? "unicode" : "text"];
$url = self::NEXTMO_ENDPOINT . '?' . http_build_query($params);
$response = $this->getResponse($url);
if (false === isset($response['messages'])) {
throw new SenderException('Invalid nexmo response: ' . var_export($response, true));
}
foreach ($response['messages'] as $message) {
if ($message['status'] !== "0") {
throw new SenderException($message['error-text'], $message['status']);
}
}
return true;
}