Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Bug Fixes

- **Message priority always serialized** — a message's `priority` is now always included in the JSON body (defaulting to `0` when unset), matching the wire format of the other official SDKs.

## [2.6.0] - 2026-08-19

### New Features

#### Inbox refresh and batch webhooks

- **`RefreshInbox` with `InboxRefreshRequest`** — refresh the inbox and choose how webhook events are delivered with `WebhookDelivery` (`Disabled`, `Individual`, or `Batch`). `RequestInboxExport` is deprecated in favor of it.
- **Batch webhook events** — `sms:batch:received`, `sms:batch:data-received`, `mms:batch:received`, and `mms:batch:downloaded` events with typed payload classes (`SmsBatchReceivedPayload`, `SmsBatchDataReceivedPayload`, `MmsBatchReceivedPayload`, `MmsBatchDownloadedPayload`).
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A modern PHP client for the [SMSGate](https://sms-gate.app) API: send SMS messag

## 📖 About

`capcom6/android-sms-gateway` is a type-safe PHP library for the SMSGate 3rd-party API. It covers messages (send, state, listing, cancellation), inbox refresh with attachment download, devices, webhooks, settings, logs, health checks, and the JWT token lifecycle, with a fluent `MessageBuilder` for message construction and an optional `Encryptor` for end-to-end encryption. Works with any PSR-18 HTTP client (Guzzle, curl, or others) and PHP 7.4+.
`capcom6/android-sms-gateway` is a type-safe PHP library for the SMSGate 3rd-party API. It covers messages (send, state, listing, cancellation), inbox refresh with individual or batch webhook delivery and attachment download, devices, webhooks, settings, logs, health checks, and the JWT token lifecycle, with a fluent `MessageBuilder` for message construction and an optional `Encryptor` for end-to-end encryption. Works with any PSR-18 HTTP client (Guzzle, curl, or others) and PHP 7.4+.

## 📚 Table of Contents

Expand All @@ -25,17 +25,19 @@ A modern PHP client for the [SMSGate](https://sms-gate.app) API: send SMS messag
- [JWT Authentication](#jwt-authentication)
- [🚀 Quickstart](#-quickstart)
- [💻 Usage](#-usage)
- [⚙️ Configuration](#️-configuration)
- [📖 API Reference](#-api-reference)
- [🤝 Contributing](#-contributing)
- [📄 License](#-license)

## ⭐ Features

- Fluent `MessageBuilder` for messages and `SettingsBuilder` for settings
- Messages: send, state, listing, and cancellation
- PSR-18 HTTP client and PSR-17 factories, auto-discovered
- Basic and JWT authentication with token generation and revocation
- Webhooks, devices, settings, logs, and health checks
- Inbox refresh with webhook delivery and MMS attachment download
- Inbox refresh with individual or batch webhook delivery and MMS attachment download
- Webhooks (single and batch events), devices, settings, logs, and health checks
- Optional end-to-end encryption via `Encryptor`
- Structured `HttpException` error handling

Expand Down Expand Up @@ -96,6 +98,20 @@ echo 'Message ID: ' . $state->ID() . PHP_EOL;

Beyond sending, the client covers message listing and cancellation, inbox listing and refresh, device management, health checks, logs, settings (get, patch, replace), webhooks, and token lifecycle. See [src/Client.php](https://github.com/android-sms-gateway/client-php/blob/master/src/Client.php) for the complete method list with signatures and [src/Domain](https://github.com/android-sms-gateway/client-php/tree/master/src/Domain) for the domain models.

## ⚙️ Configuration

The `Client` constructor accepts the following parameters:

| Parameter | Required | Description |
| ------------ | -------- | ------------------------------------------------------------------------- |
| `$login` | No | Account login for Basic authentication |
| `$password` | Yes | Account password (Basic) or a JWT token (Bearer) |
| `$serverUrl` | No | API base URL; defaults to `https://api.sms-gate.app/3rdparty/v1` |
| `$client` | No | PSR-18 HTTP client; auto-discovered via `php-http/discovery` when omitted |
| `$encryptor` | No | Optional `Encryptor` for end-to-end encryption |

When `$login` is set, Basic authentication is used. When only `$password` is provided, it is sent as a Bearer JWT token.

## 📖 API Reference

- [Official API Reference](https://docs.sms-gate.app/integration/api/) - endpoints, payloads, and error codes
Expand Down
4 changes: 4 additions & 0 deletions src/Domain/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public function ToObject(): object {
$obj->priority = $this->priority;
}

// Go wire parity: Message.Priority has no omitempty and always
// serializes (zero value 0).
$obj->priority = $this->priority ?? 0;

if ($this->ttl !== null) {
$obj->ttl = $this->ttl;
}
Expand Down
15 changes: 14 additions & 1 deletion tests/Domain/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function testCanSerializeToObject(): void {
$expected = (object) [
'id' => $id,
'message' => $messageText,
'priority' => 0,
'ttl' => $ttl,
'simNumber' => $simNumber,
'withDeliveryReport' => $withDeliveryReport,
Expand All @@ -52,5 +53,17 @@ public function testDefaultsWithNullParameters(): void {
$this->assertNull($serialized->simNumber);
$this->assertTrue($serialized->withDeliveryReport);
$this->assertFalse($serialized->isEncrypted);
$this->assertSame(0, $serialized->priority);
}
}

public function testLegacyTextMessageStillSerializesMessageKey(): void {
$message = new Message('Hello', ['+1234567890']);

$json = json_encode($message->ToObject(), JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);

$this->assertSame(
'{"id":null,"message":"Hello","simNumber":null,"withDeliveryReport":true,"isEncrypted":false,"phoneNumbers":["+1234567890"],"priority":0}',
$json
);
}
}
Loading