Skip to content

Commit

Permalink
fix sms route
Browse files Browse the repository at this point in the history
  • Loading branch information
Mujhtech committed Aug 5, 2021
1 parent 5b095e9 commit bce8e16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,16 @@ sendchamp()->createSmsSender($sender_name, $use_case, $sample_message);
* (Example: 23490126727). You can also send to multiple numbers.
* To do that put numbers in an array
* (Example: [ '234somenumber', '234anothenumber' ]).
* @param string $route e.g ['NON_DND_NG', 'DND_NGN','PREMIUM_NG']
* @return array
*
*/
SendChamp::sendSms($message, $sender_name, $numbers)
SendChamp::sendSms($message, $sender_name, $numbers, $route)

/**
* Alternatively, use the helper.
*/
sendchamp()->sendSms($message, $sender_name, $numbers, $route);


/**
Expand Down
19 changes: 16 additions & 3 deletions src/SendChamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class SendChamp {

private $tokenType = ['NUMERIC','ALPHANUMERIC'];

/**
* @var array
*/

private $smsRoute = ['NON_DND_NG', 'DND_NGN','PREMIUM_NG'];

/**
* @var string
*/
Expand Down Expand Up @@ -173,7 +179,7 @@ public function createSmsSender(string $sender_name, string $use_case,
];


return $this->setRequestOptions()->setHttpResponse('/sms/send', 'POST', $data)->getResponse();
return $this->setRequestOptions()->setHttpResponse('/sms/sender/create', 'POST', $data)->getResponse();

}

Expand All @@ -193,12 +199,19 @@ public function createSmsSender(string $sender_name, string $use_case,
* @return array
*/

public function sendSms(string $message, string $sender_name, array $numbers){
public function sendSms(string $message, string $sender_name, array $numbers, string $route = ""){

if(!empty($route) && !in_array( $route ,$this->smsRoute )){

throw new SendChampException("Invalid sms route");

}

$data = [
'to' => $numbers,
'message' => $message,
'sender_name' => $sender_name
'sender_name' => $sender_name,
'route' => $route
];


Expand Down

0 comments on commit bce8e16

Please sign in to comment.