diff --git a/readme.md b/readme.md index 76f5b63..048b666 100644 --- a/readme.md +++ b/readme.md @@ -185,16 +185,17 @@ $status = $sender->send(); | ElitBuzz | api_key, type, senderid | Done | not tested yet in live | - | | Grameenphone | username, password, messagetype | Done | not tested yet in live | - | | Infobip | user, password | Done | not tested yet in live | - | +| Lpeek | acode, apiKey, requestID, masking | Done | - | - | | MDL | api_key, type, senderid | Done | not tested yet in live | - | | Metronet | api_key, mask | Done | - | - | | MimSms | api_key, type, senderid | Done | - | - | | Mobireach | Username,Password, From | Done | - | - | | NovocomBD | ApiKey , ClientId , SenderId | Done | - | - | | OnnoRokomSMS | userName, userPassword, type, maskName, campaignName | Done | not tested yet in live | - | -| RedmoITSms | api_token, sender_id | Support closed | - | +| RedmoITSms | api_token, sender_id | Support closed | - | | SmartLabSMS | user, password, sender | Done | - | - | -| SmsinBD | api_token, senderid | Done | | - | -| SmsQ | sender_id, client_id, api_key | Done | | - | +| SmsinBD | api_token, senderid | Done | | - | +| SmsQ | sender_id, client_id, api_key | Done | | - | | SMSNet24 | user_id, user_password, route_id(optional), sms_type_id(optional) | Done | - | | | SmsNoc | sender_id, bearer_token | Done | - | | | Sslsms | api_token, sid, csms_id | Done | - | - | diff --git a/src/Config/sms.php b/src/Config/sms.php index 1ee3ddf..af86ac6 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -30,6 +30,7 @@ use Xenon\LaravelBDSms\Provider\Grameenphone; use Xenon\LaravelBDSms\Provider\GreenWeb; use Xenon\LaravelBDSms\Provider\Infobip; +use Xenon\LaravelBDSms\Provider\Lpeek; use Xenon\LaravelBDSms\Provider\MDL; use Xenon\LaravelBDSms\Provider\Metronet; use Xenon\LaravelBDSms\Provider\MimSms; @@ -137,6 +138,14 @@ 'password' => env('SMS_INFOBIP_PASSWORD', ''), 'from' => env('SMS_INFOBIP_FROM', ''), ], + Lpeek::class => [ + 'acode' => env('SMS_LPEEK_ACODE', ''), + 'apiKey' => env('SMS_LPEEK_APIKEY', ''), + 'requestID' => env('SMS_LPEEK_REQUESTID', ''), + 'masking' => env('SMS_LPEEK_MASKING', ''), + 'is_unicode' => env('SMS_LPEEK_IS_UNICODE', '0'), + 'transactionType' => env('SMS_LPEEK_TRANSACTIONTYPE', 'T'), + ], MDL::class => [ 'senderid' => env('SMS_MDL_SENDER_ID', ''), 'api_key' => env('SMS_MDL_API_KEY', ''), diff --git a/src/Helper/Helper.php b/src/Helper/Helper.php index 82c0363..0b8cb3f 100644 --- a/src/Helper/Helper.php +++ b/src/Helper/Helper.php @@ -46,4 +46,17 @@ public static function checkMobileNumberPrefixExistence($mobile) } return '88' . $mobile; } + + /** + * @param string $text + * @return string + * @since v1.0.52.0-beta + * @version v1.0.52.0-beta + */ + public static function ensureNumberStartsWith88(string $text): string { + if (!str_starts_with($text, '88')) { + $text = '88' . $text; + } + return $text; + } } diff --git a/src/Provider/Lpeek.php b/src/Provider/Lpeek.php new file mode 100644 index 0000000..211f794 --- /dev/null +++ b/src/Provider/Lpeek.php @@ -0,0 +1,93 @@ +senderObject = $sender; + } + + /** + * Send Request To Api and Send Message + * @throws RenderException + */ + public function sendRequest() + { + $number = Helper::ensureNumberStartsWith88($this->senderObject->getMobile()); + + $text = $this->senderObject->getMessage(); + $config = $this->senderObject->getConfig(); + $queue = $this->senderObject->getQueue(); + + $data = [ + 'auth' => [ + 'acode' => $config['acode'], + 'apiKey' => $config['apiKey'], + ], + 'smsInfo' => [ + 'requestID' => $config['requestID'], + 'message' => $text, + 'is_unicode' => $config['is_unicode'] ?? 0, + 'masking' => $config['masking'], + 'msisdn' => $number, + 'transactionType' => $config['transactionType'] ?? 'T', + ], + ]; + + $requestObject = new Request('https://sms.lpeek.com/API/sendSMS', $data, $queue); + $requestObject->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('acode', $this->senderObject->getConfig())) { + throw new ParameterException('acode is absent in configuration'); + } + + if (!array_key_exists('apiKey', $this->senderObject->getConfig())) { + throw new ParameterException('apiKey key is absent in configuration'); + } + if (!array_key_exists('requestID', $this->senderObject->getConfig())) { + throw new ParameterException('requestID key is absent in configuration'); + } + if (!array_key_exists('masking', $this->senderObject->getConfig())) { + throw new ParameterException('masking key is absent in configuration'); + } + } + +}