API reference
This page summarizes the public API. For implementation details and the latest release history, view the source repository.
Rayo\SmsSdk\Client
Section titled “Rayo\SmsSdk\Client”| Member | Returns | Purpose |
|---|---|---|
__construct(string $apiKey, string|array $baseUrlOrOptions, array $options = []) |
Client |
Configure credentials, base URL, and Guzzle options |
getBaseUrl() |
string |
Return the normalized URL ending in /v1/ |
sendSms(SmsRequest|array $payload) |
SmsResponse |
Send immediately or schedule |
getBalance() |
BalanceResponse |
Retrieve credits |
getBalanceInCredits() |
BalanceResponse |
Alias for getBalance() |
checkStatus(?string $serverId, ?string $clientId) |
SmsDeliveryStatusItem[] |
Query using exactly one identifier |
checkStatusByServerRequestId(string $id) |
SmsDeliveryStatusItem[] |
Query by server ID |
checkStatusByClientRequestId(string $id) |
SmsDeliveryStatusItem[] |
Query by client ID |
deleteSchedule(string $id) |
DeleteScheduleResponse |
Cancel a future message |
deleteSmsRequestSchedule(string $id) |
DeleteScheduleResponse |
Alias for deleteSchedule() |
Constants: Client::DEFAULT_TIMEOUT is 10.0; Client::API_VERSION_PREFIX is v1.
SmsRequest
Section titled “SmsRequest”Constructor:
new SmsRequest( string $fromLabel, string $smsBody, string|array|null $toMobileNumber = null, string|array|null $toGroup = null, ?string $clientRequestId = null, ?bool $callbackWhenProcessedFlag = null, ?bool $simulateSendFlag = null, ?bool $concatFlag = null, DateTimeInterface|string|null $scheduledAt = null);Factory and serialization: fromArray(), validate(), toArray(), jsonSerialize().
Getters correspond to every constructor field. SmsRequest::MAXIMUM_SMS_LENGTH is 1000.
Response models
Section titled “Response models”All response models are immutable, JSON-serializable, and provide read-only ArrayAccess to their raw response.
SmsResponse
Section titled “SmsResponse”- State:
isSuccess(),isScheduled(). - Getters:
getUsername(),getResultCode(),getResultDescription(),getClientRequestId(),getSmsServerRequestId(),getSmsRequestScheduleId(),getError().
DeleteScheduleResponse
Section titled “DeleteScheduleResponse”- State:
isSuccess(). - Getters:
getUsername(),getResultCode(),getResultDescription(),getSmsRequestScheduleId(),getError().
BalanceResponse
Section titled “BalanceResponse”- Getters:
getRequestId(),getCredits().
SmsDeliveryStatusItem
Section titled “SmsDeliveryStatusItem”- State:
isDelivered(),isFinalStatus(). - Getters:
getSmsServerRequestId(),getClientRequestId(),getInternalSmsOutDeliveryId(),getMobileNumber(),getStatus().
CallbackPayload
Section titled “CallbackPayload”- Factories:
fromArray(),fromJson(),fromQueryString(). - State:
isDelivered(),isFinalStatus(). - Getters:
getSmsServerRequestId(),getClientRequestId(),getInternalSmsOutDeliveryId(),getSenderId(),getMobileNumber(),getStatus(),getErrorDescription(),getRequestTimestamp(),getLastStatusUpdatedTimestamp().
The timestamp parser accepts the documented requestTimestamp and the server variant requestedTimestamp.
DeliveryStatus
Section titled “DeliveryStatus”Constants: NEW, TEMP_LOCKED, PROCESSING_ERROR, FAILURE, SENT, ERROR, DELIVERED, NOT_DELIVERED, and UNKNOWN_DELIVERY.
Use DeliveryStatus::all() to list every value and DeliveryStatus::isFinal($status) to test terminal status.
WebhookSignatureVerifier
Section titled “WebhookSignatureVerifier”| Method | Purpose |
|---|---|
computeSignature(...) |
Compute the expected HMAC-SHA256 digest |
verify(...) |
Return whether a raw request signature is valid |
verifyOrThrow(...) |
Throw RayoException for an invalid signature |
verifyPsr7Request(...) |
Verify a PSR-7 server request |
RayoException
Section titled “RayoException”Extends RuntimeException. In addition to inherited exception methods, it exposes getStatusCode(), getErrorPayload(), getRawResponseBody(), getErrorMessage(), getResultCode(), and getResultDescription().
