feat: add v5.7.0 package updates by onesignal-deploy · Pull Request #103 · OneSignal/onesignal-java-api · GitHub
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
33 changes: 30 additions & 3 deletions api/openapi.yaml
2 changes: 1 addition & 1 deletion docs/CreateNotificationSuccessResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**id** | **String** | Notification identifier when the request created a notification. An empty string means no notification was created; read `errors` for details (HTTP may still be 200). | [optional] |
|**id** | **String** | Notification identifier when the request created a notification. An empty string means no notification was created; read `errors` for details (HTTP may still be 200). All OneSignal server SDKs expose message-sent / message-not-sent narrowing helpers (named idiomatically per language — e.g. `isMessageSent`, `is_message_sent`, `message_sent?`); prefer them over comparing `id` directly. | [optional] |
|**externalId** | **String** | Optional correlation / idempotency-related value from the API response. This is not the end-user External ID used for targeting recipients (that lives under `include_aliases.external_id`). | [optional] |
|**errors** | **Object** | Polymorphic field: may be an array of human-readable strings and/or an object (for example with `invalid_aliases`, `invalid_external_user_ids`, or `invalid_player_ids`) depending on the API response; HTTP may still be 200 with partial success. Typed SDKs model this loosely so both shapes deserialize. | [optional] |

Expand Down
6 changes: 4 additions & 2 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ public class Example {

<a name="getNotifications"></a>
# **getNotifications**
> NotificationSlice getNotifications(appId, limit, offset, kind)
> NotificationSlice getNotifications(appId, limit, offset, kind, timeOffset)

View notifications

Expand Down Expand Up @@ -2165,8 +2165,9 @@ public class Example {
Integer limit = 10; // Integer | How many notifications to return. Max is 50. Default is 50.
Integer offset = 0; // Integer | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.
Integer kind = 0; // Integer | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only
String timeOffset = "2025-01-01T00:00:00.000Z"; // String | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.
try {
NotificationSlice result = apiInstance.getNotifications(appId, limit, offset, kind);
NotificationSlice result = apiInstance.getNotifications(appId, limit, offset, kind, timeOffset);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#getNotifications");
Expand All @@ -2190,6 +2191,7 @@ public class Example {
| **limit** | **Integer**| How many notifications to return. Max is 50. Default is 50. | [optional] |
| **offset** | **Integer**| Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. | [optional] |
| **kind** | **Integer**| Kind of notifications returned: * unset - All notification types (default) * &#x60;0&#x60; - Dashboard only * &#x60;1&#x60; - API only * &#x60;3&#x60; - Automated only | [optional] [enum: 0, 1, 3] |
| **timeOffset** | **String**| Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. &#x60;2025-01-01T00:00:00.000Z&#x60;) or the opaque Base64 cursor token returned as &#x60;next_time_offset&#x60; in a prior response. When set, results are sorted ascending by send_after and the standard &#x60;offset&#x60; parameter cannot be used. Repeat the request with each &#x60;next_time_offset&#x60; until an empty notifications array is returned. | [optional] |

### Return type

Expand Down
2 changes: 2 additions & 0 deletions docs/NotificationSlice.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
|**totalCount** | **Integer** | | [optional] |
|**offset** | **Integer** | | [optional] |
|**limit** | **Integer** | | [optional] |
|**timeOffset** | **String** | The time_offset cursor specified in the request, if any. | [optional] |
|**nextTimeOffset** | **String** | An opaque Base64 cursor token representing the next page of messages to fetch. Present when time_offset was provided in the request. Pass this value as time_offset on the next request to continue paginating. | [optional] |
|**notifications** | [**List&lt;NotificationWithMeta&gt;**](NotificationWithMeta.md) | | [optional] |


Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/onesignal/client/NotificationHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,34 @@ public static CreateNotificationWithRetryResult createNotificationWithRetry(Defa
}
}

/**
* Whether a POST /notifications 200 response is the "message sent" branch.
*
* <p>POST /notifications returns 200 in two cases that share the
* {@link CreateNotificationSuccessResponse} shape: a notification was
* created (non-empty {@code id}), or none was (empty {@code id}, with
* {@code errors} carrying the reason). Prefer this guard over inspecting
* {@code id} directly.
*
* @param response a create-notification success response
* @return {@code true} when a notification was created
*/
public static boolean isMessageSent(CreateNotificationSuccessResponse response) {
return response != null && response.getId() != null && !response.getId().isEmpty();
}

/**
* Whether a POST /notifications 200 response is the "message not sent"
* branch -- no notification was created ({@code id} absent or empty);
* inspect {@code errors} for why.
*
* @param response a create-notification success response
* @return {@code true} when no notification was created
*/
public static boolean isMessageNotSent(CreateNotificationSuccessResponse response) {
return !isMessageSent(response);
}

private static String headerValue(Map<String, List<String>> headers, String name) {
if (headers == null) {
return null;
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/com/onesignal/client/api/DefaultApi.java
Loading