Skip to content

Commit 1bf020c

Browse files
authored
feat: add v5.7.0 package updates (#101)
## Release v5.7.0 ### 🚀 Features - feat: [SDK-4438] add typed error-messages accessor to ApiException - feat: [SDK-4440] generate typed error-code catalog module per SDK - feat: [SDK-4441] add idempotency-key retry helper for create-notification ### 📚 Docs - docs: clarify errorMessages excludes structured meta; show how to read it - docs: [SDK-4440] cross-link OneSignalErrors catalog from DefaultApi.md error handling --- _Generated from [OneSignal/API-Client-Libraries@e4fc576...06c5b0f](OneSignal/API-Client-Libraries@e4fc576...06c5b0ffeb52f85914a6dd8f14ad4d6cdf81c176)._
2 parents effeee7 + eacce4d commit 1bf020c

92 files changed

Lines changed: 613 additions & 137 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# onesignal-java-client
22

33
OneSignal
4-
- API version: 5.6.0
4+
- API version: 5.7.0
55

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

@@ -19,14 +19,14 @@ Building the API client library requires:
1919
<dependency>
2020
<groupId>com.onesignal</groupId>
2121
<artifactId>onesignal-java-client</artifactId>
22-
<version>5.6.0</version>
22+
<version>5.7.0</version>
2323
</dependency>
2424
```
2525

2626
### Gradle
2727

2828
```groovy
29-
implementation "com.onesignal:onesignal-java-client:5.6.0"
29+
implementation "com.onesignal:onesignal-java-client:5.7.0"
3030
```
3131

3232
## Configuration

api/openapi.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ info:
88
customer engagement strategies. Learn more at onesignal.com
99
termsOfService: https://onesignal.com/tos
1010
title: OneSignal
11-
version: 5.6.0
11+
version: 5.7.0
1212
servers:
1313
- url: https://api.onesignal.com
1414
paths:
@@ -903,6 +903,7 @@ paths:
903903
description: Rate Limit Exceeded
904904
security:
905905
- rest_api_key: []
906+
x-onesignal-create-user-conflict-example: true
906907
x-content-type: application/json
907908
x-accepts: application/json
908909
/apps/{app_id}/users/by/{alias_label}/{alias_id}:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'com.diffplug.spotless'
55
apply plugin: 'com.vanniktech.maven.publish'
66

77
group = 'com.onesignal'
8-
version = '5.6.0'
8+
version = '5.7.0'
99

1010
buildscript {
1111
repositories {

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
22
settings(
33
organization := "com.onesignal",
44
name := "onesignal-java-client",
5-
version := "5.6.0",
5+
version := "5.7.0",
66
scalaVersion := "2.11.4",
77
scalacOptions ++= Seq("-feature"),
88
javacOptions in compile ++= Seq("-Xlint:deprecation"),

docs/DefaultApi.md

Lines changed: 209 additions & 1 deletion
Large diffs are not rendered by default.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>onesignal-java-client</artifactId>
66
<packaging>jar</packaging>
77
<name>onesignal-java-client</name>
8-
<version>5.6.0</version>
8+
<version>5.7.0</version>
99
<url>https://github.com/OneSignal/onesignal-java-api</url>
1010
<description>OneSignal Java API Client</description>
1111
<scm>

src/main/java/com/onesignal/client/ApiCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 5.6.0
5+
* The version of the OpenAPI document: 5.7.0
66
* Contact: devrel@onesignal.com
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

src/main/java/com/onesignal/client/ApiClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 5.6.0
5+
* The version of the OpenAPI document: 5.7.0
66
* Contact: devrel@onesignal.com
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -133,7 +133,7 @@ private void init() {
133133
json = new JSON();
134134

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

138138
authentications = new HashMap<String, Authentication>();
139139
}

src/main/java/com/onesignal/client/ApiException.java

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 5.6.0
5+
* The version of the OpenAPI document: 5.7.0
66
* Contact: devrel@onesignal.com
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -13,6 +13,12 @@
1313

1414
package com.onesignal.client;
1515

16+
import com.google.gson.JsonElement;
17+
import com.google.gson.JsonObject;
18+
import com.google.gson.JsonParser;
19+
20+
import java.util.ArrayList;
21+
import java.util.Collections;
1622
import java.util.Map;
1723
import java.util.List;
1824

@@ -163,4 +169,76 @@ public String getMessage() {
163169
return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s",
164170
super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders());
165171
}
172+
173+
/**
174+
* Get the error messages carried by the response body, normalized to a flat
175+
* list of strings regardless of which envelope shape the API returned
176+
* ({@code {"errors": "..."}}, {@code {"errors": ["..."]}},
177+
* {@code {"errors": [{"code": ..., "title": ...}]}}, or an object map such as
178+
* {@code {"errors": {"invalid_aliases": {...}}}}, surfaced as
179+
* {@code "<key>: <value>"} entries). Returns an empty list when the body is
180+
* not a recognizable error envelope. The raw body remains available via
181+
* {@link #getResponseBody()}.
182+
*
183+
* @return the normalized error messages
184+
*/
185+
public List<String> getErrorMessages() {
186+
List<String> messages = new ArrayList<String>();
187+
if (responseBody == null || responseBody.isEmpty()) {
188+
return messages;
189+
}
190+
191+
try {
192+
JsonElement root = JsonParser.parseString(responseBody);
193+
if (!root.isJsonObject()) {
194+
return messages;
195+
}
196+
197+
JsonElement errors = root.getAsJsonObject().get("errors");
198+
if (errors == null || errors.isJsonNull()) {
199+
return messages;
200+
}
201+
202+
if (errors.isJsonPrimitive()) {
203+
if (errors.getAsJsonPrimitive().isString()) {
204+
messages.add(errors.getAsString());
205+
}
206+
} else if (errors.isJsonArray()) {
207+
for (JsonElement item : errors.getAsJsonArray()) {
208+
if (item.isJsonPrimitive()) {
209+
if (item.getAsJsonPrimitive().isString()) {
210+
messages.add(item.getAsString());
211+
}
212+
} else if (item.isJsonObject()) {
213+
JsonObject object = item.getAsJsonObject();
214+
JsonElement title = object.get("title");
215+
JsonElement code = object.get("code");
216+
if (title != null && title.isJsonPrimitive() && title.getAsJsonPrimitive().isString()
217+
&& !title.getAsString().isEmpty()) {
218+
messages.add(title.getAsString());
219+
} else if (code != null && !code.isJsonNull()) {
220+
messages.add(code.isJsonPrimitive() ? code.getAsString() : code.toString());
221+
}
222+
}
223+
}
224+
} else if (errors.isJsonObject()) {
225+
// Object-shaped envelopes (e.g. {"invalid_aliases": {...}}) carry
226+
// data under arbitrary keys; surface each so it isn't silently
227+
// dropped. Key order is unspecified, so sort for deterministic output.
228+
JsonObject object = errors.getAsJsonObject();
229+
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
230+
JsonElement value = entry.getValue();
231+
String rendered = value.isJsonPrimitive() && value.getAsJsonPrimitive().isString()
232+
? value.getAsString()
233+
: value.toString();
234+
messages.add(entry.getKey() + ": " + rendered);
235+
}
236+
Collections.sort(messages);
237+
}
238+
} catch (RuntimeException e) {
239+
return messages;
240+
}
241+
242+
return messages;
243+
}
166244
}

src/main/java/com/onesignal/client/ApiResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* OneSignal
33
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
*
5-
* The version of the OpenAPI document: 5.6.0
5+
* The version of the OpenAPI document: 5.7.0
66
* Contact: devrel@onesignal.com
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

0 commit comments

Comments
 (0)