diff --git a/readme.md b/readme.md
index aac8e42..b79fd38 100644
--- a/readme.md
+++ b/readme.md
@@ -163,45 +163,74 @@ $sender->setConfig(
$status = $sender->send();
+# Sms Send Using Custom Gateway
+`We have tried to added most of the gateways of Bangladesh in this package as much as possible. But still if you don't find your expected gateway in this list, then use Custom Gateway using following code snippet.`
+
+use Xenon\LaravelBDSms\Provider\CustomGateway;
+use Xenon\LaravelBDSms\Sender;
-# Currently Supported Sms Gateways
+$sender = Sender::getInstance();
+$sender->setProvider(CustomGateway::class);
+$sender->setUrl('https://your_cusom_gateway_provider_url_here')
+ ->setMethod('post')
+ ->setHeaders([
+ 'Content-Type: application/json',
+ 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+ ], false);
+$sender->setMobile(true);
+$sender->setMessage(true);
+$sender->setQueue(false);
+//use required parameters based on your sms gateway
+$sender->setConfig(
+ [
+ 'MsgType' => 'TEXT',
+ 'masking' => 'sample',
+ 'userName' => 'test_user',
+ 'message' => 'test message',
+ 'receiver' => '017xxxxxxxxxx',
+ ]
+);
+echo $status = $sender->send();
+
+# Currently Supported Sms Gateways
-| Provider | Credentials Required
For Sending SMS | Support Multiple | Status | Comment | Contact |
-|-----------------|-------------------------------------------------------------------|------------------|----------------|------------------------|---------|
-| AjuraTech | apikey, secretkey , callerID | - | Done | - | - |
-| Adn | api_key, type, senderid | - | Done | - | - |
-| Alpha | api_key | Yes | Done | - | - |
-| Banglalink | userID, passwd , sender | - | Done | - | - |
-| BDBulkSMS | token | - | Done | - | - |
-| BoomCast | masking , userName , password | - | Done | - | - |
-| BulksmsBD | api_key,senderid | - | Done | - | - |
-| DianaHost | api_key, type, senderid | - | Done | - | - |
-| DianaSMS | ApiKey, ClientId, SenderId | - | Done | - | - |
-| Esms | api_token, sender_id | - | Done | - | - |
-| 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 | - | - |
-| 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 | | - |
-| 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 | Yes | Done | - | - |
-| Tense | user, password, campaign, masking | - | Done | - | - |
-| TwentyFourSmsBD | apiKey, sender_id | - | Done | - | - |
-| Trubosms | api_token, sender_id | - | Done | - | - |
-| Viatech | api_key, mask | - | Done | - | - |
+| Provider | Credentials Required
For Sending SMS | Support Multiple | Status | Comment | Contact |
+|-----------------|-------------------------------------------------------------------|------------------|----------------|----------------------------------------------------------|---------|
+| AjuraTech | apikey, secretkey , callerID | - | Done | - | - |
+| Adn | api_key, type, senderid | - | Done | - | - |
+| Alpha | api_key | Yes | Done | - | - |
+| Banglalink | userID, passwd , sender | - | Done | - | - |
+| BDBulkSMS | token | - | Done | - | - |
+| BoomCast | masking , userName , password | - | Done | - | - |
+| BulksmsBD | api_key,senderid | - | Done | - | - |
+| 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 | - | - |
+| Esms | api_token, sender_id | - | Done | - | - |
+| 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 | - | - |
+| 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 | | - |
+| 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 | Yes | Done | - | - |
+| Tense | user, password, campaign, masking | - | Done | - | - |
+| TwentyFourSmsBD | apiKey, sender_id | - | Done | - | - |
+| Trubosms | api_token, sender_id | - | Done | - | - |
+| Viatech | api_key, mask | - | Done | - | - |
diff --git a/src/Config/sms.php b/src/Config/sms.php
index a87cf3b..87f7412 100644
--- a/src/Config/sms.php
+++ b/src/Config/sms.php
@@ -22,6 +22,7 @@
use Xenon\LaravelBDSms\Provider\BoomCast;
use Xenon\LaravelBDSms\Provider\Brilliant;
use Xenon\LaravelBDSms\Provider\BulkSmsBD;
+use Xenon\LaravelBDSms\Provider\CustomGateway;
use Xenon\LaravelBDSms\Provider\DianaHost;
use Xenon\LaravelBDSms\Provider\DianaSms;
use Xenon\LaravelBDSms\Provider\DnsBd;
@@ -115,6 +116,9 @@
BulkSmsBD::class => [
'api_key' => env('SMS_BULK_SMS_BD_API_KEY', ''),
'senderid' => env('SMS_BULK_SMS_BD_SENDERID', ''),
+ ],
+ CustomGateway::class => [
+
],
DianaHost::class => [
'senderid' => env('SMS_DIANA_HOST_SENDER_ID', ''),
diff --git a/src/Provider/CustomGateway.php b/src/Provider/CustomGateway.php
new file mode 100644
index 0000000..786edaa
--- /dev/null
+++ b/src/Provider/CustomGateway.php
@@ -0,0 +1,71 @@
+senderObject = $sender;
+ }
+
+ /**
+ * Send Request To Api and Send Message
+ * @throws RenderException|GuzzleException
+ */
+ public function sendRequest()
+ {
+ $mobile = $this->senderObject->getMobile();
+ $text = $this->senderObject->getMessage();
+ $config = $this->senderObject->getConfig();
+ $queue = $this->senderObject->getQueue();
+ $query = $config;
+
+ $requestObject = new Request($this->senderObject->url, $query, $queue);
+
+ if (isset($this->senderObject->headers)) {
+ $requestObject->setHeaders($this->senderObject->headers);
+ $this->senderObject->contentTypeJson && $requestObject->setContentTypeJson(true);
+ }
+
+ $response = $this->senderObject->method === 'post' ? $requestObject->post() : $requestObject->get();
+
+ if ($queue) {
+ return true;
+ }
+
+ $body = $response->getBody();
+ $smsResult = $body->getContents();
+ $data['number'] = $mobile;
+ $data['message'] = $text;
+ return $this->generateReport($smsResult, $data)->getContent();
+ }
+
+ /**
+ * @throws RenderException
+ */
+ final public function errorException(): void
+ {
+ if (!isset($this->senderObject->url)) {
+ throw new RenderException("Url missing for custom gateway. Use setUrl() to set sms gateway endpoint ");
+ }
+ }
+}
diff --git a/src/Sender.php b/src/Sender.php
index f5aec60..24cdbe2 100644
--- a/src/Sender.php
+++ b/src/Sender.php
@@ -18,6 +18,7 @@
use Xenon\LaravelBDSms\Handler\ParameterException;
use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\LaravelBDSms\Provider\AbstractProvider;
+use Xenon\LaravelBDSms\Provider\CustomGateway;
class Sender
{
@@ -37,34 +38,24 @@ class Sender
* @var
*/
private $config;
+
+ /**
+ * @var string
+ */
+ public string $url;
/**
* @var
*/
- private $method;
+ public $method;
/**
* @var bool
*/
private bool $queue = false;
- /**
- * @return mixed
- */
- public function getMethod()
- {
- return $this->method;
- }
-
- /**
- * @param mixed $method
- */
- public function setMethod($method): void
- {
- $this->method = $method;
- }
/**
- * @var null
+ * @var Sender|null
*/
private static $instance = null;
@@ -81,12 +72,27 @@ public function setMethod($method): void
public static function getInstance(): Sender
{
if (!isset(self::$instance)) {
- self::$instance = new Sender;
+ self::$instance = new self;
}
return self::$instance;
+ }
+ /**
+ * @return mixed
+ */
+ public function getMethod()
+ {
+ return $this->method;
+ }
+ /**
+ * @param mixed $method
+ */
+ public function setMethod($method)
+ {
+ $this->method = $method;
+ return self::$instance;
}
/**
@@ -130,6 +136,17 @@ public function getQueue()
}
+ /**
+ * @param array $headers
+ * @return Sender
+ * @since v1.0.55.0-beta
+ */
+ public function setHeaders(array $headers,bool $contentTypeJson = true): Sender
+ {
+ $this->headers = $headers;
+ $this->contentTypeJson = $contentTypeJson;
+ return self::getInstance();
+ }
/**
* Send Message Finally
@@ -144,14 +161,17 @@ public function send()
throw new ParameterException('config must be an array');
}
- if (empty($this->getMobile())) {
- throw new ParameterException('Mobile number should not be empty');
- }
+ if(!$this->provider instanceof CustomGateway){ //empty check for all providers mobile and message
+ if (empty($this->getMobile())) {
+ throw new ParameterException('Mobile number should not be empty');
+ }
- if (empty($this->getMessage())) {
- throw new ParameterException('Message text should not be empty');
+ if (empty($this->getMessage())) {
+ throw new ParameterException('Message text should not be empty');
+ }
}
+
$this->provider->errorException();
$config = Config::get('sms');
@@ -205,6 +225,16 @@ public function setMessage($message = ''): Sender
return self::getInstance();
}
+ /**
+ * @param string $url
+ * @return $this
+ */
+ public function setUrl(string $url)
+ {
+ $this->url = $url;
+ return self::getInstance();
+ }
+
/**
* @return mixed
* @since v1.0.0