forked from SimpleSoftwareIO/simple-sms
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Corey McCormick
committed
Apr 24, 2016
1 parent
35b72b1
commit 9a7fb71
Showing
20 changed files
with
328 additions
and
458 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
<?php namespace SimpleSoftwareIO\SMS; | ||
<?php | ||
|
||
/** | ||
* Simple-SMS | ||
* Simple-SMS is a package made for Laravel to send/receive (polling/pushing) text messages. | ||
* | ||
* @link http://www.simplesoftware.io | ||
* @author Maksim (Ellrion) Platonov <[email protected]>, <[email protected]> | ||
* | ||
*/ | ||
namespace SimpleSoftwareIO\SMS; | ||
|
||
use GuzzleHttp\Client; | ||
use Illuminate\Support\Manager; | ||
use SimpleSoftwareIO\SMS\Drivers\CallFireSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\EmailSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\EZTextingSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\LabsMobileSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\MozeoSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\NexmoSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\MozeoSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\TwilioSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\ZenviaSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\CallFireSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\EZTextingSMS; | ||
use SimpleSoftwareIO\SMS\Drivers\LabsMobileSMS; | ||
|
||
class DriverManager extends Manager | ||
{ | ||
|
@@ -35,24 +28,23 @@ public function getDefaultDriver() | |
/** | ||
* Set the default sms driver name. | ||
* | ||
* @param string $name | ||
* @return void | ||
* @param string $name | ||
*/ | ||
public function setDefaultDriver($name) | ||
{ | ||
$this->app['config']['sms.driver'] = $name; | ||
} | ||
|
||
/** | ||
* Create an instance of the callfire driver | ||
* Create an instance of the callfire driver. | ||
* | ||
* @return CallFireSMS | ||
*/ | ||
protected function createCallfireDriver() | ||
{ | ||
$config = $this->app['config']->get('sms.callfire', []); | ||
|
||
$provider = new CallFireSMS(new Client); | ||
$provider = new CallFireSMS(new Client()); | ||
|
||
$provider->setUser($config['app_login']); | ||
$provider->setPassword($config['app_password']); | ||
|
@@ -61,7 +53,7 @@ protected function createCallfireDriver() | |
} | ||
|
||
/** | ||
* Creates an instance of the email driver | ||
* Creates an instance of the email driver. | ||
* | ||
* @return EmailSMS | ||
*/ | ||
|
@@ -73,19 +65,19 @@ protected function createEmailDriver() | |
} | ||
|
||
/** | ||
* Create an instance of the eztexting driver | ||
* Create an instance of the eztexting driver. | ||
* | ||
* @return EZTextingSMS | ||
*/ | ||
protected function createEztextingDriver() | ||
{ | ||
$config = $this->app['config']->get('sms.eztexting', []); | ||
|
||
$provider = new EZTextingSMS(new Client); | ||
$provider = new EZTextingSMS(new Client()); | ||
|
||
$data = [ | ||
'User' => $config['username'], | ||
'Password' => $config['password'] | ||
'Password' => $config['password'], | ||
]; | ||
$provider->buildBody($data); | ||
|
||
|
@@ -96,13 +88,13 @@ protected function createLabsMobileDriver() | |
{ | ||
$config = $this->app['config']->get('sms.labsmobile', []); | ||
|
||
$provider = new LabsMobileSMS(new Client); | ||
$provider = new LabsMobileSMS(new Client()); | ||
|
||
$auth = [ | ||
'client' => $config['client'], | ||
'username' => $config['username'], | ||
'password' => $config['password'], | ||
'test' => $config['test'] | ||
'test' => $config['test'], | ||
]; | ||
|
||
$provider->buildBody($auth); | ||
|
@@ -111,15 +103,15 @@ protected function createLabsMobileDriver() | |
} | ||
|
||
/** | ||
* Create an instance of the mozeo driver | ||
* Create an instance of the mozeo driver. | ||
* | ||
* @return MozeoSMS | ||
*/ | ||
protected function createMozeoDriver() | ||
{ | ||
$config = $this->app['config']->get('sms.mozeo', []); | ||
|
||
$provider = new MozeoSMS(new Client); | ||
$provider = new MozeoSMS(new Client()); | ||
|
||
$auth = [ | ||
'companykey' => $config['company_key'], | ||
|
@@ -132,7 +124,7 @@ protected function createMozeoDriver() | |
} | ||
|
||
/** | ||
* Create an instance of the nexmo driver | ||
* Create an instance of the nexmo driver. | ||
* | ||
* @return MozeoSMS | ||
*/ | ||
|
@@ -141,7 +133,7 @@ protected function createNexmoDriver() | |
$config = $this->app['config']->get('sms.nexmo', []); | ||
|
||
$provider = new NexmoSMS( | ||
new Client, | ||
new Client(), | ||
$config['api_key'], | ||
$config['api_secret'] | ||
); | ||
|
@@ -150,7 +142,7 @@ protected function createNexmoDriver() | |
} | ||
|
||
/** | ||
* Create an instance of the Twillo driver | ||
* Create an instance of the Twillo driver. | ||
* | ||
* @return TwilioSMS | ||
*/ | ||
|
@@ -167,7 +159,7 @@ protected function createTwilioDriver() | |
} | ||
|
||
/** | ||
* Create an instance of the Zenvia driver | ||
* Create an instance of the Zenvia driver. | ||
* | ||
* @return ZenviaSMS | ||
*/ | ||
|
@@ -176,7 +168,7 @@ protected function createZenviaDriver() | |
$config = $this->app['config']->get('sms.zenvia', []); | ||
|
||
$provider = new ZenviaSMS( | ||
new Client, | ||
new Client(), | ||
$config['account_key'], | ||
$config['passcode'], | ||
$config['callbackOption'] | ||
|
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 |
---|---|---|
@@ -1,13 +1,6 @@ | ||
<?php namespace SimpleSoftwareIO\SMS\Drivers; | ||
<?php | ||
|
||
/** | ||
* Simple-SMS | ||
* Simple-SMS is a package made for Laravel to send/receive (polling/pushing) text messages. | ||
* | ||
* @link http://www.simplesoftware.io | ||
* @author SimpleSoftware [email protected] | ||
* | ||
*/ | ||
namespace SimpleSoftwareIO\SMS\Drivers; | ||
|
||
use SimpleSoftwareIO\SMS\IncomingMessage; | ||
|
||
|
@@ -48,22 +41,23 @@ protected function buildCall($url) | |
} | ||
|
||
/** | ||
* Builds a URL | ||
* Builds a URL. | ||
* | ||
* @param array $segments | ||
* | ||
* @return string | ||
*/ | ||
protected function buildUrl(Array $segments = []) | ||
protected function buildUrl(array $segments = []) | ||
{ | ||
//Get the base URL and add a ? | ||
$url = $this->apiBase . '?'; | ||
$url = $this->apiBase.'?'; | ||
|
||
if (isset($this->apiEnding)) { | ||
$segments = array_merge($segments, $this->apiEnding); | ||
} | ||
|
||
foreach ($segments as $key => $value) { | ||
$url = $url . "$key=$value&"; | ||
$url = $url."$key=$value&"; | ||
} | ||
|
||
//Remove the final & | ||
|
@@ -76,7 +70,7 @@ protected function buildUrl(Array $segments = []) | |
* Builds the body part of the request and adds it to the body array. | ||
* | ||
* @param array|string $values Provides the data to be merged into the array. If a string, the key must be provided. | ||
* @param null $key Holds the key in which a string will be merged into the array. | ||
* @param null $key Holds the key in which a string will be merged into the array. | ||
*/ | ||
public function buildBody($values, $key = null) | ||
{ | ||
|
@@ -101,7 +95,6 @@ protected function getBody() | |
* Sets the username for auth. | ||
* | ||
* @param $username | ||
* @return void. | ||
*/ | ||
public function setUser($username) | ||
{ | ||
|
@@ -112,7 +105,6 @@ public function setUser($username) | |
* Sets the password for auth. | ||
* | ||
* @param $password | ||
* @return void | ||
*/ | ||
public function setPassword($password) | ||
{ | ||
|
@@ -129,21 +121,23 @@ protected function getAuth() | |
if (isset($this->auth['username']) && isset($this->auth['password'])) { | ||
return [$this->auth['username'], $this->auth['password']]; | ||
} | ||
return null; | ||
|
||
return; | ||
} | ||
|
||
/** | ||
* Creates and sends a POST request to the requested URL. | ||
* | ||
* @return mixed | ||
* | ||
* @throws \Exception | ||
*/ | ||
protected function postRequest() | ||
{ | ||
$response = $this->client->post($this->buildUrl(), | ||
[ | ||
'auth' => $this->getAuth(), | ||
'form_params' => $this->getBody() | ||
'form_params' => $this->getBody(), | ||
]); | ||
|
||
if ($response->getStatusCode() != 201 && $response->getStatusCode() != 200) { | ||
|
@@ -157,6 +151,7 @@ protected function postRequest() | |
* Creates and sends a GET request to the requested URL. | ||
* | ||
* @return mixed | ||
* | ||
* @throws \Exception | ||
*/ | ||
protected function getRequest() | ||
|
@@ -176,6 +171,7 @@ protected function getRequest() | |
* Creates many IncomingMessage objects. | ||
* | ||
* @param $rawMessages | ||
* | ||
* @return array | ||
*/ | ||
protected function makeMessages($rawMessages) | ||
|
@@ -192,6 +188,7 @@ protected function makeMessages($rawMessages) | |
* Creates a single IncomingMessage object. | ||
* | ||
* @param $rawMessage | ||
* | ||
* @return mixed | ||
*/ | ||
protected function makeMessage($rawMessage) | ||
|
@@ -203,6 +200,7 @@ protected function makeMessage($rawMessage) | |
* Creates many IncomingMessage objects and sets all of the properties. | ||
* | ||
* @param $rawMessage | ||
* | ||
* @return mixed | ||
*/ | ||
abstract protected function processReceive($rawMessage); | ||
|
Oops, something went wrong.