diff --git a/readme.md b/readme.md index a5969fb..2eb550e 100644 --- a/readme.md +++ b/readme.md @@ -194,6 +194,7 @@ echo $status = $sender->send(); | CustomGateway | provide necessary token/api_key/others based on requirements | - | Done | Be careful using this and test based on several scenario | - | | DianaHost | api_key, type, senderid | - | Done | - | - | | DianaSMS | ApiKey, ClientId, SenderId | - | Done | - | - | +| DhorolaSms | apikey, sender | - | Done | - | - | | DurjoySoft | ApiKey, SenderID | - | Done | - | - | | Esms | api_token, sender_id | - | Done | - | - | | ElitBuzz | api_key, type, senderid | - | Done | not tested yet in live | - | diff --git a/src/Config/sms.php b/src/Config/sms.php index 29f7d64..c6d7b29 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -23,6 +23,7 @@ use Xenon\LaravelBDSms\Provider\Brilliant; use Xenon\LaravelBDSms\Provider\BulkSmsBD; use Xenon\LaravelBDSms\Provider\CustomGateway; +use Xenon\LaravelBDSms\Provider\DhorolaSms; use Xenon\LaravelBDSms\Provider\DianaHost; use Xenon\LaravelBDSms\Provider\DianaSms; use Xenon\LaravelBDSms\Provider\DnsBd; @@ -142,6 +143,10 @@ 'ApiKey' => env('SMS_DIANA_SMS_API_KEY', ''), 'ClientId' => env('SMS_DIANA_SMS_CLIENT_ID', ''), ], + DhorolaSms::class => [ + 'apikey' => env('SMS_DHOROLA_SMS_APIKEY', ''), + 'sender' => env('SMS_DHOROLA_SMS_SENDERID', ''), + ], DnsBd::class => [], DurjoySoft::class => [ 'ApiKey' => env('SMS_DURJOYSOFT_SMS_API_KEY', ''), diff --git a/src/Provider/DhorolaSms.php b/src/Provider/DhorolaSms.php new file mode 100644 index 0000000..a5cd5c0 --- /dev/null +++ b/src/Provider/DhorolaSms.php @@ -0,0 +1,93 @@ +senderObject = $sender; + } + + /** + * Send Request To Api and Send Message + * @throws RenderException + */ + public function sendRequest() + { + $number = $this->senderObject->getMobile(); + $text = $this->senderObject->getMessage(); + $config = $this->senderObject->getConfig(); + $queue = $this->senderObject->getQueue(); + $queueName = $this->senderObject->getQueueName(); + $tries = $this->senderObject->getTries(); + $backoff = $this->senderObject->getBackoff(); + + $query = [ + 'apikey' => $config['apikey'], + 'sender' => $config['sender'], + 'msisdn' => $number, + 'smstext' => $text, + ]; + + if (is_array($number)) { + $query['msisdn'] = implode(',', $number); + } + + $headers = [ + 'Content-Type' => 'application/json', + 'verify' => false, + ]; + $requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName, $tries, $backoff); + $requestObject->setHeaders($headers)->setContentTypeJson(true); + $response = $requestObject->post(); + if ($queue) { + return true; + } + + $body = $response->getBody(); + $smsResult = $body->getContents(); + + $data['number'] = $number; + $data['message'] = $text; + return $this->generateReport($smsResult, $data)->getContent(); + } + + /** + * @throws ParameterException + */ + public function errorException() + { + if (!array_key_exists('apikey', $this->senderObject->getConfig())) { + throw new ParameterException('apikey key is absent in configuration'); + } + if (!array_key_exists('sender', $this->senderObject->getConfig())) { + throw new ParameterException('sender key is absent in configuration'); + } + + } +}