Skip to content

Commit

Permalink
Merge pull request #49 from arif98741/dev
Browse files Browse the repository at this point in the history
Lpeek Sms Gateway
  • Loading branch information
sim8568X authored Sep 14, 2023
2 parents 99072c2 + 1f0f447 commit fe75fa4
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 3 deletions.
7 changes: 4 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | - | - |
Expand Down
9 changes: 9 additions & 0 deletions src/Config/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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', ''),
Expand Down
13 changes: 13 additions & 0 deletions src/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
93 changes: 93 additions & 0 deletions src/Provider/Lpeek.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/*
* Last Modified: 6/29/21, 12:06 AM
* Copyright (c) 2021
* -created by Ariful Islam
* -All Rights Preserved By
* -If you have any query then knock me at
* arif98741@gmail.com
* See my profile @ https://github.com/arif98741
*/

namespace Xenon\LaravelBDSms\Provider;

use Xenon\LaravelBDSms\Handler\ParameterException;
use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\LaravelBDSms\Helper\Helper;
use Xenon\LaravelBDSms\Request;
use Xenon\LaravelBDSms\Sender;

class Lpeek extends AbstractProvider
{
/**
* Lpeek constructor.
* @param Sender $sender
*/
public function __construct(Sender $sender)
{
$this->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');
}
}

}

0 comments on commit fe75fa4

Please sign in to comment.