From 311ea7a3d4ad8575e73c6df9f5b36dc1584eb7a4 Mon Sep 17 00:00:00 2001 From: Ridvan Baluyos Date: Mon, 12 Dec 2016 14:07:18 +0800 Subject: [PATCH] add metadata in response envelope - this is the actual response of the SMS Gateway --- composer.json | 2 +- sample.php | 1 + src/ridvanbaluyos/sms/Sms.php | 5 +++-- src/ridvanbaluyos/sms/providers/Chikka.php | 2 +- src/ridvanbaluyos/sms/providers/PromoTexter.php | 2 +- src/ridvanbaluyos/sms/providers/Semaphore.php | 3 ++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index e149f03..76e3a00 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ridvanbaluyos/sms", - "version" : "v0.2-alpha", + "version" : "v0.3-alpha", "type": "library", "description": "A PHP Library built for making SMS sending easier.", "keywords": ["sms", "api", "php", "sms library", "php library"], diff --git a/sample.php b/sample.php index 2fd2d59..b3a10bb 100644 --- a/sample.php +++ b/sample.php @@ -7,6 +7,7 @@ use ridvanbaluyos\sms\providers\RisingTide as RisingTide; use ridvanbaluyos\sms\providers\Semaphore as Semaphore; use ridvanbaluyos\sms\providers\Chikka as Chikka; +use ridvanbaluyos\sms\providers\Nexmo as Nexmo; $message = 'this is a test message'; $phoneNumber = '639123456789'; diff --git a/src/ridvanbaluyos/sms/Sms.php b/src/ridvanbaluyos/sms/Sms.php index e588726..86bc4bd 100644 --- a/src/ridvanbaluyos/sms/Sms.php +++ b/src/ridvanbaluyos/sms/Sms.php @@ -87,7 +87,7 @@ protected function generateMessageId($length = 32) * @param null $message - an optional message aside from the default ones * @param null $provider - the SMS provider used. Should only be enabled during debug mode. */ - protected function response($code, $message = null, $provider) + protected function response($code, $metadata = null, $message = null, $provider) { switch ($code) { // Error Codes @@ -138,7 +138,8 @@ protected function response($code, $message = null, $provider) $envelope => [ 'code' => $code, 'message' => $message, - 'provider' => $provider + 'provider' => $provider, + 'metadata' => $metadata ], ]; $response = json_encode($response); diff --git a/src/ridvanbaluyos/sms/providers/Chikka.php b/src/ridvanbaluyos/sms/providers/Chikka.php index d8af430..62b8925 100644 --- a/src/ridvanbaluyos/sms/providers/Chikka.php +++ b/src/ridvanbaluyos/sms/providers/Chikka.php @@ -56,7 +56,7 @@ public function send($phoneNumber, $message) curl_close($ch); $result = json_decode($result); - $this->response($result->status, null, $this->className); + $this->response($result->status, $result, null, $this->className); } catch (Exception $e) { } diff --git a/src/ridvanbaluyos/sms/providers/PromoTexter.php b/src/ridvanbaluyos/sms/providers/PromoTexter.php index 0ff2243..317b4d4 100644 --- a/src/ridvanbaluyos/sms/providers/PromoTexter.php +++ b/src/ridvanbaluyos/sms/providers/PromoTexter.php @@ -54,7 +54,7 @@ public function send($phoneNumber, $message) curl_close($ch); $code = (intval($result) > 0) ? 202 : 403; - $this->response($code, null, $this->className); + $this->response($code, $result, null, $this->className); } catch (Exception $e) { } diff --git a/src/ridvanbaluyos/sms/providers/Semaphore.php b/src/ridvanbaluyos/sms/providers/Semaphore.php index 9fbad19..2f6b376 100644 --- a/src/ridvanbaluyos/sms/providers/Semaphore.php +++ b/src/ridvanbaluyos/sms/providers/Semaphore.php @@ -51,7 +51,8 @@ public function send($phoneNumber, $message) curl_close($ch); $result = json_decode($result); - $this->response($result->code, $result->message, $this->className); + + $this->response($result->code, $result, $result->message, $this->className); } catch (Exception $e) { }