diff --git a/api/openapi.yaml b/api/openapi.yaml index a47ba1ca..7e493196 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -968,6 +968,59 @@ paths: - rest_api_key: [] summary: View Outcomes x-accepts: application/json + /apps/{app_id}/email_analytics/delivery_metrics: + get: + description: "The email bounce and spam complaint rates received for the app\ + \ over the last 24 hours, 7 days, and 30 days.\nRates are expressed as fractions\ + \ of successfully delivered emails (for example, `0.02` means 2%). A window\ + \ reports `0` for both rates when the app has not successfully delivered any\ + \ email in that period.\n" + operationId: get_email_reputation + parameters: + - description: Your OneSignal App ID in UUID v4 format. + explode: false + in: path + name: app_id + required: true + schema: + example: YOUR_APP_ID + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/EmailReputationResponse' + description: OK + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GenericError' + description: Unexpected error + "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: Get email reputation statistics + x-accepts: application/json /apps/{app_id}/activities/activity/{activity_type}: post: description: Remotely start a Live Activity on iOS devices via OneSignal’s REST @@ -5148,6 +5201,48 @@ components: `false`. type: integer type: object + EmailReputationResponse: + description: "App-wide email bounce and spam complaint rates, broken out by\ + \ time window." + example: + last_7_days: "" + last_24_hours: "" + last_30_days: "" + properties: + last_24_hours: + allOf: + - $ref: '#/components/schemas/EmailReputationWindow' + description: Bounce and complaint rates for email delivered over the last + 24 hours. + last_7_days: + allOf: + - $ref: '#/components/schemas/EmailReputationWindow' + description: Bounce and complaint rates for email delivered over the last + 7 days. + last_30_days: + allOf: + - $ref: '#/components/schemas/EmailReputationWindow' + description: Bounce and complaint rates for email delivered over the last + 30 days. + type: object + EmailReputationWindow: + description: "Email reputation rates for a single time window. Each rate is\ + \ a fraction of successfully delivered emails (for example, `0.02` means 2%).\ + \ Both rates are `0` when no email was successfully delivered in the window." + properties: + bounce_rate: + description: The fraction of successfully delivered emails that hard or + soft bounced during the window. + example: 0.02 + format: double + type: number + complaint_rate: + description: The fraction of successfully delivered emails that recipients + reported as spam during the window. + example: 0.001 + format: double + type: number + type: object GenericSuccessBoolResponse: example: success: true diff --git a/docs/DefaultApi.md b/docs/DefaultApi.md index ff73cef3..e320e0b4 100644 --- a/docs/DefaultApi.md +++ b/docs/DefaultApi.md @@ -31,6 +31,7 @@ All URIs are relative to *https://api.onesignal.com* | [**getAliasesBySubscription**](DefaultApi.md#getAliasesBySubscription) | **GET** /apps/{app_id}/subscriptions/{subscription_id}/user/identity | | | [**getApp**](DefaultApi.md#getApp) | **GET** /apps/{app_id} | View an app | | [**getApps**](DefaultApi.md#getApps) | **GET** /apps | View apps | +| [**getEmailReputation**](DefaultApi.md#getEmailReputation) | **GET** /apps/{app_id}/email_analytics/delivery_metrics | Get email reputation statistics | | [**getNotification**](DefaultApi.md#getNotification) | **GET** /notifications/{notification_id} | View notification | | [**getNotificationHistory**](DefaultApi.md#getNotificationHistory) | **POST** /notifications/{notification_id}/history | Notification History | | [**getNotifications**](DefaultApi.md#getNotifications) | **GET** /notifications | View notifications | @@ -2250,6 +2251,80 @@ This endpoint does not need any parameter. | **429** | Rate Limit Exceeded | - | | **0** | Unexpected error | - | + +# **getEmailReputation** +> EmailReputationResponse getEmailReputation(appId) + +Get email reputation statistics + +The email bounce and spam complaint rates received for the app over the last 24 hours, 7 days, and 30 days. Rates are expressed as fractions of successfully delivered emails (for example, `0.02` means 2%). A window reports `0` for both rates when the app has not successfully delivered any email in that period. + +### 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 | Your OneSignal App ID in UUID v4 format. + try { + EmailReputationResponse result = apiInstance.getEmailReputation(appId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#getEmailReputation"); + 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**| Your OneSignal App ID in UUID v4 format. | | + +### Return type + +[**EmailReputationResponse**](EmailReputationResponse.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 | - | + # **getNotification** > NotificationWithMeta getNotification(appId, notificationId) diff --git a/docs/EmailReputationResponse.md b/docs/EmailReputationResponse.md new file mode 100644 index 00000000..3af2bf58 --- /dev/null +++ b/docs/EmailReputationResponse.md @@ -0,0 +1,16 @@ + + +# EmailReputationResponse + +App-wide email bounce and spam complaint rates, broken out by time window. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**last24Hours** | [**EmailReputationWindow**](EmailReputationWindow.md) | Bounce and complaint rates for email delivered over the last 24 hours. | [optional] | +|**last7Days** | [**EmailReputationWindow**](EmailReputationWindow.md) | Bounce and complaint rates for email delivered over the last 7 days. | [optional] | +|**last30Days** | [**EmailReputationWindow**](EmailReputationWindow.md) | Bounce and complaint rates for email delivered over the last 30 days. | [optional] | + + + diff --git a/docs/EmailReputationWindow.md b/docs/EmailReputationWindow.md new file mode 100644 index 00000000..5d640838 --- /dev/null +++ b/docs/EmailReputationWindow.md @@ -0,0 +1,15 @@ + + +# EmailReputationWindow + +Email reputation rates for a single time window. Each rate is a fraction of successfully delivered emails (for example, `0.02` means 2%). Both rates are `0` when no email was successfully delivered in the window. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**bounceRate** | **Double** | The fraction of successfully delivered emails that hard or soft bounced during the window. | [optional] | +|**complaintRate** | **Double** | The fraction of successfully delivered emails that recipients reported as spam during the window. | [optional] | + + + diff --git a/src/main/java/com/onesignal/client/JSON.java b/src/main/java/com/onesignal/client/JSON.java index a519fca3..3b865fb7 100644 --- a/src/main/java/com/onesignal/client/JSON.java +++ b/src/main/java/com/onesignal/client/JSON.java @@ -117,6 +117,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri .registerTypeAdapterFactory(new com.onesignal.client.model.CustomEvent.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.CustomEventsRequest.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.DeliveryData.CustomTypeAdapterFactory()) + .registerTypeAdapterFactory(new com.onesignal.client.model.EmailReputationResponse.CustomTypeAdapterFactory()) + .registerTypeAdapterFactory(new com.onesignal.client.model.EmailReputationWindow.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.EmailWarmUp.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.EmailWarmUpRequest.CustomTypeAdapterFactory()) .registerTypeAdapterFactory(new com.onesignal.client.model.EmailWarmUpStage.CustomTypeAdapterFactory()) diff --git a/src/main/java/com/onesignal/client/api/DefaultApi.java b/src/main/java/com/onesignal/client/api/DefaultApi.java index 12854639..28367415 100644 --- a/src/main/java/com/onesignal/client/api/DefaultApi.java +++ b/src/main/java/com/onesignal/client/api/DefaultApi.java @@ -38,6 +38,7 @@ import com.onesignal.client.model.CreateTemplateRequest; import com.onesignal.client.model.CreateUserConflictResponse; import com.onesignal.client.model.CustomEventsRequest; +import com.onesignal.client.model.EmailReputationResponse; import com.onesignal.client.model.EstimateNotificationRecipientsRequest; import com.onesignal.client.model.EstimateNotificationRecipientsSuccessResponse; import com.onesignal.client.model.ExportEventsSuccessResponse; @@ -4316,6 +4317,152 @@ public okhttp3.Call getAppsAsync(final ApiCallback> _callback) throws localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for getEmailReputation + * @param appId Your OneSignal App ID in UUID v4 format. (required) + * @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 getEmailReputationCall(String appId, 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}/email_analytics/delivery_metrics" + .replaceAll("\\{" + "app_id" + "\\}", localVarApiClient.escapeString(appId.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.15.0"); + + 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 getEmailReputationValidateBeforeCall(String appId, 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 getEmailReputation(Async)"); + } + + + okhttp3.Call localVarCall = getEmailReputationCall(appId, _callback); + return localVarCall; + + } + + /** + * Get email reputation statistics + * The email bounce and spam complaint rates received for the app over the last 24 hours, 7 days, and 30 days. Rates are expressed as fractions of successfully delivered emails (for example, `0.02` means 2%). A window reports `0` for both rates when the app has not successfully delivered any email in that period. + * @param appId Your OneSignal App ID in UUID v4 format. (required) + * @return EmailReputationResponse + * @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 EmailReputationResponse getEmailReputation(String appId) throws ApiException { + ApiResponse localVarResp = getEmailReputationWithHttpInfo(appId); + return localVarResp.getData(); + } + + /** + * Get email reputation statistics + * The email bounce and spam complaint rates received for the app over the last 24 hours, 7 days, and 30 days. Rates are expressed as fractions of successfully delivered emails (for example, `0.02` means 2%). A window reports `0` for both rates when the app has not successfully delivered any email in that period. + * @param appId Your OneSignal App ID in UUID v4 format. (required) + * @return ApiResponse<EmailReputationResponse> + * @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 getEmailReputationWithHttpInfo(String appId) throws ApiException { + okhttp3.Call localVarCall = getEmailReputationValidateBeforeCall(appId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get email reputation statistics (asynchronously) + * The email bounce and spam complaint rates received for the app over the last 24 hours, 7 days, and 30 days. Rates are expressed as fractions of successfully delivered emails (for example, `0.02` means 2%). A window reports `0` for both rates when the app has not successfully delivered any email in that period. + * @param appId Your OneSignal App ID in UUID v4 format. (required) + * @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 getEmailReputationAsync(String appId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getEmailReputationValidateBeforeCall(appId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for getNotification * @param appId (required) diff --git a/src/main/java/com/onesignal/client/model/EmailReputationResponse.java b/src/main/java/com/onesignal/client/model/EmailReputationResponse.java new file mode 100644 index 00000000..93b67ecc --- /dev/null +++ b/src/main/java/com/onesignal/client/model/EmailReputationResponse.java @@ -0,0 +1,258 @@ +/* + * OneSignal + * A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com + * + * 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.EmailReputationWindow; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +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; + +/** + * App-wide email bounce and spam complaint rates, broken out by time window. + */ +@ApiModel(description = "App-wide email bounce and spam complaint rates, broken out by time window.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class EmailReputationResponse { + private static final long serialVersionUID = 1L; + + public static final String SERIALIZED_NAME_LAST24_HOURS = "last_24_hours"; + @SerializedName(SERIALIZED_NAME_LAST24_HOURS) + private EmailReputationWindow last24Hours; + + public static final String SERIALIZED_NAME_LAST7_DAYS = "last_7_days"; + @SerializedName(SERIALIZED_NAME_LAST7_DAYS) + private EmailReputationWindow last7Days; + + public static final String SERIALIZED_NAME_LAST30_DAYS = "last_30_days"; + @SerializedName(SERIALIZED_NAME_LAST30_DAYS) + private EmailReputationWindow last30Days; + + public EmailReputationResponse() { + } + + public EmailReputationResponse last24Hours(EmailReputationWindow last24Hours) { + + this.last24Hours = last24Hours; + return this; + } + + /** + * Bounce and complaint rates for email delivered over the last 24 hours. + * @return last24Hours + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Bounce and complaint rates for email delivered over the last 24 hours.") + + public EmailReputationWindow getLast24Hours() { + return last24Hours; + } + + + public void setLast24Hours(EmailReputationWindow last24Hours) { + this.last24Hours = last24Hours; + } + + + public EmailReputationResponse last7Days(EmailReputationWindow last7Days) { + + this.last7Days = last7Days; + return this; + } + + /** + * Bounce and complaint rates for email delivered over the last 7 days. + * @return last7Days + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Bounce and complaint rates for email delivered over the last 7 days.") + + public EmailReputationWindow getLast7Days() { + return last7Days; + } + + + public void setLast7Days(EmailReputationWindow last7Days) { + this.last7Days = last7Days; + } + + + public EmailReputationResponse last30Days(EmailReputationWindow last30Days) { + + this.last30Days = last30Days; + return this; + } + + /** + * Bounce and complaint rates for email delivered over the last 30 days. + * @return last30Days + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Bounce and complaint rates for email delivered over the last 30 days.") + + public EmailReputationWindow getLast30Days() { + return last30Days; + } + + + public void setLast30Days(EmailReputationWindow last30Days) { + this.last30Days = last30Days; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EmailReputationResponse emailReputationResponse = (EmailReputationResponse) o; + return Objects.equals(this.last24Hours, emailReputationResponse.last24Hours) && + Objects.equals(this.last7Days, emailReputationResponse.last7Days) && + Objects.equals(this.last30Days, emailReputationResponse.last30Days); + } + + 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(last24Hours, last7Days, last30Days); + } + + 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 EmailReputationResponse {\n"); + sb.append(" last24Hours: ").append(toIndentedString(last24Hours)).append("\n"); + sb.append(" last7Days: ").append(toIndentedString(last7Days)).append("\n"); + sb.append(" last30Days: ").append(toIndentedString(last30Days)).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("last_24_hours"); + openapiFields.add("last_7_days"); + openapiFields.add("last_30_days"); + + // 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 (!EmailReputationResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EmailReputationResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EmailReputationResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EmailReputationResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EmailReputationResponse read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EmailReputationResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of EmailReputationResponse + * @throws IOException if the JSON string is invalid with respect to EmailReputationResponse + */ + public static EmailReputationResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EmailReputationResponse.class); + } + + /** + * Convert an instance of EmailReputationResponse 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/EmailReputationWindow.java b/src/main/java/com/onesignal/client/model/EmailReputationWindow.java new file mode 100644 index 00000000..f08ac614 --- /dev/null +++ b/src/main/java/com/onesignal/client/model/EmailReputationWindow.java @@ -0,0 +1,215 @@ +/* + * OneSignal + * A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com + * + * 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 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; + +/** + * Email reputation rates for a single time window. Each rate is a fraction of successfully delivered emails (for example, `0.02` means 2%). Both rates are `0` when no email was successfully delivered in the window. + */ +@ApiModel(description = "Email reputation rates for a single time window. Each rate is a fraction of successfully delivered emails (for example, `0.02` means 2%). Both rates are `0` when no email was successfully delivered in the window.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class EmailReputationWindow { + private static final long serialVersionUID = 1L; + + public static final String SERIALIZED_NAME_BOUNCE_RATE = "bounce_rate"; + @SerializedName(SERIALIZED_NAME_BOUNCE_RATE) + private Double bounceRate; + + public static final String SERIALIZED_NAME_COMPLAINT_RATE = "complaint_rate"; + @SerializedName(SERIALIZED_NAME_COMPLAINT_RATE) + private Double complaintRate; + + public EmailReputationWindow() { + } + + public EmailReputationWindow bounceRate(Double bounceRate) { + + this.bounceRate = bounceRate; + return this; + } + + /** + * The fraction of successfully delivered emails that hard or soft bounced during the window. + * @return bounceRate + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "0.02", value = "The fraction of successfully delivered emails that hard or soft bounced during the window.") + + public Double getBounceRate() { + return bounceRate; + } + + + public void setBounceRate(Double bounceRate) { + this.bounceRate = bounceRate; + } + + + public EmailReputationWindow complaintRate(Double complaintRate) { + + this.complaintRate = complaintRate; + return this; + } + + /** + * The fraction of successfully delivered emails that recipients reported as spam during the window. + * @return complaintRate + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "0.001", value = "The fraction of successfully delivered emails that recipients reported as spam during the window.") + + public Double getComplaintRate() { + return complaintRate; + } + + + public void setComplaintRate(Double complaintRate) { + this.complaintRate = complaintRate; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EmailReputationWindow emailReputationWindow = (EmailReputationWindow) o; + return Objects.equals(this.bounceRate, emailReputationWindow.bounceRate) && + Objects.equals(this.complaintRate, emailReputationWindow.complaintRate); + } + + @Override + public int hashCode() { + return Objects.hash(bounceRate, complaintRate); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EmailReputationWindow {\n"); + sb.append(" bounceRate: ").append(toIndentedString(bounceRate)).append("\n"); + sb.append(" complaintRate: ").append(toIndentedString(complaintRate)).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("bounce_rate"); + openapiFields.add("complaint_rate"); + + // 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 (!EmailReputationWindow.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EmailReputationWindow' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EmailReputationWindow.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EmailReputationWindow value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public EmailReputationWindow read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EmailReputationWindow given an JSON string + * + * @param jsonString JSON string + * @return An instance of EmailReputationWindow + * @throws IOException if the JSON string is invalid with respect to EmailReputationWindow + */ + public static EmailReputationWindow fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EmailReputationWindow.class); + } + + /** + * Convert an instance of EmailReputationWindow to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +