Skip to content

Commit

Permalink
Failed send message improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmany committed Feb 16, 2019
1 parent d41d16e commit ad066a8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Services/PlivoApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,24 @@ public function sendSms(Lead $contact, $content)

$integration = $this->integrationHelper->getIntegrationObject('Plivo');
if ($integration && $integration->getIntegrationSettings()->getIsPublished()) {
$data = $integration->getDecryptedApiKeys();
$data = $integration->getDecryptedApiKeys();
$client = new RestClient($data['AUTH_ID'], $data['AUTH_TOKEN']);
try {
$response = $client->messages->create(
$data['sender_phone_number'],
[$contact->getMobile()],
$content
);

return true;
} catch (PlivoRestException $ex) {
return $ex->getErrorMessage();
if (method_exists($ex, 'getErrorMessage')) {
return $ex->getErrorMessage();
} elseif (!empty($ex->getMessage())) {
return $ex->getMessage();
}

return false;
}
}
}
Expand Down

0 comments on commit ad066a8

Please sign in to comment.