Skip to content

Commit 0db8d72

Browse files
committed
[client] implement new methods for devices, webhooks, settings and logs management
1 parent 424cfe5 commit 0db8d72

17 files changed

+1691
-29
lines changed

README.md

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,42 @@ composer require capcom6/android-sms-gateway
1717

1818
## Usage
1919

20-
Here is a simple example of how to send a message using the library:
20+
### Using the Builder Pattern
2121

22+
The library provides builder classes for creating `Message` and `Settings` objects with numerous optional fields.
23+
24+
#### Creating a Message
2225

2326
```php
2427
<?php
2528

2629
require 'vendor/autoload.php';
2730

2831
use AndroidSmsGateway\Client;
29-
use AndroidSmsGateway\Encryptor;
30-
use AndroidSmsGateway\Domain\Message;
32+
use AndroidSmsGateway\Domain\MessageBuilder;
3133

3234
$login = 'your_login';
3335
$password = 'your_password';
3436

3537
$client = new Client($login, $password);
36-
// or
37-
// $encryptor = new Encryptor('your_passphrase');
38-
// $client = new Client($login, $password, Client::DEFAULT_URL, $httpClient, $encryptor);
3938

40-
$message = new Message('Your message text here.', ['+1234567890']);
39+
$message = (new MessageBuilder('Your message text here.', ['+1234567890']))
40+
->setTtl(3600)
41+
->setSimNumber(1)
42+
->setWithDeliveryReport(true)
43+
->setPriority(100)
44+
->build();
4145

4246
try {
43-
$messageState = $client->Send($message);
47+
$messageState = $client->SendMessage($message);
4448
echo "Message sent with ID: " . $messageState->ID() . PHP_EOL;
4549
} catch (Exception $e) {
4650
echo "Error sending message: " . $e->getMessage() . PHP_EOL;
4751
die(1);
4852
}
4953

5054
try {
51-
$messageState = $client->GetState($messageState->ID());
55+
$messageState = $client->GetMessageState($messageState->ID());
5256
echo "Message state: " . $messageState->State() . PHP_EOL;
5357
} catch (Exception $e) {
5458
echo "Error getting message state: " . $e->getMessage() . PHP_EOL;
@@ -60,12 +64,35 @@ try {
6064

6165
The `Client` is used for sending SMS messages in plain text, but can also be used for sending encrypted messages by providing an `Encryptor`.
6266

63-
### Methods
67+
### Message Methods
68+
69+
* `Send(Message $message)` (deprecated): Send a new SMS message.
70+
* `SendMessage(Message $message)`: Send a new SMS message.
71+
* `GetState(string $id)` (deprecated): Retrieve the state of a previously sent message by its ID.
72+
* `GetMessageState(string $id)`: Retrieve the state of a previously sent message by its ID.
73+
74+
### Device Methods
75+
76+
* `ListDevices()`: List all registered devices.
77+
* `RemoveDevice(string $id)`: Remove a device by ID.
78+
79+
### System Methods
80+
81+
* `HealthCheck()`: Check system health.
82+
* `RequestInboxExport(object $request)`: Request inbox messages export.
83+
* `GetLogs(?string $from = null, ?string $to = null)`: Get logs within a specified time range.
84+
85+
### Settings Methods
86+
87+
* `GetSettings()`: Get user settings.
88+
* `UpdateSettings(object $settings)`: Update user settings.
89+
* `PatchSettings(object $settings)`: Partially update user settings.
6490

65-
The `Client` class has the following methods:
91+
### Webhook Methods
6692

67-
* `Send(Message $message)`: Send a new SMS message.
68-
* `GetState(string $id)`: Retrieve the state of a previously sent message by its ID.
93+
* `ListWebhooks()`: List all registered webhooks.
94+
* `RegisterWebhook(object $webhook)`: Register a new webhook.
95+
* `DeleteWebhook(string $id)`: Delete a webhook by ID.
6996

7097
# Contributing
7198

0 commit comments

Comments
 (0)