From 6d2e50e936ff43313741cdd3ab6128c5779844a9 Mon Sep 17 00:00:00 2001 From: Ariful islam Date: Mon, 24 Jan 2022 10:57:03 +0600 Subject: [PATCH] add viatech sms gateway to the list --- src/Provider/Viatech.php | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/Provider/Viatech.php diff --git a/src/Provider/Viatech.php b/src/Provider/Viatech.php new file mode 100644 index 0000000..4aa12bb --- /dev/null +++ b/src/Provider/Viatech.php @@ -0,0 +1,90 @@ +senderObject = $sender; + } + + /** + * @return JsonResponse + * @throws GuzzleException + * @throws RenderException + * @version v1.0.37 + * @since v1.0.31 + */ + public function sendRequest() + { + $mobile = $this->senderObject->getMobile(); + $text = $this->senderObject->getMessage(); + $config = $this->senderObject->getConfig(); + + + $client = new Client([ + 'base_uri' => 'https://api.boom-cast.com/boomcast/WebFramework/boomCastWebService/OTPMessage.php', + 'timeout' => 10.0, + 'verify' => false, + ]); + + try { + $response = $client->request('GET', '', [ + 'query' => [ + "masking" => $config['masking'], + "userName" => $config['username'], + "password" => $config['password'], + "MsgType" => "TEXT", + "receiver" => $mobile, + "message" => $text, + ], + 'timeout' => 60, + 'read_timeout' => 60, + 'connect_timeout' => 60 + ]); + } catch (ClientException|GuzzleException $e) { + throw new RenderException($e->getMessage()); + } + + + $response = $response->getBody()->getContents(); + + $data['number'] = $mobile; + $data['message'] = $text; + return $this->generateReport($response, $data); + } + + /** + * @throws RenderException + * @version v1.0.32 + * @since v1.0.31 + */ + public function errorException() + { + $config = $this->senderObject->getConfig(); + + + if (!array_key_exists('masking', $config)) + throw new RenderException('masking key is absent in configuration'); + + if (!array_key_exists('username', $config)) + throw new RenderException('username key is absent in configuration'); + + if (!array_key_exists('password', $config)) + throw new RenderException('password key is absent in configuration'); + } +}