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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# onesignal-java-client

OneSignal
- API version: 5.6.0
- API version: 5.7.0

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

Expand All @@ -19,14 +19,14 @@ Building the API client library requires:
<dependency>
<groupId>com.onesignal</groupId>
<artifactId>onesignal-java-client</artifactId>
<version>5.6.0</version>
<version>5.7.0</version>
</dependency>
```

### Gradle

```groovy
implementation "com.onesignal:onesignal-java-client:5.6.0"
implementation "com.onesignal:onesignal-java-client:5.7.0"
```

## Configuration
Expand Down
2 changes: 1 addition & 1 deletion api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
customer engagement strategies. Learn more at onesignal.com
termsOfService: https://onesignal.com/tos
title: OneSignal
version: 5.6.0
version: 5.7.0
servers:
- url: https://api.onesignal.com
paths:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.vanniktech.maven.publish'

group = 'com.onesignal'
version = '5.6.0'
version = '5.7.0'

buildscript {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
settings(
organization := "com.onesignal",
name := "onesignal-java-client",
version := "5.6.0",
version := "5.7.0",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
javacOptions in compile ++= Seq("-Xlint:deprecation"),
Expand Down
131 changes: 130 additions & 1 deletion docs/DefaultApi.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>onesignal-java-client</artifactId>
<packaging>jar</packaging>
<name>onesignal-java-client</name>
<version>5.6.0</version>
<version>5.7.0</version>
<url>https://github.com/OneSignal/onesignal-java-api</url>
<description>OneSignal Java API Client</description>
<scm>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/onesignal/client/ApiCallback.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/onesignal/client/ApiClient.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -133,7 +133,7 @@ private void init() {
json = new JSON();

// Set default User-Agent.
setUserAgent("OpenAPI-Generator/5.6.0/java");
setUserAgent("OpenAPI-Generator/5.7.0/java");

authentications = new HashMap<String, Authentication>();
}
Expand Down
80 changes: 79 additions & 1 deletion src/main/java/com/onesignal/client/ApiException.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -13,6 +13,12 @@

package com.onesignal.client;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.List;

Expand Down Expand Up @@ -163,4 +169,76 @@ public String getMessage() {
return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s",
super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders());
}

/**
* Get the error messages carried by the response body, normalized to a flat
* list of strings regardless of which envelope shape the API returned
* ({@code {"errors": "..."}}, {@code {"errors": ["..."]}},
* {@code {"errors": [{"code": ..., "title": ...}]}}, or an object map such as
* {@code {"errors": {"invalid_aliases": {...}}}}, surfaced as
* {@code "<key>: <value>"} entries). Returns an empty list when the body is
* not a recognizable error envelope. The raw body remains available via
* {@link #getResponseBody()}.
*
* @return the normalized error messages
*/
public List<String> getErrorMessages() {
List<String> messages = new ArrayList<String>();
if (responseBody == null || responseBody.isEmpty()) {
return messages;
}

try {
JsonElement root = JsonParser.parseString(responseBody);
if (!root.isJsonObject()) {
return messages;
}

JsonElement errors = root.getAsJsonObject().get("errors");
if (errors == null || errors.isJsonNull()) {
return messages;
}

if (errors.isJsonPrimitive()) {
if (errors.getAsJsonPrimitive().isString()) {
messages.add(errors.getAsString());
}
} else if (errors.isJsonArray()) {
for (JsonElement item : errors.getAsJsonArray()) {
if (item.isJsonPrimitive()) {
if (item.getAsJsonPrimitive().isString()) {
messages.add(item.getAsString());
}
} else if (item.isJsonObject()) {
JsonObject object = item.getAsJsonObject();
JsonElement title = object.get("title");
JsonElement code = object.get("code");
if (title != null && title.isJsonPrimitive() && title.getAsJsonPrimitive().isString()
&& !title.getAsString().isEmpty()) {
messages.add(title.getAsString());
} else if (code != null && !code.isJsonNull()) {
messages.add(code.isJsonPrimitive() ? code.getAsString() : code.toString());
}
}
}
} else if (errors.isJsonObject()) {
// 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.
JsonObject object = errors.getAsJsonObject();
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
JsonElement value = entry.getValue();
String rendered = value.isJsonPrimitive() && value.getAsJsonPrimitive().isString()
? value.getAsString()
: value.toString();
messages.add(entry.getKey() + ": " + rendered);
}
Collections.sort(messages);
}
} catch (RuntimeException e) {
return messages;
}

return messages;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/onesignal/client/ApiResponse.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/onesignal/client/Configuration.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/onesignal/client/JSON.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/onesignal/client/OneSignalErrors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.onesignal.client;

/**
* Generated from inputs/api/error-catalog.json. Do not edit by hand.
*
* <p>Sentinel error message strings the OneSignal API can return. Each
* constant equals the literal message the server emits, so you can test
* membership against {@link ApiException#getErrorMessages()} (e.g.
* NO_TARGETING_SPECIFIED).
*
* <p>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.
*/
public final class OneSignalErrors {
private 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.' */
public static final String 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. */
public static final String 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. */
public static final String 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. */
public static final String 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. */
public static final String SERVICE_UNAVAILABLE = "Service temporarily unavailable";
}
2 changes: 1 addition & 1 deletion src/main/java/com/onesignal/client/Pair.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/onesignal/client/StringUtil.java
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
*
* The version of the OpenAPI document: 5.6.0
* The version of the OpenAPI document: 5.7.0
* Contact: devrel@onesignal.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Loading