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
Loading