Skip to content

Commit

Permalink
Merge pull request #14 from arif98741/smsnet24-gateway
Browse files Browse the repository at this point in the history
Merge request for Smsnet24
  • Loading branch information
arif98741 authored Sep 27, 2022
2 parents 540c41f + f8543e0 commit 88a1c6f
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions src/Provider/SmsNet24.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/*
* Last Modified: 6/28/21, 11:18 PM
* 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\RenderException;
use Xenon\LaravelBDSms\Request;
use Xenon\LaravelBDSms\Sender;

class SmsNet24 extends AbstractProvider
{
/**
* SmsNet24 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_token' => $config['api_token'],
'sid' => $config['sid'],
'csms_id' => $config['csms_id'],
'msisdn' => $mobile,
'sms' => $text,
];

if (is_array($mobile)) {
$requestObject = new Request('https://smsplus.sslwireless.com/api/v3/send-sms/bulk', $query, $queue);
} else {
$requestObject = new Request('https://smsplus.sslwireless.com/api/v3/send-sms', $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()
{
if (!array_key_exists('api_token', $this->senderObject->getConfig())) {
throw new RenderException('api_token key is absent in configuration');
}

if (!array_key_exists('sid', $this->senderObject->getConfig())) {
throw new RenderException('sid key is absent in configuration');
}

if (!array_key_exists('csms_id', $this->senderObject->getConfig())) {
throw new RenderException('csms_id key is absent in configuration');
}

}
}

0 comments on commit 88a1c6f

Please sign in to comment.