-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
108 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters