-
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
pk
committed
Oct 18, 2024
0 parents
commit 7b95749
Showing
16 changed files
with
497 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
APP_ENV=development |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
vendor | ||
.env | ||
composer.lock | ||
/.phpunit.result.cache |
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Orange SmartSMS API Client | ||
|
||
A PHP client to interact with the Orange SmartSMS API. This package allows you to send SMS messages, check their delivery status, and monitor API usage limits. | ||
|
||
## Features | ||
|
||
- Send SMS messages to various networks. | ||
- Check the delivery status of previously sent SMS messages. | ||
- Retrieve the usage limit and available requests for the SmartSMS API. | ||
|
||
## Installation | ||
|
||
1. Install via Composer: | ||
|
||
```bash | ||
composer require kwarcek/orange-smartsms-api | ||
``` | ||
|
||
## Usage | ||
|
||
### 1. Send an SMS Message | ||
|
||
You can send an SMS message by using the `sendSMS` method. The message will be delivered to the recipient's mobile phone. | ||
#### Example: | ||
```php | ||
use Kwarcek\OrangeSmartsmsApi\Requests\MessagingRequest; | ||
use Kwarcek\OrangeSmartsmsApi\DTO\SMSMessage; | ||
use GuzzleHttp\Client; | ||
$isDev = getenv('APP_ENV'); | ||
// Create a new Guzzle client and MessagingRequest instance | ||
$client = new Client([ | ||
'base_uri' => $isDev ? 'https://apib2b-test.orange.pl/' : 'https://apib2b.orange.pl/', | ||
]); | ||
$apiKey = 'your-api-key-here'; | ||
$messagingRequest = new MessagingRequest($client, $apiKey); | ||
// Define the SMS message | ||
$message = new SMSMessage([ | ||
'sender' => 'YourSenderID', | ||
'recipient' => '48510123456', // Recipient's phone number | ||
'content' => 'Hello from Orange SmartSMS!', | ||
]); | ||
|
||
// Send the SMS | ||
$response = $messagingRequest->sendSMS($message, true); | ||
|
||
print_r($response); | ||
``` | ||
|
||
### 2. Check SMS Delivery Status | ||
|
||
You can check the delivery status of a sent SMS by passing the unique ID returned in the sendSMS response. | ||
Example: | ||
|
||
```php | ||
use Kwarcek\OrangeSmartsmsApi\Requests\MessagingRequest; | ||
use GuzzleHttp\Client; | ||
|
||
$isDev = getenv('APP_ENV'); | ||
|
||
$client = new Client([ | ||
'base_uri' => $isDev ? 'https://apib2b-test.orange.pl/' : 'https://apib2b.orange.pl/', | ||
]); | ||
$apiKey = 'your-api-key-here'; | ||
|
||
$messagingRequest = new MessagingRequest($client, $apiKey); | ||
|
||
$id = '54510a5d0361'; // Example message ID | ||
$response = $messagingRequest->checkDeliveryStatus($id); | ||
|
||
print_r($response); | ||
``` | ||
|
||
### 3. Check API Usage Limit | ||
|
||
You can check the current API usage limit for SmartSMS, including used and available requests. | ||
Example: | ||
|
||
```php | ||
use Kwarcek\OrangeSmartsmsApi\Requests\MessagingRequest; | ||
use GuzzleHttp\Client; | ||
|
||
$isDev = getenv('APP_ENV'); | ||
|
||
$client = new Client([ | ||
'base_uri' => $isDev ? 'https://apib2b-test.orange.pl/' : 'https://apib2b.orange.pl/', | ||
]); | ||
$apiKey = 'your-api-key-here'; | ||
|
||
$messagingRequest = new MessagingRequest($client, $apiKey); | ||
|
||
$response = $messagingRequest->checkLimit(); | ||
|
||
print_r($response); | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "kwarcek/smart-sms-api", | ||
"description": "A PHP API client for Orange SmartSMS service.", | ||
"type": "library", | ||
"version": "1.0.0", | ||
"require": { | ||
"php": "^8.2", | ||
"guzzlehttp/guzzle": "^7.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Kwarcek\\OrangeSmartsmsApi\\":"src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Kwarcek\\OrangeSmartsmsApi\\Test\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "phpunit" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
php: | ||
container_name: orange-smartsms-api | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile | ||
env_file: | ||
- .env | ||
tty: true | ||
volumes: | ||
- ./:/app |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM php:8.1 | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install git -y | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y libpq-dev \ | ||
unzip \ | ||
zlib1g-dev \ | ||
zlib1g-dev \ | ||
zip \ | ||
--no-install-recommends | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
CMD /bin/bash |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<phpunit bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage cacheDirectory=".phpunit.cache/code-coverage" | ||
processUncoveredFiles="true"> | ||
</coverage> | ||
<php> | ||
<server name="APP_ENV" value="development"/> | ||
</php> | ||
</phpunit> |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Kwarcek\OrangeSmartsmsApi\DTO; | ||
|
||
class SMSMessage | ||
{ | ||
public function __construct( | ||
public string $sender, | ||
public string $recipient, | ||
public string $content | ||
) | ||
{ | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Kwarcek\OrangeSmartsmsApi\Exceptions; | ||
|
||
class BadRequestException extends Exception | ||
{ | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Kwarcek\OrangeSmartsmsApi\Exceptions; | ||
|
||
class Exception extends \Exception | ||
{ | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Kwarcek\OrangeSmartsmsApi\Exceptions; | ||
|
||
class ForbiddenException extends Exception | ||
{ | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Kwarcek\OrangeSmartsmsApi\Exceptions; | ||
|
||
class InternalServerException extends Exception | ||
{ | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Kwarcek\OrangeSmartsmsApi\Exceptions; | ||
|
||
class NotFoundException extends Exception | ||
{ | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Kwarcek\OrangeSmartsmsApi\Exceptions; | ||
|
||
class UnathorizedException extends Exception | ||
{ | ||
|
||
} |
Oops, something went wrong.