Skip to content

Commit

Permalink
Merge pull request #1 from fleetbase/dev-v5.0.1
Browse files Browse the repository at this point in the history
Dev v5.0.1
  • Loading branch information
roncodes authored Aug 15, 2024
2 parents 0349c2f + 056c7a8 commit 1f7f411
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ laravel-twilio
===============
Laravel Twilio API Integration

[![Build Status](https://img.shields.io/travis/aloha/laravel-twilio.svg?style=flat-square)](https://travis-ci.org/aloha/laravel-twilio)
[![Total Downloads](https://img.shields.io/packagist/dt/aloha/twilio.svg?style=flat-square)](https://packagist.org/packages/aloha/twilio)
[![Latest Stable Version](https://img.shields.io/packagist/v/aloha/twilio.svg?style=flat-square)](https://packagist.org/packages/aloha/twilio)
[![License](https://img.shields.io/github/license/aloha/laravel-twilio?style=flat-square)](#license)
[![Build Status](https://img.shields.io/travis/fleetbase/laravel-twilio.svg?style=flat-square)](https://travis-ci.org/fleetbase/laravel-twilio)
[![Total Downloads](https://img.shields.io/packagist/dt/fleetbase/twilio.svg?style=flat-square)](https://packagist.org/packages/fleetbase/twilio)
[![Latest Stable Version](https://img.shields.io/packagist/v/fleetbase/twilio.svg?style=flat-square)](https://packagist.org/packages/fleetbase/twilio)
[![License](https://img.shields.io/github/license/fleetbase/laravel-twilio?style=flat-square)](#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:
Expand All @@ -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;
Expand All @@ -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:
Expand Down Expand Up @@ -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.

Expand All @@ -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.
Expand Down
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
},
{
"name": "Travis J Ryan",
"email": "[email protected]"
Expand All @@ -13,7 +18,7 @@
"email": "[email protected]"
}
],
"homepage":"https://github.com/aloha/laravel-twilio",
"homepage":"https://github.com/fleetbase/laravel-twilio",
"license": "MIT",
"require": {
"php": ">=7.2.0",
Expand All @@ -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": {
Expand All @@ -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"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/TwilioCallCommand.php
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/Commands/TwilioSmsCommand.php
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Dummy.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Aloha\Twilio;
namespace Fleetbase\Twilio;

use Twilio\Exceptions\ConfigurationException;
use Twilio\Rest\Api;
Expand Down
2 changes: 1 addition & 1 deletion src/LoggingDecorator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Aloha\Twilio;
namespace Fleetbase\Twilio;

use Psr\Log\LoggerInterface;
use Twilio\Rest\Api\V2010\Account\CallInstance;
Expand Down
2 changes: 1 addition & 1 deletion src/Manager.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Aloha\Twilio;
namespace Fleetbase\Twilio;

use InvalidArgumentException;
use Twilio\Rest\Api\V2010\Account\CallInstance;
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Laravel/Facade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Aloha\Twilio\Support\Laravel;
namespace Fleetbase\Twilio\Support\Laravel;

use Illuminate\Support\Facades\Facade as BaseFacade;

Expand Down
10 changes: 5 additions & 5 deletions src/Support/Laravel/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
10 changes: 5 additions & 5 deletions src/Twilio.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Aloha\Twilio;
namespace Fleetbase\Twilio;

use Twilio\Exceptions\ConfigurationException;
use Twilio\Exceptions\TwilioException;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/TwilioInterface.php
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/TwilioCallCommandTest.php
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/TwilioSmsCommandTest.php
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1f7f411

Please sign in to comment.