Skip to content
Closed
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ A powerful way to send personalized messages at scale and build effective custom

For more information, please visit [https://onesignal.com](https://onesignal.com).

- API version: 5.6.0
- Package version: 5.6.0
- API version: 5.7.0
- Package version: 5.7.0

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onesignal/onesignal-php-api",
"version": "5.6.0",
"version": "5.7.0",
"description": "A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com",
"keywords": [
"onesignal",
Expand Down
131 changes: 130 additions & 1 deletion docs/Api/DefaultApi.md

Large diffs are not rendered by default.

69 changes: 68 additions & 1 deletion lib/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.0-SNAPSHOT
Expand Down Expand Up @@ -117,4 +117,71 @@ public function getResponseObject()
{
return $this->responseObject;
}

/**
* Gets the error messages carried by the response body, normalized to a
* flat string array regardless of which envelope shape the API returned
* (`{ "errors": "..." }`, `{ "errors": ["..."] }`,
* `{ "errors": [{ "code": ..., "title": ... }] }`, or an object map such as
* `{ "errors": { "invalid_aliases": {...} } }`, surfaced as `"<key>: <value>"`
* entries). Returns an empty array when the body is not a recognizable error
* envelope. The raw body remains available via getResponseBody().
*
* @return string[]
*/
public function getErrorMessages()
{
$body = $this->responseBody;
if (is_string($body)) {
$body = json_decode($body);
if ($body === null) {
return [];
}
}

$errors = null;
if (is_object($body) && isset($body->errors)) {
$errors = $body->errors;
} elseif (is_array($body) && isset($body['errors'])) {
$errors = $body['errors'];
}

if (is_string($errors)) {
return [$errors];
}
if (is_array($errors)) {
$messages = [];
foreach ($errors as $error) {
if (is_string($error)) {
$messages[] = $error;
} elseif (is_object($error)) {
if (isset($error->title) && $error->title !== '') {
$messages[] = $error->title;
} elseif (isset($error->code)) {
$messages[] = $error->code;
}
} elseif (is_array($error)) {
if (isset($error['title']) && $error['title'] !== '') {
$messages[] = $error['title'];
} elseif (isset($error['code'])) {
$messages[] = $error['code'];
}
}
}
return $messages;
}
if (is_object($errors)) {
// Object-shaped envelopes (e.g. { "invalid_aliases": {...} }) carry
// data under arbitrary keys; surface each so it isn't silently
// dropped. Key order is unspecified, so sort for deterministic output.
$messages = [];
foreach (get_object_vars($errors) as $key => $value) {
$rendered = is_string($value) ? $value : json_encode($value);
$messages[] = $key . ': ' . $rendered;
}
sort($messages);
return $messages;
}
return [];
}
}
8 changes: 4 additions & 4 deletions lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.0-SNAPSHOT
Expand Down Expand Up @@ -99,7 +99,7 @@ class Configuration
*
* @var string
*/
protected $userAgent = 'OpenAPI-Generator/5.6.0/PHP';
protected $userAgent = 'OpenAPI-Generator/5.7.0/PHP';

/**
* Debug switch (default set to false)
Expand Down Expand Up @@ -430,8 +430,8 @@ public static function toDebugReport()
$report = 'PHP SDK (onesignal\client) Debug Report:' . PHP_EOL;
$report .= ' OS: ' . php_uname() . PHP_EOL;
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
$report .= ' The version of the OpenAPI document: 5.6.0' . PHP_EOL;
$report .= ' SDK Package Version: 5.6.0' . PHP_EOL;
$report .= ' The version of the OpenAPI document: 5.7.0' . PHP_EOL;
$report .= ' SDK Package Version: 5.7.0' . PHP_EOL;
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;

return $report;
Expand Down
2 changes: 1 addition & 1 deletion lib/HeaderSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.0-SNAPSHOT
Expand Down
2 changes: 1 addition & 1 deletion lib/ObjectSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.0-SNAPSHOT
Expand Down
31 changes: 31 additions & 0 deletions lib/OneSignalErrors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* Generated from inputs/api/error-catalog.json. Do not edit by hand.
*/

namespace onesignal\client;

/**
* Sentinel error message strings the OneSignal API can return. Each
* constant equals the literal message the server emits, so you can test
* membership against ApiException::getErrorMessages() (e.g.
* NO_TARGETING_SPECIFIED).
*
* Note: 200-status sentinels such as NO_SUBSCRIBERS arrive on a successful
* response, not via the exception accessor — read the response's errors
* field for those.
*/
class OneSignalErrors
{
/** HTTP 403 | retryable: no | emitted by: any API-key-authenticated endpoint (REST or Organization key) | note: Generic auth-failure message the public api.onesignal.com edge returns for any invalid or mismatched key — REST or Organization — so a single sentinel covers both. Supersedes the Rails-monolith INVALID_REST_API_KEY / INVALID_USER_AUTH_KEY strings, which the public host no longer returns verbatim. Note the double space after 'denied.' */
const INVALID_API_KEY = 'Access denied. Please include an \'Authorization: ...\' header with a valid API key (https://documentation.onesignal.com/docs/en/keys-and-ids#api-keys).';
/** HTTP 400, 404 | retryable: no | emitted by: POST /notifications/{id}/history, POST /notifications/{id}/messages, GET /notifications/{id} (export) | note: Verified live 2026-06-16: GET /notifications/{bogus-uuid} returns 404 with this exact message. */
const NOTIFICATION_NOT_FOUND = 'Notification not found';
/** HTTP 200 | retryable: no | emitted by: POST /notifications | note: Returned with HTTP 200 OK (id is empty), not an error status. The flagship case for the errorMessages accessor — lets callers distinguish a sent notification from a no-op without parsing the polymorphic 200 body. */
const NO_SUBSCRIBERS = 'All included players are not subscribed';
/** HTTP 400 | retryable: no | emitted by: POST /notifications | note: Verified live 2026-06-16: a no-targeting POST /notifications returns 400 with this exact message. */
const NO_TARGETING_SPECIFIED = 'You must include which players, segments, or tags you wish to send this notification to.';
/** HTTP 503 | retryable: yes | emitted by: any endpoint (pgbouncer rejection) | note: Transient DB/pgbouncer failure — the canonical retryable sentinel. */
const SERVICE_UNAVAILABLE = 'Service temporarily unavailable';
}
Loading