Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'refs/remotes/origin/master' into pr/13
# Conflicts:
#	README.md
#	src/config/sms.php
  • Loading branch information
Corey McCormick committed Nov 12, 2015
2 parents c78a28c + f17e5e1 commit 090f880
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 107 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
/vendor
composer.phar
composer.lock
.DS_Store
.DS_Store
.idea
21 changes: 20 additions & 1 deletion README.md
Expand Up @@ -14,6 +14,7 @@ Simple SMS
* [EZTexting Driver](#docs-ez-texting-driver)
* [Email Driver](#docs-e-mail-driver)
* [Mozeo Driver](#docs-mozeo-driver)
* [Nexmo Driver](#docs-nexmo-driver)
* [Twilio Driver](#docs-twilio-driver)
* [LabsMobile Driver](#docs-labsmobile-driver)
* [Driver Support](#docs-driver-support)
Expand All @@ -23,7 +24,7 @@ Simple SMS

<a id="docs-introduction"></a>
## Introduction
Simple SMS is an easy to use package for [Laravel](http://laravel.com/) that adds the capability to send and receive SMS/MMS messages to mobile phones from your web app. It currently supports a free way to send SMS messages through E-Mail gateways provided by the wireless carriers. The package also supports 5 paid services, [Call Fire,](https://www.callfire.com/) [EZTexting,](https://www.eztexting.com) [Mozeo,](https://www.mozeo.com/) [Twilio,](https://www.twilio.com) and [LabsMobile.](http://www.labsmobile.com)
Simple SMS is an easy to use package for [Laravel](http://laravel.com/) that adds the capability to send and receive SMS/MMS messages to mobile phones from your web app. It currently supports a free way to send SMS messages through E-Mail gateways provided by the wireless carriers. The package also supports 4 paid services, [Call Fire,](https://www.callfire.com/) [EZTexting,](https://www.eztexting.com) [LabsMobile,](http://www.labsmobile.com) [Mozeo,](https://www.mozeo.com/)[Nexmo,](https://www.nexmo.com/) and [Twilio.](https://www.twilio.com)

<a id="docs-requirements"></a>
## Requirements
Expand Down Expand Up @@ -203,6 +204,22 @@ This driver sends all messages through the [Mozeo](https://www.mozeo.com/) servi

>Note: All messages from Mozeo come from the same short number (24587)
<a id="docs-nexmo-driver"></a>
###### Nexmo Driver

This driver sends messages through the [Nexmo](https://www.nexmo.com/product/messaging/) messaging service. It is very reliable and capable of sending messages to mobile phones worldwide.

return [
'driver' => 'nexmo',
'from' => 'Company Name',
'nexmo' => [
'key' => 'Your Nexmo API Key',
'secret' => 'Your Nexmo API Secret'
]
];

To enable `receive()` messages you must set up the [request URL.](https://docs.nexmo.com/index.php/sms-api/handle-inbound-message)

<a id="docs-twilio-driver"></a>
###### Twilio Driver

Expand Down Expand Up @@ -249,6 +266,7 @@ Not all drivers support every method due to the differences in each individual A
| EZTexting | Yes | Yes | Yes | Yes | Yes | Yes |
| E-Mail | Yes | Yes | Yes | No | No | No |
| Mozeo | Yes | Yes | Yes | No | No | No |
| Nexmo | Yes | Yes | Yes | Yes | Yes | Yes |
| Twilio | Yes | Yes | Yes | Yes | Yes | Yes |
| LabsMobile | Yes | Yes | Yes | No | No | No |

Expand Down Expand Up @@ -376,6 +394,7 @@ More information about each service provider can be found at their API docs.
* [Call Fire](https://www.callfire.com/api-documentation/rest/version/1.1#!/text/QueryTexts_get_1)
* [EZTexting](https://www.eztexting.com/developers/sms-api-documentation/rest)
* [Mozeo](https://www.mozeo.com/mozeo/customer/Mozeo_API_OutboundSMS.pdf)
* [Nexmo](https://docs.nexmo.com/index.php/developer-api/search-message)
* [Twilio](https://www.twilio.com/docs/api/rest/message#list-get)
* [LabsMobile](http://www.labsmobile.com/en/api-sms)

Expand Down
15 changes: 15 additions & 0 deletions src/SimpleSoftwareIO/SMS/DriverManager.php
Expand Up @@ -14,6 +14,7 @@
use SimpleSoftwareIO\SMS\Drivers\CallFireSMS;
use SimpleSoftwareIO\SMS\Drivers\EZTextingSMS;
use SimpleSoftwareIO\SMS\Drivers\MozeoSMS;
use SimpleSoftwareIO\SMS\Drivers\NexmoSMS;
use SimpleSoftwareIO\SMS\Drivers\TwilioSMS;

class DriverManager extends Manager
Expand Down Expand Up @@ -93,6 +94,20 @@ protected function createMozeoDriver()
return $provider;
}

/**
* Create an instance of the nexmo driver
*
* @return MozeoSMS
*/
protected function createNexmoDriver()
{
$config = $this->app['config']->get('sms.nexmo', []);

$provider = new NexmoSMS(new Client, $config['key'], $config['secret']);

return $provider;
}

/**
* Get the default sms driver name.
*
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSoftwareIO/SMS/Drivers/AbstractSMS.php
Expand Up @@ -75,7 +75,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 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.
*/
public function buildBody($values, $key = null)
Expand Down
12 changes: 6 additions & 6 deletions src/SimpleSoftwareIO/SMS/Drivers/CallFireSMS.php
Expand Up @@ -41,7 +41,7 @@ public function __construct(Client $client)
/**
* Sends a SMS message.
*
* @param OutgoingMessage $message The SMS message instance.
* @param \SimpleSoftwareIO\SMS\OutgoingMessage $message
* @return void
*/
public function send(OutgoingMessage $message)
Expand Down Expand Up @@ -86,7 +86,7 @@ protected function processReceive($rawMessage)
* @param array $options
* @return array
*/
public function checkMessages(Array $options = array())
public function checkMessages(array $options = [])
{
$this->buildCall('/text');

Expand All @@ -98,8 +98,8 @@ public function checkMessages(Array $options = array())
/**
* Gets a single message by it's ID.
*
* @param $messageId
* @return IncomingMessage
* @param string|int $messageId
* @return \SimpleSoftwareIO\SMS\IncomingMessage
*/
public function getMessage($messageId)
{
Expand All @@ -111,8 +111,8 @@ public function getMessage($messageId)
/**
* Receives an incoming message via REST call.
*
* @param $raw
* @return \SimpleSoftwareIO\SMS\IncomingMessage|void
* @param mixed $raw
* @return \SimpleSoftwareIO\SMS\IncomingMessage
* @throws \RuntimeException
*/
public function receive($raw)
Expand Down
12 changes: 6 additions & 6 deletions src/SimpleSoftwareIO/SMS/Drivers/DriverInterface.php
Expand Up @@ -15,9 +15,9 @@
interface DriverInterface
{
/**
* Sends a SMS message
* Sends a SMS message.
*
* @parma SimpleSoftwareIO\SMS\Message @messasge The message class.
* @param \SimpleSoftwareIO\SMS\OutgoingMessage $message
* @return void
*/
public function send(OutgoingMessage $message);
Expand All @@ -28,20 +28,20 @@ public function send(OutgoingMessage $message);
* @param array $options
* @return array
*/
public function checkMessages(Array $options = array());
public function checkMessages(array $options = []);

/**
* Gets a single message by it's ID.
*
* @param $messageId
* @return IncomingMessage
* @param string|int $messageId
* @return \SimpleSoftwareIO\SMS\IncomingMessage
*/
public function getMessage($messageId);

/**
* Receives an incoming message via REST call.
*
* @param $raw
* @param mixed $raw
* @return \SimpleSoftwareIO\SMS\IncomingMessage
*/
public function receive($raw);
Expand Down
11 changes: 6 additions & 5 deletions src/SimpleSoftwareIO/SMS/Drivers/EZTextingSMS.php
Expand Up @@ -9,6 +9,7 @@
*
*/

use SimpleSoftwareIO\SMS\IncomingMessage;
use SimpleSoftwareIO\SMS\OutgoingMessage;
use GuzzleHttp\Client;

Expand Down Expand Up @@ -48,7 +49,7 @@ public function __construct(Client $client)
/**
* Sends a SMS message.
*
* @param OutgoingMessage $message
* @param \SimpleSoftwareIO\SMS\OutgoingMessage $message
* @return void
*/
public function send(OutgoingMessage $message)
Expand All @@ -72,7 +73,7 @@ public function send(OutgoingMessage $message)
* @param array $options
* @return array
*/
public function checkMessages(Array $options = array())
public function checkMessages(array $options = [])
{
$this->buildCall('/incoming-messages');
$this->buildBody($options);
Expand All @@ -84,8 +85,8 @@ public function checkMessages(Array $options = array())
/**
* Gets a single message by it's ID.
*
* @param $messageId
* @return IncomingMessage
* @param string|int $messageId
* @return \SimpleSoftwareIO\SMS\IncomingMessage
*/
public function getMessage($messageId)
{
Expand Down Expand Up @@ -118,7 +119,7 @@ protected function processReceive($rawMessage)
/**
* Receives an incoming message via REST call.
*
* @param $raw
* @param mixed $raw
* @return \SimpleSoftwareIO\SMS\IncomingMessage
*/
public function receive($raw)
Expand Down
44 changes: 32 additions & 12 deletions src/SimpleSoftwareIO/SMS/Drivers/EmailSMS.php
Expand Up @@ -17,14 +17,14 @@ class EmailSMS implements DriverInterface
/**
* The Message Instance
*
* @var SimpleSoftwareIO\SMS\Message
* @var \SimpleSoftwareIO\SMS\OutgoingMessage
*/
protected $outgoingMessage;

/**
* Creates the EmailSMS Instance.
*
* @parma Illuminate\Mail\Mailer $mailer Illuminate Mailer
* @param \Illuminate\Mail\Mailer $mailer Illuminate Mailer
* @return void
*/
public function __construct(Mailer $mailer)
Expand All @@ -33,9 +33,9 @@ public function __construct(Mailer $mailer)
}

/**
* Sends a SMS message
* Sends a SMS message.
*
* @parma SimpleSoftwareIO\SMS\Message @messasge The message class.
* @param \SimpleSoftwareIO\SMS\OutgoingMessage $message
* @return void
*/
public function send(OutgoingMessage $message)
Expand All @@ -61,7 +61,7 @@ public function send(OutgoingMessage $message)
/**
* Builds the email address of a number.
*
* @parma array $number The number and carrier to look up.
* @param array $number The number and carrier to look up.
* @return string
*/
protected function buildEmail($number)
Expand All @@ -76,8 +76,8 @@ protected function buildEmail($number)
/**
* Finds the gateway based on the carrier and MMS.
*
* @parm string $carrier The desired carrier to look up.
* @parma boolean $mms If the Message is an MMS.
* @param string $carrier The desired carrier to look up.
* @param boolean $mms If the Message is an MMS.
* @return string
*/
protected function lookupGateway($carrier, $mms)
Expand All @@ -88,13 +88,13 @@ protected function lookupGateway($carrier, $mms)
return 'mms.att.net';

case 'airfiremobile':
throw new InvalidArgumentException('Air Fire Mobile does not support Email Gateway MMS messages.');
throw new \InvalidArgumentException('Air Fire Mobile does not support Email Gateway MMS messages.');

case 'alaskacommunicates':
return 'msg.acsalaska.com';

case 'ameritech':
throw new InvalidArgumentException('Ameritech does not support Email Gateway MMS messages.');
throw new \InvalidArgumentException('Ameritech does not support Email Gateway MMS messages.');

case 'assurancewireless':
return 'vmobl.com';
Expand All @@ -103,7 +103,7 @@ protected function lookupGateway($carrier, $mms)
return 'myboostmobile.com';

case 'cleartalk':
throw new InvalidArgumentException('Clear Talk does not support Email Gateway MMS messages.');
throw new \InvalidArgumentException('Clear Talk does not support Email Gateway MMS messages.');

case 'cricket':
return 'mms.mycricket.com ';
Expand All @@ -112,7 +112,7 @@ protected function lookupGateway($carrier, $mms)
return 'mymetropcs.com';

case 'nextech':
throw new InvalidArgumentException('NexTech does not support Email Gateway MMS messages.');
throw new \InvalidArgumentException('NexTech does not support Email Gateway MMS messages.');

case 'rogerswireless':
return 'mms.rogers.com';
Expand Down Expand Up @@ -185,16 +185,36 @@ protected function lookupGateway($carrier, $mms)
}
}

public function checkMessages(Array $options = array())
/**
* Checks the server for messages and returns their results.
*
* @param array $options
* @return array
*/
public function checkMessages(array $options = [])
{
throw new \RuntimeException('Receive methods are not support with the E-Mail driver.');
}

/**
* Gets a single message by it's ID.
*
* @param string|int $messageId
* @return \SimpleSoftwareIO\SMS\IncomingMessage
* @throws \RuntimeException
*/
public function getMessage($messageId)
{
throw new \RuntimeException('Receive methods are not support with the E-Mail driver.');
}

/**
* Receives an incoming message via REST call.
*
* @param mixed $raw
* @return \SimpleSoftwareIO\SMS\IncomingMessage
* @throws \RuntimeException
*/
public function receive($raw)
{
throw new \RuntimeException('Receive methods are not support with the E-Mail driver.');
Expand Down
14 changes: 9 additions & 5 deletions src/SimpleSoftwareIO/SMS/Drivers/MozeoSMS.php
Expand Up @@ -42,7 +42,7 @@ public function __construct(Client $client)
/**
* Sends a SMS message.
*
* @param OutgoingMessage $message The SMS message instance.
* @param \SimpleSoftwareIO\SMS\OutgoingMessage $message
* @return void
*/
public function send(OutgoingMessage $message)
Expand Down Expand Up @@ -74,17 +74,21 @@ protected function processReceive($rawMessage)
/**
* Checks the server for messages and returns their results.
*
* @param array $options
* @return array
* @throws \RuntimeException
*/
public function checkMessages(Array $options = array())
public function checkMessages(array $options = [])
{
throw new \RuntimeException('Mozeo does not support Inbound API Calls.');
}

/**
* Gets a single message by it's ID.
*
* @throws \RuntimeException
* @param string|int $messageId
* @return \SimpleSoftwareIO\SMS\IncomingMessage
* @throws \RangeException
*/
public function getMessage($messageId)
{
Expand All @@ -94,8 +98,8 @@ public function getMessage($messageId)
/**
* Receives an incoming message via REST call.
*
* @param $raw
* @return IncomingMessage|void
* @param mixed $raw
* @return \SimpleSoftwareIO\SMS\IncomingMessage
* @throws \RuntimeException
*/
public function receive($raw)
Expand Down

0 comments on commit 090f880

Please sign in to comment.