Skip to content

Commit

Permalink
Merge pull request #67 from arif98741/dev
Browse files Browse the repository at this point in the history
Sms.net.bd provider added
  • Loading branch information
arif98741 authored Dec 6, 2023
2 parents a319d37 + 1b9552b commit b4c536d
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ echo $status = $sender->send();
| RedmoITSms | api_token, sender_id | - | Support closed | - |
| SmartLabSMS | user, password, sender | - | Done | - | - |
| SmsinBD | api_token, senderid | - | Done | | - |
| SMS.net.bd | api_key | - | 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 | - | |
Expand Down
4 changes: 4 additions & 0 deletions src/Config/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
use Xenon\LaravelBDSms\Provider\Sms4BD;
use Xenon\LaravelBDSms\Provider\SmsinBD;
use Xenon\LaravelBDSms\Provider\SmsNet24;
use Xenon\LaravelBDSms\Provider\SmsNetBD;
use Xenon\LaravelBDSms\Provider\SMSNoc;
use Xenon\LaravelBDSms\Provider\SmsQ;
use Xenon\LaravelBDSms\Provider\Ssl;
Expand Down Expand Up @@ -240,6 +241,9 @@
'api_token' => env('SMSINBD_API_TOKEN', ''),
'senderid' => env('SMSINBD_SENDERID', ''),
],
SmsNetBD::class => [
'api_key' => env('SMS_NET_BD_API_KEY'),
],
SmsQ::class => [
'sender_id' => env('SMS_SMSQ_SENDER_ID', ''),
'api_key' => env('SMS_SMSQ_API_KEY', ''),
Expand Down
8 changes: 7 additions & 1 deletion src/Provider/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
use Xenon\LaravelBDSms\Request;
use Xenon\LaravelBDSms\Sender;

/**
* ====================================================================================================================
* Alpha SMS is an advanced SMS service provider in Bangladesh with multiple services such as Bulk SMS, OTP Notification,
* SMS Gateway, Marketing, Masking SMS, etc. It provides a powerful and easy-to-use SMS API for developers that you can use
* to integration with Software Applications & Websites.
* =========================================================================================================================
*/
class Alpha extends AbstractProvider
{
/**
Expand Down Expand Up @@ -81,6 +88,5 @@ public function errorException(): void
if (!array_key_exists('api_key', $this->senderObject->getConfig())) {
throw new RenderException('api_key key is absent in configuration');
}

}
}
92 changes: 92 additions & 0 deletions src/Provider/SmsNetBD.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/*
* Last Modified: 12/06/23, 11:50 PM
* Copyright (c) 2023
* -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\RenderException;
use Xenon\LaravelBDSms\Request;
use Xenon\LaravelBDSms\Sender;

/**
* =====================================================================================================================================
* SMS.NET.BD( Alpha ) SMS is an advanced SMS service provider in Bangladesh with multiple services such as Bulk SMS, OTP Notification,
* SMS Gateway, Marketing, Masking SMS, etc. It provides a powerful and easy-to-use SMS API for developers that you can use
* to integration with Software Applications & Websites.
* ======================================================================================================================================
*/
class SmsNetBD extends AbstractProvider
{
/**
* Alpha SMS constructor.
* @param Sender $sender
*/
public function __construct(Sender $sender)
{
$this->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'],
'msg' => $text,
'to' => $mobile,
];

/**
* The schedule date and time to send your message. Date and time must be formatted as Y-m-d H:i:s(eg. 2023-10-05 01:36:03)
*/
if (isset($config['schedule'])) {
$query['schedule'] = $config['schedule'];
}

/**
* If you have an approved Sender ID, you can use this parameter to set your Sender ID as from in you messages.
*/
if (isset($config['sender_id'])) {
$query['sender_id'] = $config['sender_id'];
}
if (is_array($mobile)) {
$query['to'] = implode(',', $mobile);
}

$requestObject = new Request('https://api.sms.net.bd/sendsms', $query, $queue);

$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');
}
}
}

0 comments on commit b4c536d

Please sign in to comment.