mirror of
https://github.com/fleetbase/fleetbase.git
synced 2025-12-19 22:27:22 +00:00
takeover and minor fix, allow nullable values for twilio constructor instead of having a system breaking exception when running the system provider
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
We accept contributions via Pull Requests on [Github](https://github.com/aloha/laravel-twilio).
|
||||
We accept contributions via Pull Requests on [Github](https://github.com/fleetbase/laravel-twilio).
|
||||
|
||||
## Pull Requests
|
||||
|
||||
|
||||
32
README.md
32
README.md
@@ -2,17 +2,17 @@ laravel-twilio
|
||||
===============
|
||||
Laravel Twilio API Integration
|
||||
|
||||
[](https://travis-ci.org/aloha/laravel-twilio)
|
||||
[](https://packagist.org/packages/aloha/twilio)
|
||||
[](https://packagist.org/packages/aloha/twilio)
|
||||
[](#license)
|
||||
[](https://travis-ci.org/fleetbase/laravel-twilio)
|
||||
[](https://packagist.org/packages/fleetbase/twilio)
|
||||
[](https://packagist.org/packages/fleetbase/twilio)
|
||||
[](#license)
|
||||
|
||||
## Installation
|
||||
|
||||
Begin by installing this package through Composer. Run this command from the Terminal:
|
||||
|
||||
```bash
|
||||
composer require aloha/twilio
|
||||
composer require fleetbase/twilio
|
||||
```
|
||||
|
||||
This will register two new artisan commands for you:
|
||||
@@ -22,25 +22,25 @@ This will register two new artisan commands for you:
|
||||
|
||||
And make these objects resolvable from the IoC container:
|
||||
|
||||
- `Aloha\Twilio\Manager` (aliased as `twilio`)
|
||||
- `Aloha\Twilio\TwilioInterface` (resolves a `Twilio` object, the default connection object created by the `Manager`).
|
||||
- `Fleetbase\Twilio\Manager` (aliased as `twilio`)
|
||||
- `Fleetbase\Twilio\TwilioInterface` (resolves a `Twilio` object, the default connection object created by the `Manager`).
|
||||
|
||||
There's a Facade class available for you, if you like. In your `app.php` config file add the following
|
||||
line to the `aliases` array if you want to use a short class name:
|
||||
|
||||
```php
|
||||
'Twilio' => 'Aloha\Twilio\Support\Laravel\Facade',
|
||||
'Twilio' => 'Fleetbase\Twilio\Support\Laravel\Facade',
|
||||
```
|
||||
|
||||
You can publish the default config file to `config/twilio.php` with the terminal command
|
||||
|
||||
```shell
|
||||
php artisan vendor:publish --provider="Aloha\Twilio\Support\Laravel\ServiceProvider"
|
||||
php artisan vendor:publish --provider="Fleetbase\Twilio\Support\Laravel\ServiceProvider"
|
||||
```
|
||||
|
||||
#### Facade
|
||||
|
||||
The facade has the exact same methods as the `Aloha\Twilio\TwilioInterface`. First, include the `Facade` class at the top of your file:
|
||||
The facade has the exact same methods as the `Fleetbase\Twilio\TwilioInterface`. First, include the `Facade` class at the top of your file:
|
||||
|
||||
```php
|
||||
use Twilio;
|
||||
@@ -63,10 +63,10 @@ Define multiple entries in your `twilio` [config file](src/config/config.php) to
|
||||
|
||||
### Usage
|
||||
|
||||
Creating a Twilio object. This object implements the `Aloha\Twilio\TwilioInterface`.
|
||||
Creating a Twilio object. This object implements the `Fleetbase\Twilio\TwilioInterface`.
|
||||
|
||||
```php
|
||||
$twilio = new Aloha\Twilio\Twilio($accountId, $token, $fromNumber);
|
||||
$twilio = new Fleetbase\Twilio\Twilio($accountId, $token, $fromNumber);
|
||||
```
|
||||
|
||||
Sending a text message:
|
||||
@@ -131,12 +131,12 @@ $twilio->call($to, $message, $params);
|
||||
|
||||
#### Dummy class
|
||||
|
||||
There is a dummy implementation of the `TwilioInterface` available: `Aloha\Twilio\Dummy`. This class
|
||||
There is a dummy implementation of the `TwilioInterface` available: `Fleetbase\Twilio\Dummy`. This class
|
||||
allows you to inject this instead of a working implementation in case you need to run quick integration tests.
|
||||
|
||||
#### Logging decorator
|
||||
|
||||
There is one more class available for you: the `Aloha\Twilio\LoggingDecorator`. This class wraps any
|
||||
There is one more class available for you: the `Fleetbase\Twilio\LoggingDecorator`. This class wraps any
|
||||
`TwilioInterface` object and logs whatever Twilio will do for you. It also takes a `Psr\Log\LoggerInterface` object
|
||||
(like Monolog) for logging, you know.
|
||||
|
||||
@@ -146,10 +146,10 @@ but it is at your disposal in case you want it. A possible use case is to constr
|
||||
|
||||
```php
|
||||
if (getenv('APP_ENV') === 'production') {
|
||||
$twilio = $container->make(\Aloha\Twilio\Manager::class);
|
||||
$twilio = $container->make(\Fleetbase\Twilio\Manager::class);
|
||||
} else {
|
||||
$psrLogger = $container->make(\Psr\Log\LoggerInterface::class);
|
||||
$twilio = new LoggingDecorator($psrLogger, new \Aloha\Twilio\Dummy());
|
||||
$twilio = new LoggingDecorator($psrLogger, new \Fleetbase\Twilio\Dummy());
|
||||
}
|
||||
|
||||
// Inject it wherever you want.
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
{
|
||||
"name": "aloha/twilio",
|
||||
"name": "fleetbase/twilio",
|
||||
"description": "Twilio API for Laravel",
|
||||
"version": "5.0.1",
|
||||
"type": "library",
|
||||
"keywords": ["sms", "ivr", "laravel", "twilio"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ronald A Richardson",
|
||||
"email": "ron@fleetbase.io"
|
||||
},
|
||||
{
|
||||
"name": "Travis J Ryan",
|
||||
"email": "travisjryan@gmail.com"
|
||||
@@ -13,7 +18,7 @@
|
||||
"email": "vandevreken.hannes@gmail.com"
|
||||
}
|
||||
],
|
||||
"homepage":"https://github.com/aloha/laravel-twilio",
|
||||
"homepage":"https://github.com/fleetbase/laravel-twilio",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=7.2.0",
|
||||
@@ -27,12 +32,12 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Aloha\\Twilio\\": "src/"
|
||||
"Fleetbase\\Twilio\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Aloha\\Twilio\\Tests\\": "tests/"
|
||||
"Fleetbase\\Twilio\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@@ -51,10 +56,10 @@
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Aloha\\Twilio\\Support\\Laravel\\ServiceProvider"
|
||||
"Fleetbase\\Twilio\\Support\\Laravel\\ServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Twilio": "Aloha\\Twilio\\Support\\Laravel\\Facade"
|
||||
"Twilio": "Fleetbase\\Twilio\\Support\\Laravel\\Facade"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio\Commands;
|
||||
namespace Fleetbase\Twilio\Commands;
|
||||
|
||||
use Aloha\Twilio\TwilioInterface;
|
||||
use Fleetbase\Twilio\TwilioInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio\Commands;
|
||||
namespace Fleetbase\Twilio\Commands;
|
||||
|
||||
use Aloha\Twilio\TwilioInterface;
|
||||
use Fleetbase\Twilio\TwilioInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@@ -24,14 +24,14 @@ class TwilioSmsCommand extends Command
|
||||
protected $description = 'Twilio command to test Twilio SMS API Integration.';
|
||||
|
||||
/**
|
||||
* @var \Aloha\Twilio\TwilioInterface
|
||||
* @var \Fleetbase\Twilio\TwilioInterface
|
||||
*/
|
||||
protected $twilio;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @param \Aloha\Twilio\TwilioInterface $twilio
|
||||
* @param \Fleetbase\Twilio\TwilioInterface $twilio
|
||||
*/
|
||||
public function __construct(TwilioInterface $twilio)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio;
|
||||
namespace Fleetbase\Twilio;
|
||||
|
||||
use Twilio\Exceptions\ConfigurationException;
|
||||
use Twilio\Rest\Api;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio;
|
||||
namespace Fleetbase\Twilio;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Twilio\Rest\Api\V2010\Account\CallInstance;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio;
|
||||
namespace Fleetbase\Twilio;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Twilio\Rest\Api\V2010\Account\CallInstance;
|
||||
@@ -51,7 +51,7 @@ class Manager implements TwilioInterface
|
||||
throw new InvalidArgumentException("Connection \"{$connection}\" is not configured.");
|
||||
}
|
||||
|
||||
$settings = $this->settings[$connection];
|
||||
$settings = $this->settings[$connection] ?? ['sid' => '', 'token' => '', 'from' => ''];
|
||||
|
||||
return new Twilio($settings['sid'], $settings['token'], $settings['from']);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio\Support\Laravel;
|
||||
namespace Fleetbase\Twilio\Support\Laravel;
|
||||
|
||||
use Illuminate\Support\Facades\Facade as BaseFacade;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio\Support\Laravel;
|
||||
namespace Fleetbase\Twilio\Support\Laravel;
|
||||
|
||||
use Aloha\Twilio\Commands\TwilioCallCommand;
|
||||
use Aloha\Twilio\Commands\TwilioSmsCommand;
|
||||
use Aloha\Twilio\Manager;
|
||||
use Aloha\Twilio\TwilioInterface;
|
||||
use Fleetbase\Twilio\Commands\TwilioCallCommand;
|
||||
use Fleetbase\Twilio\Commands\TwilioSmsCommand;
|
||||
use Fleetbase\Twilio\Manager;
|
||||
use Fleetbase\Twilio\TwilioInterface;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio;
|
||||
namespace Fleetbase\Twilio;
|
||||
|
||||
use Twilio\Exceptions\ConfigurationException;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
@@ -38,12 +38,12 @@ class Twilio implements TwilioInterface
|
||||
protected $twilio;
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
* @param string $from
|
||||
* @param string $sid
|
||||
* @param string|null $token
|
||||
* @param string|null $from
|
||||
* @param string|null $sid
|
||||
* @param bool $sslVerify
|
||||
*/
|
||||
public function __construct(string $sid, string $token, string $from, bool $sslVerify = true)
|
||||
public function __construct(?string $sid = null, ?string $token = null, ?string $from = null, bool $sslVerify = true)
|
||||
{
|
||||
$this->sid = $sid;
|
||||
$this->token = $token;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio;
|
||||
namespace Fleetbase\Twilio;
|
||||
|
||||
use Twilio\Rest\Api\V2010\Account\CallInstance;
|
||||
use Twilio\Rest\Api\V2010\Account\MessageInstance;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio\Tests;
|
||||
namespace Fleetbase\Twilio\Tests;
|
||||
|
||||
use Aloha\Twilio\Commands\TwilioCallCommand;
|
||||
use Fleetbase\Twilio\Commands\TwilioCallCommand;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TwilioCallCommandTest extends TestCase
|
||||
@@ -13,7 +13,7 @@ class TwilioCallCommandTest extends TestCase
|
||||
public function testName()
|
||||
{
|
||||
// Arrange
|
||||
$stub = $this->createMock('Aloha\Twilio\TwilioInterface');
|
||||
$stub = $this->createMock('Fleetbase\Twilio\TwilioInterface');
|
||||
$command = new TwilioCallCommand($stub);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Aloha\Twilio\Tests;
|
||||
namespace Fleetbase\Twilio\Tests;
|
||||
|
||||
use Aloha\Twilio\Commands\TwilioSmsCommand;
|
||||
use Fleetbase\Twilio\Commands\TwilioSmsCommand;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TwilioSmsCommandTest extends TestCase
|
||||
@@ -13,7 +13,7 @@ class TwilioSmsCommandTest extends TestCase
|
||||
public function testName()
|
||||
{
|
||||
// Arrange
|
||||
$stub = $this->createMock('Aloha\Twilio\TwilioInterface');
|
||||
$stub = $this->createMock('Fleetbase\Twilio\TwilioInterface');
|
||||
$command = new TwilioSmsCommand($stub);
|
||||
|
||||
// Act
|
||||
|
||||
Reference in New Issue
Block a user