Skip to content

Commit

Permalink
feat(SMS): add SMS API Service
Browse files Browse the repository at this point in the history
refactor Token Authentication
add examples
  • Loading branch information
enigma972 committed Nov 15, 2021
1 parent 102b56e commit 2b2d8b1
Show file tree
Hide file tree
Showing 17 changed files with 939 additions and 87 deletions.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
# Orange API Client (SDK)
Orange APIs Client with Token Caching

## Installation

You need to have composer installed in your computer before doing this

```bash
composer require informagenie/orange-sms
```

## Quick setup

Get `client_id` and `client_secret` [here](https://developer.orange.com/myapps/) or [follow guide](https://informagenie.com/3141/envoyer-sms-orange-sms-api/)

```php
<?php
require_once __DIR__.'/vendor/autoload.php';

use Informagenie\OrangeSDK;

$credentials = [
'client_id' => 'your_client_id',
'client_secret' => 'your_client_secret'
];

/*
You can use directly authorization header instead of client_id and client_secret
$credentials = [
'authorization_header' => 'Basic xxx...',
];
*/

$sms = new OrangeSDK($credentials);

$response = $sms->message('Hello world !')
->from(243820000000) // Sender phone's number
->as('Informagenie') // Sender's name (optional)
->to(2439000000000) // Recipiant phone's number
->send();

```
If all is ok, $response should be like this :

```
stdClass Object
(
[outboundSMSMessageRequest] => stdClass Object
(
[address] => Array
(
[0] => tel:+243900000000
)
[senderAddress] => tel:+243820000000
[senderName] => Informagenie
[outboundSMSTextMessage] => stdClass Object
(
[message] => Hello World
)
[resourceURL] => https://api.orange.com/smsmessaging/v1/outbound/tel:+243820000000/requests/9d523078-1d3d-4c90-8984-7216e18deb97
)
)
```
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"psr-4": {
"OrangeApiClient\\": "src/"
}
},
"require-dev": {
"symfony/var-dumper": "^5.3"
}
}
173 changes: 171 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions examples/Sms/getContracts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require_once './../../vendor/autoload.php';

use OrangeApiClient\Service\Sms\Sms;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use OrangeApiClient\Client;

$cache = new FilesystemAdapter();
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');

$sms = new Sms($client);

$response = $sms->getContracts([
'contry' => 'CONTRY-CODE',
]);

dd($response->toArray());
17 changes: 17 additions & 0 deletions examples/Sms/getPurchaseOrders.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require_once './../../vendor/autoload.php';

use OrangeApiClient\Service\Sms\Sms;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use OrangeApiClient\Client;

$cache = new FilesystemAdapter();
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');

$sms = new Sms($client);

$response = $sms->getPurchaseOrders([
'contry' => 'CONTRY-CODE',
]);

dd($response->toArray());
18 changes: 18 additions & 0 deletions examples/Sms/getStatistics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
require_once './../../vendor/autoload.php';

use OrangeApiClient\Service\Sms\Sms;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use OrangeApiClient\Client;

$cache = new FilesystemAdapter();
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');

$sms = new Sms($client);

$response = $sms->getStatistics([
'contry' => 'CONTRY-CODE',
'appid' => 'APP-ID',
]);

dd($response->toArray());
12 changes: 12 additions & 0 deletions examples/Sms/getToken.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
require_once './../../vendor/autoload.php';

use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use OrangeApiClient\Client;

$cache = new FilesystemAdapter();
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');

$token = $client->getAccessToken();

dd($token);
24 changes: 24 additions & 0 deletions examples/Sms/sendSms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
require_once './../../vendor/autoload.php';

use OrangeApiClient\Service\Sms\Sms;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use OrangeApiClient\Client;
use OrangeApiClient\Service\Sms\Message;

$cache = new FilesystemAdapter();
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');

$sms = new Sms($client);

$message = new Message();
$message
->content('Hello world, via Orange SMS API.')
->from(243899999999)
// ->as('Lussi')
->to(243899999999)
;

$response = $sms->doSend($message);

dd($response->toArray());
Loading

0 comments on commit 2b2d8b1

Please sign in to comment.