Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
arif98741 committed May 24, 2024
2 parents c343b96 + d2d8426 commit bc97b67
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 12 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ echo $status = $sender->send();
| TwentyFourBulkSmsBD | customer_id, api_key | - | Done | - | - |
| Trubosms | api_token, sender_id | - | Done | - | - |
| Viatech | api_key, mask | - | Done | - | - |
| ZamanIT | api_key, senderid,type | - | Done | - | - |



Expand Down
6 changes: 6 additions & 0 deletions src/Config/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
use Xenon\LaravelBDSms\Provider\Twenty4BulkSms;
use Xenon\LaravelBDSms\Provider\TwentyFourBulkSmsBD;
use Xenon\LaravelBDSms\Provider\Viatech;
use Xenon\LaravelBDSms\Provider\ZamanIt;

return [
/*
Expand Down Expand Up @@ -297,6 +298,11 @@
'user_email' => env('SMS_TWENTYFOUR_BULKSMS_USER_EMAIL', ''),
'api_key' => env('SMS_TWENTYFOUR_BULKSMS_APP_KEY', ''),
],
ZamanIt::class => [
'api_key' => env('SMS_ZAMANIT_API_KEY', ''),
'type' => env('SMS_ZAMANIT_TYPE', ''),
'senderid' => env('SMS_ZAMANIT_SENDER_ID', ''),
],
]
];

2 changes: 1 addition & 1 deletion src/Facades/SMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @method static \Xenon\LaravelBDSms\SMS via(string $provider)
* @method static mixed shoot(string $mobile, string $text)
* @method static mixed shootWithQueue(string $number, string $text)
* @method static mixed shootWithQueue(string $number, string $text, string $queueName, int $tries, int $backoff)
*
* @see \Xenon\LaravelBDSms\SMS
*/
Expand Down
90 changes: 90 additions & 0 deletions src/Provider/ZamanIt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/*
* Last Modified: 05/24/24, 12:06 AM
* Copyright (c) 2023
* -created by Ariful Islam
* -All Rights Preserved By
* -If you have any query then knock me at
* [email protected]
* See my profile @ https://github.com/arif98741
*/

namespace Xenon\LaravelBDSms\Provider;

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

class ZamanIt extends AbstractProvider
{
private string $apiEndpoint = 'https://sms.zaman-it.com/api/sendsms';

/**
* ZamanIt 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 = $this->senderObject->getMobile();
$text = $this->senderObject->getMessage();
$config = $this->senderObject->getConfig();
$queue = $this->senderObject->getQueue();
$queueName = $this->senderObject->getQueueName();
$tries = $this->senderObject->getTries();
$backoff = $this->senderObject->getBackoff();

$query = [
'api_key' => $config['api_key'],
'type' => $config['type'],
'senderid' => $config['senderid'],
'phone' => $number,
'message' => $text,
];

$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName, $tries, $backoff);

$response = $requestObject->post();
if ($queue) {
return true;
}

$body = $response->getBody();
$smsResult = $body->getContents();

$data['phone'] = $number;
$data['message'] = $text;
return $this->generateReport($smsResult, $data)->getContent();
}

/**
* @throws ParameterException
*/
public function errorException()
{
if (!array_key_exists('api_key', $this->senderObject->getConfig())) {
throw new ParameterException('api_key is absent in configuration');
}

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

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

}

}
10 changes: 5 additions & 5 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Request extends Controller
{
private bool $queue;

private bool $queueName;
private string $queueName;

private string $requestUrl;

Expand All @@ -29,11 +29,11 @@ class Request extends Controller
/**
* @var int
*/
private int $tries = 3;
private int $tries;
/**
* @var int
*/
private $backoff = 60;
private int $backoff;


/**
Expand Down Expand Up @@ -133,7 +133,7 @@ public function setQueue(bool $queue)
/**
* @return string
*/
public function getRequestUrl()
public function getRequestUrl(): string
{
return $this->requestUrl;
}
Expand All @@ -149,7 +149,7 @@ public function setRequestUrl($requestUrl): void
/**
* @return array
*/
public function getQuery()
public function getQuery(): array
{
return $this->query;
}
Expand Down
11 changes: 5 additions & 6 deletions src/SMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,17 @@ public function shoot(string $number, string $text)
* @version v1.0.46-dev
* @since v1.0.46-dev
*/
public function shootWithQueue(string $number, string $text, ?string $queue, ?int $tries, ?int $backoff)
public function shootWithQueue(string $number, string $text, string $queueName = 'default', int $tries = 3, int $backoff = 60)
{
$this->sender->setMobile($number);
$this->sender->setMessage($text);
$this->sender->setQueue(true);
if (isset($queue)){
$this->sender->setQueueName($queue);
}
if (isset($tries)){
$this->sender->setQueueName($queueName);

if (isset($tries)) {
$this->sender->setTries($tries);
}
if (isset($backoff)){
if (isset($backoff)) {
$this->sender->setBackoff($backoff);
}
return $this->sender->send();
Expand Down

0 comments on commit bc97b67

Please sign in to comment.