Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ssatz authored and actions-user committed Jun 8, 2020
1 parent de70ffe commit b777186
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 31 deletions.
4 changes: 2 additions & 2 deletions config/exotel-sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* *.
*/
return [
'SID' => '',
'Token' => '',
'SID' => '',
'Token' => '',
'SenderId' => '',
];
7 changes: 1 addition & 6 deletions src/Exception/ConfigNotDefinedException.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<?php
/**
*
* * *
* * * * Copyright (C) Optimo Technologies - All Rights Reserved
* * * * Unauthorized copying of this file, via any medium is strictly prohibited
* * * * Proprietary and confidential
* * * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>
* * *
* *
*
* * * * Written by Sathish Kumar(satz) <sathish.thi@gmail.com>.
*/

namespace OptimoApps\ExotelSms\Exception;


use Exception;
use Illuminate\Support\Facades\Log;

Expand Down
32 changes: 14 additions & 18 deletions src/ExotelSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

use GuzzleHttp\Client;
use OptimoApps\ExotelSms\Enum\SmsType;
use OptimoApps\ExotelSms\Exception\ExotelException;
use OptimoApps\ExotelSms\Exception\ConfigNotDefinedException;
use OptimoApps\ExotelSms\Exception\ExotelException;

/**
* Class ExotelSms.
Expand All @@ -25,7 +25,7 @@ class ExotelSms
/**
* @var Client
*/
protected $client;
protected $client;
/**
* @var
*/
Expand All @@ -39,30 +39,25 @@ class ExotelSms
*/
protected $senderId;

/**
* @param int $toMobile
* @param string $message
*/
public static function send(int $toMobile, string $message)
{
return (new static())->sms($toMobile, $message);
}

/**
* Send Bulk Dynamic Bulk Sms
* @link https://developer.exotel.com/api/#send-bulk-dynamic-sms.
* @param array $messages
* Send Bulk Dynamic Bulk Sms.
*
* @see https://developer.exotel.com/api/#send-bulk-dynamic-sms.
*/
public static function sendBulkDynamicSms(array $messages)
{
return (new static())->bulkDynamicSms($messages);
}

/**
* @return string
* @throws ConfigNotDefinedException
*/
private function buildUrl(int $smsType):string
private function buildUrl(int $smsType): string
{
$this->sid = config('exotel-sms.SID');
$this->token = config('exotel-sms.Token');
Expand Down Expand Up @@ -95,20 +90,21 @@ public function sms($mobile, $message)
$response = $this->client->post($this->buildUrl(SmsType::SMS), [
'form_params' => [
'From' => $this->senderId,
'To' => $mobile,
'To' => $mobile,
'Body' => $message,
],
]);
if ($response->getStatusCode() === 200) {
if (200 === $response->getStatusCode()) {
return $response->getBody()->getContents();
}
throw new ExotelException($response->getBody(), $response->getStatusCode());
}

/**
* Send Bulk SMS
* @link https://developer.exotel.com/api/#send-bulk-dynamic-sms.
* @param array $messages
* Send Bulk SMS.
*
* @see https://developer.exotel.com/api/#send-bulk-dynamic-sms.
*
* @throws ConfigNotDefinedException
* @throws ExotelException
*/
Expand All @@ -117,11 +113,11 @@ public function bulkDynamicSms(array $messages)
$this->client = new Client();
$response = $this->client->post($this->buildUrl(SmsType::BULK_DYNAMIC_SMS), [
'form_params' => [
'From' => $this->senderId,
'From' => $this->senderId,
'Messages'=> $messages,
],
]);
if ($response->getStatusCode() === 200) {
if (200 === $response->getStatusCode()) {
return $response->getBody()->getContents();
}

Expand Down
3 changes: 1 addition & 2 deletions tests/ExotelSmsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
*
*/

use Illuminate\Support\Facades\Config;
use OptimoApps\ExotelSms\Exception\ConfigNotDefinedException;
use OptimoApps\ExotelSms\ExotelSms;
use Illuminate\Support\Facades\Config;


class ExotelSmsTest extends TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace OptimoApps\ExotelSms\Test;

use Illuminate\Config\Repository;
Expand Down Expand Up @@ -33,4 +32,4 @@ public function testRegisterMakesRazorXAvailableInApp()
self::assertTrue($app->has(ExotelSms::class));
self::assertInstanceOf(ExotelSms::class, $app->make(ExotelSms::class));
}
}
}
3 changes: 2 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/
class TestCase extends OrchestraTestCase
{

/**
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageProviders($app)
Expand All @@ -32,6 +32,7 @@ protected function getPackageProviders($app)

/**
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageAliases($app)
Expand Down

0 comments on commit b777186

Please sign in to comment.