From 66f1a45c8b4ee5f316e7fc3e1b513c607ea54b94 Mon Sep 17 00:00:00 2001 From: OneSignal Date: Fri, 24 Jul 2026 20:44:34 +0000 Subject: [PATCH] feat: add v5.10.0 package updates --- api/openapi.yaml | 129 ++++++ docs/DefaultApi.md | 79 ++++ docs/GetSegmentSuccessResponse.md | 14 + docs/SegmentDetails.md | 29 ++ src/main/java/com/onesignal/client/JSON.java | 2 + .../com/onesignal/client/api/DefaultApi.java | 165 +++++++ .../model/GetSegmentSuccessResponse.java | 216 ++++++++++ .../client/model/SegmentDetails.java | 408 ++++++++++++++++++ 8 files changed, 1042 insertions(+) create mode 100644 docs/GetSegmentSuccessResponse.md create mode 100644 docs/SegmentDetails.md create mode 100644 src/main/java/com/onesignal/client/model/GetSegmentSuccessResponse.java create mode 100644 src/main/java/com/onesignal/client/model/SegmentDetails.java diff --git a/api/openapi.yaml b/api/openapi.yaml index 41b0fe8..626cc8b 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -721,6 +721,74 @@ paths: - rest_api_key: [] summary: Delete Segment x-accepts: application/json + get: + description: "Retrieve details for a single segment by its ID, including subscriber\ + \ count and optionally segment metadata and filters." + operationId: get_segment + parameters: + - description: The OneSignal App ID for your app. Available in Keys & IDs. + explode: false + in: path + name: app_id + required: true + schema: + example: YOUR_APP_ID + type: string + style: simple + - description: The segment's unique identifier. Can be found using the View + Segments API or in the URL of the segment when viewing it in the dashboard. + explode: false + in: path + name: segment_id + required: true + schema: + example: d6c5a3e1-9f17-44a1-9d10-7c0e4a2b1c8e + type: string + style: simple + - description: Set to true to include segment metadata and filters in the response. + explode: true + in: query + name: include-segment-detail + required: false + schema: + example: true + type: boolean + style: form + responses: + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GenericError' + description: Unexpected error + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/GetSegmentSuccessResponse' + description: OK + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/GenericError' + description: Bad Request + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/GenericError' + description: Not Found + "429": + content: + application/json: + schema: + $ref: '#/components/schemas/RateLimitError' + description: Rate Limit Exceeded + security: + - rest_api_key: [] + summary: View Segment + x-accepts: application/json /apps/{app_id}/outcomes: get: description: "View the details of all the outcomes associated with your app\n\ @@ -3574,6 +3642,67 @@ components: $ref: '#/components/schemas/SegmentData' type: array type: object + SegmentDetails: + description: Segment details. Only included when the include-segment-detail + query parameter is set to true. + example: + name: name + description: description + created_at: 6 + id: id + source: default + filters: + - null + - null + properties: + id: + description: The unique identifier for the segment (UUID v4). + type: string + name: + description: The segment name. + type: string + description: + description: Human-readable description for the segment. `null` when unset. + Maximum 255 characters. + nullable: true + type: string + created_at: + description: Unix timestamp when the segment was created. + type: integer + source: + description: The source of the segment. + enum: + - default + - custom + - quickstart + type: string + filters: + description: "Array of filter and operator objects defining the segment\ + \ criteria. Uses the same format as the Create Segment API, so filters\ + \ can be directly used to recreate or update the segment." + items: + $ref: '#/components/schemas/FilterExpression' + type: array + type: object + GetSegmentSuccessResponse: + example: + payload: + name: name + description: description + created_at: 6 + id: id + source: default + filters: + - null + - null + subscriber_count: 0 + properties: + subscriber_count: + description: The number of subscribers matching this segment. + type: integer + payload: + $ref: '#/components/schemas/SegmentDetails' + type: object UpdateLiveActivityRequest: example: event_updates: "{}" diff --git a/docs/DefaultApi.md b/docs/DefaultApi.md index 97db482..f83e0d2 100644 --- a/docs/DefaultApi.md +++ b/docs/DefaultApi.md @@ -32,6 +32,7 @@ All URIs are relative to *https://api.onesignal.com* | [**getNotificationHistory**](DefaultApi.md#getNotificationHistory) | **POST** /notifications/{notification_id}/history | Notification History | | [**getNotifications**](DefaultApi.md#getNotifications) | **GET** /notifications | View notifications | | [**getOutcomes**](DefaultApi.md#getOutcomes) | **GET** /apps/{app_id}/outcomes | View Outcomes | +| [**getSegment**](DefaultApi.md#getSegment) | **GET** /apps/{app_id}/segments/{segment_id} | View Segment | | [**getSegments**](DefaultApi.md#getSegments) | **GET** /apps/{app_id}/segments | Get Segments | | [**getUser**](DefaultApi.md#getUser) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id} | | | [**rotateApiKey**](DefaultApi.md#rotateApiKey) | **POST** /apps/{app_id}/auth/tokens/{token_id}/rotate | Rotate API key | @@ -2330,6 +2331,84 @@ public class Example { | **429** | Rate Limit Exceeded | - | | **0** | Unexpected error | - | + +# **getSegment** +> GetSegmentSuccessResponse getSegment(appId, segmentId, includeSegmentDetail) + +View Segment + +Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. + +### Example +```java +// Import classes: +import com.onesignal.client.ApiClient; +import com.onesignal.client.ApiException; +import com.onesignal.client.Configuration; +import com.onesignal.client.auth.*; +import com.onesignal.client.model.*; +import com.onesignal.client.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.onesignal.com"); + + // Configure HTTP bearer authorization: rest_api_key + HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication("rest_api_key"); + rest_api_key.setBearerToken("YOUR_REST_API_KEY"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + String appId = "YOUR_APP_ID"; // String | The OneSignal App ID for your app. Available in Keys & IDs. + String segmentId = "d6c5a3e1-9f17-44a1-9d10-7c0e4a2b1c8e"; // String | The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. + Boolean includeSegmentDetail = true; // Boolean | Set to true to include segment metadata and filters in the response. + try { + GetSegmentSuccessResponse result = apiInstance.getSegment(appId, segmentId, includeSegmentDetail); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#getSegment"); + System.err.println("Status code: " + e.getCode()); + // getErrorMessages() flattens any error-envelope shape to a List; + // the raw body remains on getResponseBody(). + System.err.println("Error messages: " + e.getErrorMessages()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **appId** | **String**| The OneSignal App ID for your app. Available in Keys & IDs. | | +| **segmentId** | **String**| The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. | | +| **includeSegmentDetail** | **Boolean**| Set to true to include segment metadata and filters in the response. | [optional] | + +### Return type + +[**GetSegmentSuccessResponse**](GetSegmentSuccessResponse.md) + +### Authorization + +[rest_api_key](https://github.com/OneSignal/onesignal-java-api#configuration) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **400** | Bad Request | - | +| **404** | Not Found | - | +| **429** | Rate Limit Exceeded | - | +| **0** | Unexpected error | - | + # **getSegments** > GetSegmentsSuccessResponse getSegments(appId, offset, limit) diff --git a/docs/GetSegmentSuccessResponse.md b/docs/GetSegmentSuccessResponse.md new file mode 100644 index 0000000..357b214 --- /dev/null +++ b/docs/GetSegmentSuccessResponse.md @@ -0,0 +1,14 @@ + + +# GetSegmentSuccessResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**subscriberCount** | **Integer** | The number of subscribers matching this segment. | [optional] | +|**payload** | [**SegmentDetails**](SegmentDetails.md) | | [optional] | + + + diff --git a/docs/SegmentDetails.md b/docs/SegmentDetails.md new file mode 100644 index 0000000..d2ed261 --- /dev/null +++ b/docs/SegmentDetails.md @@ -0,0 +1,29 @@ + + +# SegmentDetails + +Segment details. Only included when the include-segment-detail query parameter is set to true. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | The unique identifier for the segment (UUID v4). | [optional] | +|**name** | **String** | The segment name. | [optional] | +|**description** | **String** | Human-readable description for the segment. `null` when unset. Maximum 255 characters. | [optional] | +|**createdAt** | **Integer** | Unix timestamp when the segment was created. | [optional] | +|**source** | [**SourceEnum**](#SourceEnum) | The source of the segment. | [optional] | +|**filters** | [**List<FilterExpression>**](FilterExpression.md) | Array of filter and operator objects defining the segment criteria. Uses the same format as the Create Segment API, so filters can be directly used to recreate or update the segment. | [optional] | + + + +## Enum: SourceEnum + +| Name | Value | +|---- | -----| +| DEFAULT | "default" | +| CUSTOM | "custom" | +| QUICKSTART | "quickstart" | + + + diff --git a/src/main/java/com/onesignal/client/JSON.java b/src/main/java/com/onesignal/client/JSON.java index de56d9d..3020542 100644 --- a/src/main/java/com/onesignal/client/JSON.java +++ b/src/main/java/com/onesignal/client/JSON.java @@ -121,6 +121,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri .registerTypeAdapterFactory(new com.onesignal.client.model.GenericError.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.GenericSuccessBoolResponse.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.GetNotificationHistoryRequestBody.CustomTypeAdapterFactory()) + .registerTypeAdapterFactory(new com.onesignal.client.model.GetSegmentSuccessResponse.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.GetSegmentsSuccessResponse.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.LanguageStringMap.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.Notification.CustomTypeAdapterFactory()) @@ -143,6 +144,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri .registerTypeAdapterFactory(new com.onesignal.client.model.RateLimitError.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.Segment.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.SegmentData.CustomTypeAdapterFactory()) + .registerTypeAdapterFactory(new com.onesignal.client.model.SegmentDetails.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.SegmentNotificationTarget.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.StartLiveActivityRequest.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.StartLiveActivitySuccessResponse.CustomTypeAdapterFactory()) diff --git a/src/main/java/com/onesignal/client/api/DefaultApi.java b/src/main/java/com/onesignal/client/api/DefaultApi.java index 338f401..2ce4d8c 100644 --- a/src/main/java/com/onesignal/client/api/DefaultApi.java +++ b/src/main/java/com/onesignal/client/api/DefaultApi.java @@ -44,6 +44,7 @@ import com.onesignal.client.model.GenericError; import com.onesignal.client.model.GenericSuccessBoolResponse; import com.onesignal.client.model.GetNotificationHistoryRequestBody; +import com.onesignal.client.model.GetSegmentSuccessResponse; import com.onesignal.client.model.GetSegmentsSuccessResponse; import com.onesignal.client.model.Notification; import com.onesignal.client.model.NotificationHistorySuccessResponse; @@ -4531,6 +4532,170 @@ public okhttp3.Call getOutcomesAsync(String appId, String outcomeNames, String o localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for getSegment + * @param appId The OneSignal App ID for your app. Available in Keys & IDs. (required) + * @param segmentId The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. (required) + * @param includeSegmentDetail Set to true to include segment metadata and filters in the response. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK -
400 Bad Request -
404 Not Found -
429 Rate Limit Exceeded -
0 Unexpected error -
+ */ + public okhttp3.Call getSegmentCall(String appId, String segmentId, Boolean includeSegmentDetail, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/apps/{app_id}/segments/{segment_id}" + .replaceAll("\\{" + "app_id" + "\\}", localVarApiClient.escapeString(appId.toString())) + .replaceAll("\\{" + "segment_id" + "\\}", localVarApiClient.escapeString(segmentId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + // Adds client sdk version header + localVarHeaderParams.put("OS-Usage-Data", "kind=sdk, sdk-name=onesignal-java, version=5.10.0"); + + if (includeSegmentDetail != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("include-segment-detail", includeSegmentDetail)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "rest_api_key" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getSegmentValidateBeforeCall(String appId, String segmentId, Boolean includeSegmentDetail, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'appId' is set + if (appId == null) { + throw new ApiException("Missing the required parameter 'appId' when calling getSegment(Async)"); + } + + // verify the required parameter 'segmentId' is set + if (segmentId == null) { + throw new ApiException("Missing the required parameter 'segmentId' when calling getSegment(Async)"); + } + + + okhttp3.Call localVarCall = getSegmentCall(appId, segmentId, includeSegmentDetail, _callback); + return localVarCall; + + } + + /** + * View Segment + * Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. + * @param appId The OneSignal App ID for your app. Available in Keys & IDs. (required) + * @param segmentId The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. (required) + * @param includeSegmentDetail Set to true to include segment metadata and filters in the response. (optional) + * @return GetSegmentSuccessResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK -
400 Bad Request -
404 Not Found -
429 Rate Limit Exceeded -
0 Unexpected error -
+ */ + public GetSegmentSuccessResponse getSegment(String appId, String segmentId, Boolean includeSegmentDetail) throws ApiException { + ApiResponse localVarResp = getSegmentWithHttpInfo(appId, segmentId, includeSegmentDetail); + return localVarResp.getData(); + } + + /** + * View Segment + * Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. + * @param appId The OneSignal App ID for your app. Available in Keys & IDs. (required) + * @param segmentId The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. (required) + * @param includeSegmentDetail Set to true to include segment metadata and filters in the response. (optional) + * @return ApiResponse<GetSegmentSuccessResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK -
400 Bad Request -
404 Not Found -
429 Rate Limit Exceeded -
0 Unexpected error -
+ */ + public ApiResponse getSegmentWithHttpInfo(String appId, String segmentId, Boolean includeSegmentDetail) throws ApiException { + okhttp3.Call localVarCall = getSegmentValidateBeforeCall(appId, segmentId, includeSegmentDetail, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * View Segment (asynchronously) + * Retrieve details for a single segment by its ID, including subscriber count and optionally segment metadata and filters. + * @param appId The OneSignal App ID for your app. Available in Keys & IDs. (required) + * @param segmentId The segment's unique identifier. Can be found using the View Segments API or in the URL of the segment when viewing it in the dashboard. (required) + * @param includeSegmentDetail Set to true to include segment metadata and filters in the response. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK -
400 Bad Request -
404 Not Found -
429 Rate Limit Exceeded -
0 Unexpected error -
+ */ + public okhttp3.Call getSegmentAsync(String appId, String segmentId, Boolean includeSegmentDetail, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getSegmentValidateBeforeCall(appId, segmentId, includeSegmentDetail, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for getSegments * @param appId The OneSignal App ID for your app. Available in Keys & IDs. (required) diff --git a/src/main/java/com/onesignal/client/model/GetSegmentSuccessResponse.java b/src/main/java/com/onesignal/client/model/GetSegmentSuccessResponse.java new file mode 100644 index 0000000..1b65b79 --- /dev/null +++ b/src/main/java/com/onesignal/client/model/GetSegmentSuccessResponse.java @@ -0,0 +1,216 @@ +/* + * 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.10.0 + * Contact: devrel@onesignal.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.onesignal.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.onesignal.client.model.SegmentDetails; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.io.Serializable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.onesignal.client.JSON; + +/** + * GetSegmentSuccessResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GetSegmentSuccessResponse { + private static final long serialVersionUID = 1L; + + public static final String SERIALIZED_NAME_SUBSCRIBER_COUNT = "subscriber_count"; + @SerializedName(SERIALIZED_NAME_SUBSCRIBER_COUNT) + private Integer subscriberCount; + + public static final String SERIALIZED_NAME_PAYLOAD = "payload"; + @SerializedName(SERIALIZED_NAME_PAYLOAD) + private SegmentDetails payload; + + public GetSegmentSuccessResponse() { + } + + public GetSegmentSuccessResponse subscriberCount(Integer subscriberCount) { + + this.subscriberCount = subscriberCount; + return this; + } + + /** + * The number of subscribers matching this segment. + * @return subscriberCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The number of subscribers matching this segment.") + + public Integer getSubscriberCount() { + return subscriberCount; + } + + + public void setSubscriberCount(Integer subscriberCount) { + this.subscriberCount = subscriberCount; + } + + + public GetSegmentSuccessResponse payload(SegmentDetails payload) { + + this.payload = payload; + return this; + } + + /** + * Get payload + * @return payload + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public SegmentDetails getPayload() { + return payload; + } + + + public void setPayload(SegmentDetails payload) { + this.payload = payload; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetSegmentSuccessResponse getSegmentSuccessResponse = (GetSegmentSuccessResponse) o; + return Objects.equals(this.subscriberCount, getSegmentSuccessResponse.subscriberCount) && + Objects.equals(this.payload, getSegmentSuccessResponse.payload); + } + + @Override + public int hashCode() { + return Objects.hash(subscriberCount, payload); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetSegmentSuccessResponse {\n"); + sb.append(" subscriberCount: ").append(toIndentedString(subscriberCount)).append("\n"); + sb.append(" payload: ").append(toIndentedString(payload)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("subscriber_count"); + openapiFields.add("payload"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetSegmentSuccessResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetSegmentSuccessResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetSegmentSuccessResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetSegmentSuccessResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetSegmentSuccessResponse read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetSegmentSuccessResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetSegmentSuccessResponse + * @throws IOException if the JSON string is invalid with respect to GetSegmentSuccessResponse + */ + public static GetSegmentSuccessResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetSegmentSuccessResponse.class); + } + + /** + * Convert an instance of GetSegmentSuccessResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onesignal/client/model/SegmentDetails.java b/src/main/java/com/onesignal/client/model/SegmentDetails.java new file mode 100644 index 0000000..986867e --- /dev/null +++ b/src/main/java/com/onesignal/client/model/SegmentDetails.java @@ -0,0 +1,408 @@ +/* + * 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.10.0 + * Contact: devrel@onesignal.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.onesignal.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.onesignal.client.model.FilterExpression; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.io.Serializable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.onesignal.client.JSON; + +/** + * Segment details. Only included when the include-segment-detail query parameter is set to true. + */ +@ApiModel(description = "Segment details. Only included when the include-segment-detail query parameter is set to true.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SegmentDetails { + private static final long serialVersionUID = 1L; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_CREATED_AT = "created_at"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private Integer createdAt; + + /** + * The source of the segment. + */ + @JsonAdapter(SourceEnum.Adapter.class) + public enum SourceEnum { + DEFAULT("default"), + + CUSTOM("custom"), + + QUICKSTART("quickstart"); + + private String value; + + SourceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SourceEnum fromValue(String value) { + for (SourceEnum b : SourceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SourceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SourceEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + private SourceEnum source; + + public static final String SERIALIZED_NAME_FILTERS = "filters"; + @SerializedName(SERIALIZED_NAME_FILTERS) + private List filters = null; + + public SegmentDetails() { + } + + public SegmentDetails id(String id) { + + this.id = id; + return this; + } + + /** + * The unique identifier for the segment (UUID v4). + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The unique identifier for the segment (UUID v4).") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public SegmentDetails name(String name) { + + this.name = name; + return this; + } + + /** + * The segment name. + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The segment name.") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public SegmentDetails description(String description) { + + this.description = description; + return this; + } + + /** + * Human-readable description for the segment. `null` when unset. Maximum 255 characters. + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Human-readable description for the segment. `null` when unset. Maximum 255 characters.") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public SegmentDetails createdAt(Integer createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * Unix timestamp when the segment was created. + * @return createdAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Unix timestamp when the segment was created.") + + public Integer getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(Integer createdAt) { + this.createdAt = createdAt; + } + + + public SegmentDetails source(SourceEnum source) { + + this.source = source; + return this; + } + + /** + * The source of the segment. + * @return source + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The source of the segment.") + + public SourceEnum getSource() { + return source; + } + + + public void setSource(SourceEnum source) { + this.source = source; + } + + + public SegmentDetails filters(List filters) { + + this.filters = filters; + return this; + } + + public SegmentDetails addFiltersItem(FilterExpression filtersItem) { + if (this.filters == null) { + this.filters = new ArrayList<>(); + } + this.filters.add(filtersItem); + return this; + } + + /** + * Array of filter and operator objects defining the segment criteria. Uses the same format as the Create Segment API, so filters can be directly used to recreate or update the segment. + * @return filters + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Array of filter and operator objects defining the segment criteria. Uses the same format as the Create Segment API, so filters can be directly used to recreate or update the segment.") + + public List getFilters() { + return filters; + } + + + public void setFilters(List filters) { + this.filters = filters; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SegmentDetails segmentDetails = (SegmentDetails) o; + return Objects.equals(this.id, segmentDetails.id) && + Objects.equals(this.name, segmentDetails.name) && + Objects.equals(this.description, segmentDetails.description) && + Objects.equals(this.createdAt, segmentDetails.createdAt) && + Objects.equals(this.source, segmentDetails.source) && + Objects.equals(this.filters, segmentDetails.filters); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, createdAt, source, filters); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SegmentDetails {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("description"); + openapiFields.add("created_at"); + openapiFields.add("source"); + openapiFields.add("filters"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SegmentDetails.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SegmentDetails' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SegmentDetails.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SegmentDetails value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SegmentDetails read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SegmentDetails given an JSON string + * + * @param jsonString JSON string + * @return An instance of SegmentDetails + * @throws IOException if the JSON string is invalid with respect to SegmentDetails + */ + public static SegmentDetails fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SegmentDetails.class); + } + + /** + * Convert an instance of SegmentDetails to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +