diff --git a/readme.md b/readme.md index 48a2ca2..aac8e42 100644 --- a/readme.md +++ b/readme.md @@ -190,6 +190,7 @@ $status = $sender->send(); | Muthofun | sender_id | Yes | Done | - | - | | NovocomBD | ApiKey , ClientId , SenderId | - | Done | - | - | | OnnoRokomSMS | userName, userPassword, type, maskName, campaignName | - | Done | not tested yet in live | - | +| QuickSms | api_key, senderid, type,scheduledDateTime | - | Done | not tested yet in live | - | | RedmoITSms | api_token, sender_id | - | Support closed | - | | SmartLabSMS | user, password, sender | - | Done | - | - | | SmsinBD | api_token, senderid | - | Done | | - | diff --git a/src/Config/sms.php b/src/Config/sms.php index d4a2217..a87cf3b 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -39,6 +39,7 @@ use Xenon\LaravelBDSms\Provider\Muthofun; use Xenon\LaravelBDSms\Provider\NovocomBd; use Xenon\LaravelBDSms\Provider\Onnorokom; +use Xenon\LaravelBDSms\Provider\QuickSms; use Xenon\LaravelBDSms\Provider\RedmoItSms; use Xenon\LaravelBDSms\Provider\SmartLabSms; use Xenon\LaravelBDSms\Provider\Sms4BD; @@ -197,6 +198,12 @@ 'maskName' => env('SMS_ONNOROKOM_MASK', ''), 'campaignName' => env('SMS_ONNOROKOM_CAMPAIGN_NAME', ''), ], + QuickSms::class => [ + 'api_key' => env('SMS_QUICKSMS_API_KEY'), + 'senderid' => env('SMS_QUICKSMS_SENDER_ID'), + 'type' => env('SMS_QUICKSMS_SENDER_ID'), + 'scheduledDateTime' => env('SMS_QUICKSMS_SCHEDULED_DATE_TIME'), + ], RedmoItSms::class => [ 'sender_id' => env('SMS_REDMOIT_SENDER_ID', ''), 'api_token' => env('SMS_REDMOIT_API_TOKEN', ''), diff --git a/src/Provider/QuickSms.php b/src/Provider/QuickSms.php new file mode 100644 index 0000000..8aceafc --- /dev/null +++ b/src/Provider/QuickSms.php @@ -0,0 +1,85 @@ +senderObject = $sender; + } + + /** + * Send Request To Api and Send Message + * @throws RenderException + */ + public function sendRequest() + { + $mobile = $this->senderObject->getMobile(); + $text = $this->senderObject->getMessage(); + $config = $this->senderObject->getConfig(); + $queue = $this->senderObject->getQueue(); + + $query = [ + 'api_key' => $config['api_key'], + 'senderid' => $config['senderid'], + 'contacts' => $mobile, + 'msg' => $text, + ]; + + if (array_key_exists('type', $config)) { + $query ['type'] = $config['type']; + } + + if (array_key_exists('scheduledDateTime', $config)) { + $query ['scheduledDateTime'] = $config['scheduledDateTime']; + } + + if (is_array($mobile)) { + $query['contacts'] = implode(',', $mobile); + } + + $requestObject = new Request('https://server1.quicksms.xyz/smsapi', $query, $queue); + $requestObject->setContentTypeJson(true); + + $response = $requestObject->post(); + if ($queue) { + return true; + } + $body = $response->getBody(); + $smsResult = $body->getContents(); + $data['number'] = $mobile; + $data['message'] = $text; + return $this->generateReport($smsResult, $data)->getContent(); + } + + /** + * @throws RenderException + */ + public function errorException(): void + { + if (!array_key_exists('api_key', $this->senderObject->getConfig())) { + throw new RenderException('api_key key is absent in configuration'); + } + if (!array_key_exists('senderid', $this->senderObject->getConfig())) { + throw new RenderException('senderid key is absent in configuration'); + } + } +}