Skip to content

Commit

Permalink
add metadata in response envelope
Browse files Browse the repository at this point in the history
- this is the actual response of the SMS Gateway
  • Loading branch information
ridvanbaluyos committed Dec 12, 2016
1 parent a29fa98 commit 311ea7a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
1 change: 1 addition & 0 deletions sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 3 additions & 2 deletions src/ridvanbaluyos/sms/Sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ridvanbaluyos/sms/providers/Chikka.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

}
Expand Down
2 changes: 1 addition & 1 deletion src/ridvanbaluyos/sms/providers/PromoTexter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

}
Expand Down
3 changes: 2 additions & 1 deletion src/ridvanbaluyos/sms/providers/Semaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

}
Expand Down

0 comments on commit 311ea7a

Please sign in to comment.