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
222 changes: 133 additions & 89 deletions DefaultApi.md

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions apis/exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,58 @@ export class ApiException<T> extends Error {
// Reference: https://github.com/microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, ApiException.prototype);
}

/**
* 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: {...} } }`, which is
* surfaced as `"<key>: <value>"` entries). Returns an empty array when the
* body is not a recognizable error envelope. The raw body remains on `body`.
*/
public get errorMessages(): string[] {
let parsed: any = this.body;
if (typeof parsed === "string") {
try {
parsed = JSON.parse(parsed);
} catch {
return [];
}
}
if (parsed === null || typeof parsed !== "object") {
return [];
}
const errors: any = parsed.errors;
if (typeof errors === "string") {
return [errors];
}
if (Array.isArray(errors)) {
return errors
.map((e: any) => {
if (typeof e === "string") {
return e;
}
if (e !== null && typeof e === "object") {
const title = typeof e.title === "string" ? e.title : undefined;
const code = typeof e.code === "string" ? e.code : (e.code != null ? String(e.code) : undefined);
return title || code;
}
return undefined;
})
.filter((m: any): m is string => typeof m === "string");
}
if (errors !== null && typeof errors === "object") {
// 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.
return Object.keys(errors)
.map((key: string) => {
const value: any = errors[key];
const rendered = typeof value === "string" ? value : JSON.stringify(value);
return key + ": " + rendered;
})
.sort();
}
return [];
}
}
1 change: 1 addition & 0 deletions dist/apis/exception.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export declare class ApiException<T> extends Error {
constructor(code: number, message: string, body: T, headers: {
[key: string]: string;
});
get errorMessages(): string[];
}
43 changes: 43 additions & 0 deletions dist/apis/exception.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/apis/exception.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion models/ApiKeyToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ApiKeyTokensListResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/BasicNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/BasicNotificationAllOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/BasicNotificationAllOfAndroidBackgroundLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CopyTemplateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateApiKeyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateApiKeyResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateNotificationSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateSegmentConflictResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateSegmentSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateTemplateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateUserConflictResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateUserConflictResponseErrorsInner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateUserConflictResponseErrorsItemsMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CustomEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CustomEventsRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/DeliveryData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ExportEventsSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ExportSubscriptionsRequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ExportSubscriptionsSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/Filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/FilterExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/GenericError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/GenericSuccessBoolResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/GetNotificationHistoryRequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/GetSegmentsSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/LanguageStringMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/Notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
Loading