From ad066a8f8623bc00a6836f0e8962593069c8001a Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Sun, 17 Feb 2019 00:36:44 +0100 Subject: [PATCH] Failed send message improvements --- Services/PlivoApi.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Services/PlivoApi.php b/Services/PlivoApi.php index 06b8d02..e79217b 100644 --- a/Services/PlivoApi.php +++ b/Services/PlivoApi.php @@ -83,7 +83,7 @@ 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( @@ -91,9 +91,16 @@ public function sendSms(Lead $contact, $content) [$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; } } }