Skip to content

Commit 6d2e50e

Browse files
committed
add viatech sms gateway to the list
1 parent e0504d1 commit 6d2e50e

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

src/Provider/Viatech.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
namespace Xenon\LaravelBDSms\Provider;
4+
5+
use GuzzleHttp\Client;
6+
use GuzzleHttp\Exception\ClientException;
7+
use GuzzleHttp\Exception\GuzzleException;
8+
use Illuminate\Http\JsonResponse;
9+
use Xenon\LaravelBDSms\Handler\RenderException;
10+
use Xenon\LaravelBDSms\Sender;
11+
12+
class BoomCast extends AbstractProvider
13+
{
14+
/**
15+
* BoomCast Constructor
16+
* @param Sender $sender
17+
* @version v1.0.32
18+
* @since v1.0.31
19+
*/
20+
public function __construct(Sender $sender)
21+
{
22+
$this->senderObject = $sender;
23+
}
24+
25+
/**
26+
* @return JsonResponse
27+
* @throws GuzzleException
28+
* @throws RenderException
29+
* @version v1.0.37
30+
* @since v1.0.31
31+
*/
32+
public function sendRequest()
33+
{
34+
$mobile = $this->senderObject->getMobile();
35+
$text = $this->senderObject->getMessage();
36+
$config = $this->senderObject->getConfig();
37+
38+
39+
$client = new Client([
40+
'base_uri' => 'https://api.boom-cast.com/boomcast/WebFramework/boomCastWebService/OTPMessage.php',
41+
'timeout' => 10.0,
42+
'verify' => false,
43+
]);
44+
45+
try {
46+
$response = $client->request('GET', '', [
47+
'query' => [
48+
"masking" => $config['masking'],
49+
"userName" => $config['username'],
50+
"password" => $config['password'],
51+
"MsgType" => "TEXT",
52+
"receiver" => $mobile,
53+
"message" => $text,
54+
],
55+
'timeout' => 60,
56+
'read_timeout' => 60,
57+
'connect_timeout' => 60
58+
]);
59+
} catch (ClientException|GuzzleException $e) {
60+
throw new RenderException($e->getMessage());
61+
}
62+
63+
64+
$response = $response->getBody()->getContents();
65+
66+
$data['number'] = $mobile;
67+
$data['message'] = $text;
68+
return $this->generateReport($response, $data);
69+
}
70+
71+
/**
72+
* @throws RenderException
73+
* @version v1.0.32
74+
* @since v1.0.31
75+
*/
76+
public function errorException()
77+
{
78+
$config = $this->senderObject->getConfig();
79+
80+
81+
if (!array_key_exists('masking', $config))
82+
throw new RenderException('masking key is absent in configuration');
83+
84+
if (!array_key_exists('username', $config))
85+
throw new RenderException('username key is absent in configuration');
86+
87+
if (!array_key_exists('password', $config))
88+
throw new RenderException('password key is absent in configuration');
89+
}
90+
}

0 commit comments

Comments
 (0)