From 13f31ce2df9a5bacc941ab368ad3caf149464a42 Mon Sep 17 00:00:00 2001 From: api-librarian Date: Thu, 12 Sep 2024 14:48:56 +0000 Subject: [PATCH 1/5] Travis update: Sep 2024 (Build 796) [skip ci] --- .openapi-generator/FILES | 2 + api/openapi.yaml | 469 ++++++++++++++++++ docs/OmnimessageMessagesInner.md | 1 + docs/Viber.md | 1 + docs/ViberVideo.md | 17 + src/main/java/com/messente/JSON.java | 1 + .../api/OmnimessageMessagesInner.java | 1 + src/main/java/com/messente/api/Viber.java | 35 +- .../java/com/messente/api/ViberVideo.java | 400 +++++++++++++++ 9 files changed, 925 insertions(+), 2 deletions(-) create mode 100644 docs/ViberVideo.md create mode 100644 src/main/java/com/messente/api/ViberVideo.java diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index e068305..3c517ba 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -64,6 +64,7 @@ docs/SyncNumberLookupSuccess.md docs/Telegram.md docs/TextStore.md docs/Viber.md +docs/ViberVideo.md docs/WhatsApp.md docs/WhatsAppComponent.md docs/WhatsAppCurrency.md @@ -153,6 +154,7 @@ src/main/java/com/messente/api/SyncNumberLookupSuccess.java src/main/java/com/messente/api/Telegram.java src/main/java/com/messente/api/TextStore.java src/main/java/com/messente/api/Viber.java +src/main/java/com/messente/api/ViberVideo.java src/main/java/com/messente/api/WhatsApp.java src/main/java/com/messente/api/WhatsAppComponent.java src/main/java/com/messente/api/WhatsAppCurrency.java diff --git a/api/openapi.yaml b/api/openapi.yaml index 5945126..bcb5a4d 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -2035,6 +2035,57 @@ components: validity: 360 text: text button_text: button_text + video: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2043,6 +2094,57 @@ components: validity: 360 text: text button_text: button_text + video: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 to: to priority: low @@ -2107,6 +2209,57 @@ components: validity: 360 text: text button_text: button_text + video: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 properties: sender: @@ -2151,6 +2304,83 @@ components: enum: - viber type: string + video: + $ref: '#/components/schemas/ViberVideo' + type: object + ViberVideo: + description: Viber video object + example: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 + properties: + url: + description: URL pointing to the video resource. + type: string + thumbnail: + description: URL pointing to the video thumbnail resource. + type: string + file_size: + description: Size of the video file in bytes. Cannot be larger than 200MB. + type: integer + duration: + description: Duration of the video in seconds. Cannot be longer than 600 + seconds. + items: + $ref: '#/components/schemas/WhatsAppParameter' + type: array + required: + - duration + - file_size + - thumbnail + - url type: object WhatsApp: description: |- @@ -2262,6 +2492,10 @@ components: type: object WhatsAppCurrency: description: Whatsapp currency object. + example: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 properties: fallback_value: description: Default text if localization fails. @@ -2328,6 +2562,8 @@ components: type: object WhatsAppDatetime: description: Whatsapp datetime object. + example: + fallback_value: fallback_value properties: fallback_value: description: Default text. @@ -2337,6 +2573,11 @@ components: type: object WhatsAppMedia: description: Whatsapp media object. + example: + filename: filename + link: link + caption: caption + id: id properties: id: description: The media object ID. Do not use this field when message type @@ -2357,6 +2598,30 @@ components: type: object WhatsAppParameter: description: Whatsapp component parameter. + example: + image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type properties: type: description: Type of the parameter. @@ -2628,6 +2893,57 @@ components: validity: 360 text: text button_text: button_text + video: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2636,6 +2952,57 @@ components: validity: 360 text: text button_text: button_text + video: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 to: to priority: low @@ -2650,6 +3017,57 @@ components: validity: 360 text: text button_text: button_text + video: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2658,6 +3076,57 @@ components: validity: 360 text: text button_text: button_text + video: + duration: + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + - image: + filename: filename + link: link + caption: caption + id: id + date_time: + fallback_value: fallback_value + document: + filename: filename + link: link + caption: caption + id: id + currency: + fallback_value: fallback_value + code: code + amount_1000: amount_1000 + text: text + video: + filename: filename + link: link + caption: caption + id: id + type: type + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 to: to priority: low diff --git a/docs/OmnimessageMessagesInner.md b/docs/OmnimessageMessagesInner.md index ca6e234..9e81b34 100644 --- a/docs/OmnimessageMessagesInner.md +++ b/docs/OmnimessageMessagesInner.md @@ -15,6 +15,7 @@ |**buttonUrl** | **String** | URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) | [optional] | |**buttonText** | **String** | Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) | [optional] | |**channel** | [**ChannelEnum**](#ChannelEnum) | The channel used to deliver the message | [optional] | +|**video** | [**ViberVideo**](ViberVideo.md) | | [optional] | |**autoconvert** | [**AutoconvertEnum**](#AutoconvertEnum) | Defines how non-GSM characters will be treated: - \"on\" Use replacement settings from the account's [API Auto Replace settings page](https://dashboard.messente.com/api-settings/auto-replace) (default) - \"full\" All non GSM 03.38 characters will be replaced with suitable alternatives - \"off\" Message content is not modified in any way | [optional] | |**udh** | **String** | hex-encoded string containing SMS UDH | [optional] | |**template** | [**WhatsAppTemplate**](WhatsAppTemplate.md) | | [optional] | diff --git a/docs/Viber.md b/docs/Viber.md index 08e2a6f..3f15c85 100644 --- a/docs/Viber.md +++ b/docs/Viber.md @@ -16,6 +16,7 @@ Viber message content |**buttonUrl** | **String** | URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) | [optional] | |**buttonText** | **String** | Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) | [optional] | |**channel** | [**ChannelEnum**](#ChannelEnum) | The channel used to deliver the message | [optional] | +|**video** | [**ViberVideo**](ViberVideo.md) | | [optional] | diff --git a/docs/ViberVideo.md b/docs/ViberVideo.md new file mode 100644 index 0000000..a2fcc75 --- /dev/null +++ b/docs/ViberVideo.md @@ -0,0 +1,17 @@ + + +# ViberVideo + +Viber video object + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**url** | **String** | URL pointing to the video resource. | | +|**thumbnail** | **String** | URL pointing to the video thumbnail resource. | | +|**fileSize** | **Integer** | Size of the video file in bytes. Cannot be larger than 200MB. | | +|**duration** | [**List<WhatsAppParameter>**](WhatsAppParameter.md) | Duration of the video in seconds. Cannot be longer than 600 seconds. | | + + + diff --git a/src/main/java/com/messente/JSON.java b/src/main/java/com/messente/JSON.java index 0c3b072..1b0c0dd 100644 --- a/src/main/java/com/messente/JSON.java +++ b/src/main/java/com/messente/JSON.java @@ -140,6 +140,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.messente.api.SyncNumberLookupSuccess.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.Telegram.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.Viber.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.messente.api.ViberVideo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsApp.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppComponent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppCurrency.CustomTypeAdapterFactory()); diff --git a/src/main/java/com/messente/api/OmnimessageMessagesInner.java b/src/main/java/com/messente/api/OmnimessageMessagesInner.java index f1e02cc..fc773f0 100644 --- a/src/main/java/com/messente/api/OmnimessageMessagesInner.java +++ b/src/main/java/com/messente/api/OmnimessageMessagesInner.java @@ -22,6 +22,7 @@ import com.messente.api.SMS; import com.messente.api.Telegram; import com.messente.api.Viber; +import com.messente.api.ViberVideo; import com.messente.api.WhatsApp; import com.messente.api.WhatsAppTemplate; import java.io.IOException; diff --git a/src/main/java/com/messente/api/Viber.java b/src/main/java/com/messente/api/Viber.java index 514bf0a..95b7c53 100644 --- a/src/main/java/com/messente/api/Viber.java +++ b/src/main/java/com/messente/api/Viber.java @@ -19,6 +19,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.messente.api.ViberVideo; import java.io.IOException; import java.util.Arrays; @@ -133,6 +134,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_CHANNEL) private ChannelEnum channel = ChannelEnum.VIBER; + public static final String SERIALIZED_NAME_VIDEO = "video"; + @SerializedName(SERIALIZED_NAME_VIDEO) + private ViberVideo video; + public Viber() { } @@ -287,6 +292,25 @@ public void setChannel(ChannelEnum channel) { this.channel = channel; } + + public Viber video(ViberVideo video) { + this.video = video; + return this; + } + + /** + * Get video + * @return video + **/ + @javax.annotation.Nullable + public ViberVideo getVideo() { + return video; + } + + public void setVideo(ViberVideo video) { + this.video = video; + } + /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -349,13 +373,14 @@ public boolean equals(Object o) { Objects.equals(this.imageUrl, viber.imageUrl) && Objects.equals(this.buttonUrl, viber.buttonUrl) && Objects.equals(this.buttonText, viber.buttonText) && - Objects.equals(this.channel, viber.channel)&& + Objects.equals(this.channel, viber.channel) && + Objects.equals(this.video, viber.video)&& Objects.equals(this.additionalProperties, viber.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sender, validity, ttl, text, imageUrl, buttonUrl, buttonText, channel, additionalProperties); + return Objects.hash(sender, validity, ttl, text, imageUrl, buttonUrl, buttonText, channel, video, additionalProperties); } @Override @@ -370,6 +395,7 @@ public String toString() { sb.append(" buttonUrl: ").append(toIndentedString(buttonUrl)).append("\n"); sb.append(" buttonText: ").append(toIndentedString(buttonText)).append("\n"); sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); + sb.append(" video: ").append(toIndentedString(video)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -401,6 +427,7 @@ private String toIndentedString(Object o) { openapiFields.add("button_url"); openapiFields.add("button_text"); openapiFields.add("channel"); + openapiFields.add("video"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -441,6 +468,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("channel") != null && !jsonObj.get("channel").isJsonNull()) { ChannelEnum.validateJsonElement(jsonObj.get("channel")); } + // validate the optional field `video` + if (jsonObj.get("video") != null && !jsonObj.get("video").isJsonNull()) { + ViberVideo.validateJsonElement(jsonObj.get("video")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/com/messente/api/ViberVideo.java b/src/main/java/com/messente/api/ViberVideo.java new file mode 100644 index 0000000..f91602b --- /dev/null +++ b/src/main/java/com/messente/api/ViberVideo.java @@ -0,0 +1,400 @@ +/* + * Messente API + * [Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: messente@messente.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.messente.api; + +import java.util.Objects; +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.messente.api.WhatsAppParameter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +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 com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.messente.JSON; + +/** + * Viber video object + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class ViberVideo { + public static final String SERIALIZED_NAME_URL = "url"; + @SerializedName(SERIALIZED_NAME_URL) + private String url; + + public static final String SERIALIZED_NAME_THUMBNAIL = "thumbnail"; + @SerializedName(SERIALIZED_NAME_THUMBNAIL) + private String thumbnail; + + public static final String SERIALIZED_NAME_FILE_SIZE = "file_size"; + @SerializedName(SERIALIZED_NAME_FILE_SIZE) + private Integer fileSize; + + public static final String SERIALIZED_NAME_DURATION = "duration"; + @SerializedName(SERIALIZED_NAME_DURATION) + private List duration = new ArrayList<>(); + + public ViberVideo() { + } + + public ViberVideo url(String url) { + this.url = url; + return this; + } + + /** + * URL pointing to the video resource. + * @return url + **/ + @javax.annotation.Nonnull + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + + public ViberVideo thumbnail(String thumbnail) { + this.thumbnail = thumbnail; + return this; + } + + /** + * URL pointing to the video thumbnail resource. + * @return thumbnail + **/ + @javax.annotation.Nonnull + public String getThumbnail() { + return thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + + public ViberVideo fileSize(Integer fileSize) { + this.fileSize = fileSize; + return this; + } + + /** + * Size of the video file in bytes. Cannot be larger than 200MB. + * @return fileSize + **/ + @javax.annotation.Nonnull + public Integer getFileSize() { + return fileSize; + } + + public void setFileSize(Integer fileSize) { + this.fileSize = fileSize; + } + + + public ViberVideo duration(List duration) { + this.duration = duration; + return this; + } + + public ViberVideo addDurationItem(WhatsAppParameter durationItem) { + if (this.duration == null) { + this.duration = new ArrayList<>(); + } + this.duration.add(durationItem); + return this; + } + + /** + * Duration of the video in seconds. Cannot be longer than 600 seconds. + * @return duration + **/ + @javax.annotation.Nonnull + public List getDuration() { + return duration; + } + + public void setDuration(List duration) { + this.duration = duration; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ViberVideo instance itself + */ + public ViberVideo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ViberVideo viberVideo = (ViberVideo) o; + return Objects.equals(this.url, viberVideo.url) && + Objects.equals(this.thumbnail, viberVideo.thumbnail) && + Objects.equals(this.fileSize, viberVideo.fileSize) && + Objects.equals(this.duration, viberVideo.duration)&& + Objects.equals(this.additionalProperties, viberVideo.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(url, thumbnail, fileSize, duration, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ViberVideo {\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" thumbnail: ").append(toIndentedString(thumbnail)).append("\n"); + sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).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("url"); + openapiFields.add("thumbnail"); + openapiFields.add("file_size"); + openapiFields.add("duration"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("url"); + openapiRequiredFields.add("thumbnail"); + openapiRequiredFields.add("file_size"); + openapiRequiredFields.add("duration"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ViberVideo + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ViberVideo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ViberVideo is not found in the empty JSON string", ViberVideo.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ViberVideo.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + if (!jsonObj.get("thumbnail").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `thumbnail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thumbnail").toString())); + } + // ensure the json data is an array + if (!jsonObj.get("duration").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `duration` to be an array in the JSON string but got `%s`", jsonObj.get("duration").toString())); + } + + JsonArray jsonArrayduration = jsonObj.getAsJsonArray("duration"); + // validate the required field `duration` (array) + for (int i = 0; i < jsonArrayduration.size(); i++) { + WhatsAppParameter.validateJsonElement(jsonArrayduration.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ViberVideo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ViberVideo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ViberVideo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ViberVideo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ViberVideo read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ViberVideo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ViberVideo given an JSON string + * + * @param jsonString JSON string + * @return An instance of ViberVideo + * @throws IOException if the JSON string is invalid with respect to ViberVideo + */ + public static ViberVideo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ViberVideo.class); + } + + /** + * Convert an instance of ViberVideo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + From f836539ce14b5e8a765734779e6bfde7631f5458 Mon Sep 17 00:00:00 2001 From: api-librarian Date: Thu, 12 Sep 2024 14:50:37 +0000 Subject: [PATCH 2/5] Travis update: Sep 2024 (Build 797) [skip ci] --- README.md | 10 +++++----- build.gradle | 2 +- build.sbt | 2 +- pom.xml | 2 +- src/main/java/com/messente/ApiClient.java | 2 +- src/main/java/com/messente/Configuration.java | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d7c93df..52f335e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Messente API Library - Messente API version: 2.0.0 -- Java artifact version: 4.2.1 +- Java artifact version: 4.3.0 [Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. @@ -13,7 +13,7 @@ Install Messente API library via Maven, Gradle, Ivy or manual build. ```groovy dependencies { - implementation 'com.messente.api:messente-api:4.2.1' + implementation 'com.messente.api:messente-api:4.3.0' } ``` @@ -23,14 +23,14 @@ dependencies { com.messente.api messente-api - 4.2.1 + 4.3.0 ``` ### Ivy ```xml - + ``` ### Manual Build @@ -43,7 +43,7 @@ mvn clean package Install -- `target/messente-api-4.2.1.jar` +- `target/messente-api-4.3.0.jar` - `target/lib/*.jar` ## Features diff --git a/build.gradle b/build.gradle index cb3756b..b4adea6 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'com.messente.api' -version = '4.2.1' +version = '4.3.0' ext { jakarta_annotation_version = "1.3.5" diff --git a/build.sbt b/build.sbt index 1db1b39..b675345 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.messente.api", name := "messente-api", - version := "4.2.1", + version := "4.3.0", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/pom.xml b/pom.xml index 02ee81b..6569aac 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ messente-api jar messente-api - 4.2.1 + 4.3.0 https://github.com/messente/messente-api-java Java library for Messente API diff --git a/src/main/java/com/messente/ApiClient.java b/src/main/java/com/messente/ApiClient.java index c8b3cee..a0e85b9 100644 --- a/src/main/java/com/messente/ApiClient.java +++ b/src/main/java/com/messente/ApiClient.java @@ -141,7 +141,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/4.2.1/java"); + setUserAgent("OpenAPI-Generator/4.3.0/java"); authentications = new HashMap(); } diff --git a/src/main/java/com/messente/Configuration.java b/src/main/java/com/messente/Configuration.java index 4a71e8c..30c1863 100644 --- a/src/main/java/com/messente/Configuration.java +++ b/src/main/java/com/messente/Configuration.java @@ -15,7 +15,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") public class Configuration { - public static final String VERSION = "4.2.1"; + public static final String VERSION = "4.3.0"; private static ApiClient defaultApiClient = new ApiClient(); From fd89517464859d453cf18aa11b2b683ca513b0b3 Mon Sep 17 00:00:00 2001 From: api-librarian Date: Thu, 12 Sep 2024 15:25:53 +0000 Subject: [PATCH 3/5] Travis update: Sep 2024 (Build 798) [skip ci] --- api/openapi.yaml | 423 +----------------- docs/ViberVideo.md | 2 +- .../java/com/messente/api/ViberVideo.java | 29 +- 3 files changed, 14 insertions(+), 440 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index bcb5a4d..7f93068 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -2036,53 +2036,7 @@ components: text: text button_text: button_text video: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 @@ -2095,53 +2049,7 @@ components: text: text button_text: button_text video: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 @@ -2210,53 +2118,7 @@ components: text: text button_text: button_text video: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 @@ -2310,53 +2172,7 @@ components: ViberVideo: description: Viber video object example: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 @@ -2373,9 +2189,7 @@ components: duration: description: Duration of the video in seconds. Cannot be longer than 600 seconds. - items: - $ref: '#/components/schemas/WhatsAppParameter' - type: array + type: integer required: - duration - file_size @@ -2492,10 +2306,6 @@ components: type: object WhatsAppCurrency: description: Whatsapp currency object. - example: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 properties: fallback_value: description: Default text if localization fails. @@ -2562,8 +2372,6 @@ components: type: object WhatsAppDatetime: description: Whatsapp datetime object. - example: - fallback_value: fallback_value properties: fallback_value: description: Default text. @@ -2573,11 +2381,6 @@ components: type: object WhatsAppMedia: description: Whatsapp media object. - example: - filename: filename - link: link - caption: caption - id: id properties: id: description: The media object ID. Do not use this field when message type @@ -2598,30 +2401,6 @@ components: type: object WhatsAppParameter: description: Whatsapp component parameter. - example: - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type properties: type: description: Type of the parameter. @@ -2894,53 +2673,7 @@ components: text: text button_text: button_text video: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 @@ -2953,53 +2686,7 @@ components: text: text button_text: button_text video: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 @@ -3018,53 +2705,7 @@ components: text: text button_text: button_text video: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 @@ -3077,53 +2718,7 @@ components: text: text button_text: button_text video: - duration: - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type - - image: - filename: filename - link: link - caption: caption - id: id - date_time: - fallback_value: fallback_value - document: - filename: filename - link: link - caption: caption - id: id - currency: - fallback_value: fallback_value - code: code - amount_1000: amount_1000 - text: text - video: - filename: filename - link: link - caption: caption - id: id - type: type + duration: 6 thumbnail: thumbnail url: url file_size: 0 diff --git a/docs/ViberVideo.md b/docs/ViberVideo.md index a2fcc75..17187ed 100644 --- a/docs/ViberVideo.md +++ b/docs/ViberVideo.md @@ -11,7 +11,7 @@ Viber video object |**url** | **String** | URL pointing to the video resource. | | |**thumbnail** | **String** | URL pointing to the video thumbnail resource. | | |**fileSize** | **Integer** | Size of the video file in bytes. Cannot be larger than 200MB. | | -|**duration** | [**List<WhatsAppParameter>**](WhatsAppParameter.md) | Duration of the video in seconds. Cannot be longer than 600 seconds. | | +|**duration** | **Integer** | Duration of the video in seconds. Cannot be longer than 600 seconds. | | diff --git a/src/main/java/com/messente/api/ViberVideo.java b/src/main/java/com/messente/api/ViberVideo.java index f91602b..bfb42e8 100644 --- a/src/main/java/com/messente/api/ViberVideo.java +++ b/src/main/java/com/messente/api/ViberVideo.java @@ -19,11 +19,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.messente.api.WhatsAppParameter; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -68,7 +65,7 @@ public class ViberVideo { public static final String SERIALIZED_NAME_DURATION = "duration"; @SerializedName(SERIALIZED_NAME_DURATION) - private List duration = new ArrayList<>(); + private Integer duration; public ViberVideo() { } @@ -130,29 +127,21 @@ public void setFileSize(Integer fileSize) { } - public ViberVideo duration(List duration) { + public ViberVideo duration(Integer duration) { this.duration = duration; return this; } - public ViberVideo addDurationItem(WhatsAppParameter durationItem) { - if (this.duration == null) { - this.duration = new ArrayList<>(); - } - this.duration.add(durationItem); - return this; - } - /** * Duration of the video in seconds. Cannot be longer than 600 seconds. * @return duration **/ @javax.annotation.Nonnull - public List getDuration() { + public Integer getDuration() { return duration; } - public void setDuration(List duration) { + public void setDuration(Integer duration) { this.duration = duration; } @@ -293,16 +282,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("thumbnail").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `thumbnail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thumbnail").toString())); } - // ensure the json data is an array - if (!jsonObj.get("duration").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `duration` to be an array in the JSON string but got `%s`", jsonObj.get("duration").toString())); - } - - JsonArray jsonArrayduration = jsonObj.getAsJsonArray("duration"); - // validate the required field `duration` (array) - for (int i = 0; i < jsonArrayduration.size(); i++) { - WhatsAppParameter.validateJsonElement(jsonArrayduration.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { From a73cbba9582ee5961a592adb4e759162dee85acb Mon Sep 17 00:00:00 2001 From: api-librarian Date: Thu, 12 Sep 2024 15:39:58 +0000 Subject: [PATCH 4/5] Travis update: Sep 2024 (Build 799) [skip ci] --- .openapi-generator/FILES | 2 - README.md | 10 +- api/openapi.yaml | 64 --- build.gradle | 2 +- build.sbt | 2 +- docs/OmnimessageMessagesInner.md | 1 - docs/Viber.md | 1 - docs/ViberVideo.md | 17 - pom.xml | 2 +- src/main/java/com/messente/ApiClient.java | 2 +- src/main/java/com/messente/Configuration.java | 2 +- src/main/java/com/messente/JSON.java | 1 - .../api/OmnimessageMessagesInner.java | 1 - src/main/java/com/messente/api/Viber.java | 35 +- .../java/com/messente/api/ViberVideo.java | 379 ------------------ 15 files changed, 12 insertions(+), 509 deletions(-) delete mode 100644 docs/ViberVideo.md delete mode 100644 src/main/java/com/messente/api/ViberVideo.java diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 3c517ba..e068305 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -64,7 +64,6 @@ docs/SyncNumberLookupSuccess.md docs/Telegram.md docs/TextStore.md docs/Viber.md -docs/ViberVideo.md docs/WhatsApp.md docs/WhatsAppComponent.md docs/WhatsAppCurrency.md @@ -154,7 +153,6 @@ src/main/java/com/messente/api/SyncNumberLookupSuccess.java src/main/java/com/messente/api/Telegram.java src/main/java/com/messente/api/TextStore.java src/main/java/com/messente/api/Viber.java -src/main/java/com/messente/api/ViberVideo.java src/main/java/com/messente/api/WhatsApp.java src/main/java/com/messente/api/WhatsAppComponent.java src/main/java/com/messente/api/WhatsAppCurrency.java diff --git a/README.md b/README.md index 52f335e..d7c93df 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Messente API Library - Messente API version: 2.0.0 -- Java artifact version: 4.3.0 +- Java artifact version: 4.2.1 [Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. @@ -13,7 +13,7 @@ Install Messente API library via Maven, Gradle, Ivy or manual build. ```groovy dependencies { - implementation 'com.messente.api:messente-api:4.3.0' + implementation 'com.messente.api:messente-api:4.2.1' } ``` @@ -23,14 +23,14 @@ dependencies { com.messente.api messente-api - 4.3.0 + 4.2.1 ``` ### Ivy ```xml - + ``` ### Manual Build @@ -43,7 +43,7 @@ mvn clean package Install -- `target/messente-api-4.3.0.jar` +- `target/messente-api-4.2.1.jar` - `target/lib/*.jar` ## Features diff --git a/api/openapi.yaml b/api/openapi.yaml index 7f93068..5945126 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -2035,11 +2035,6 @@ components: validity: 360 text: text button_text: button_text - video: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2048,11 +2043,6 @@ components: validity: 360 text: text button_text: button_text - video: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 ttl: 21600 to: to priority: low @@ -2117,11 +2107,6 @@ components: validity: 360 text: text button_text: button_text - video: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 ttl: 21600 properties: sender: @@ -2166,35 +2151,6 @@ components: enum: - viber type: string - video: - $ref: '#/components/schemas/ViberVideo' - type: object - ViberVideo: - description: Viber video object - example: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 - properties: - url: - description: URL pointing to the video resource. - type: string - thumbnail: - description: URL pointing to the video thumbnail resource. - type: string - file_size: - description: Size of the video file in bytes. Cannot be larger than 200MB. - type: integer - duration: - description: Duration of the video in seconds. Cannot be longer than 600 - seconds. - type: integer - required: - - duration - - file_size - - thumbnail - - url type: object WhatsApp: description: |- @@ -2672,11 +2628,6 @@ components: validity: 360 text: text button_text: button_text - video: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2685,11 +2636,6 @@ components: validity: 360 text: text button_text: button_text - video: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 ttl: 21600 to: to priority: low @@ -2704,11 +2650,6 @@ components: validity: 360 text: text button_text: button_text - video: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2717,11 +2658,6 @@ components: validity: 360 text: text button_text: button_text - video: - duration: 6 - thumbnail: thumbnail - url: url - file_size: 0 ttl: 21600 to: to priority: low diff --git a/build.gradle b/build.gradle index b4adea6..cb3756b 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'com.messente.api' -version = '4.3.0' +version = '4.2.1' ext { jakarta_annotation_version = "1.3.5" diff --git a/build.sbt b/build.sbt index b675345..1db1b39 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.messente.api", name := "messente-api", - version := "4.3.0", + version := "4.2.1", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/docs/OmnimessageMessagesInner.md b/docs/OmnimessageMessagesInner.md index 9e81b34..ca6e234 100644 --- a/docs/OmnimessageMessagesInner.md +++ b/docs/OmnimessageMessagesInner.md @@ -15,7 +15,6 @@ |**buttonUrl** | **String** | URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) | [optional] | |**buttonText** | **String** | Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) | [optional] | |**channel** | [**ChannelEnum**](#ChannelEnum) | The channel used to deliver the message | [optional] | -|**video** | [**ViberVideo**](ViberVideo.md) | | [optional] | |**autoconvert** | [**AutoconvertEnum**](#AutoconvertEnum) | Defines how non-GSM characters will be treated: - \"on\" Use replacement settings from the account's [API Auto Replace settings page](https://dashboard.messente.com/api-settings/auto-replace) (default) - \"full\" All non GSM 03.38 characters will be replaced with suitable alternatives - \"off\" Message content is not modified in any way | [optional] | |**udh** | **String** | hex-encoded string containing SMS UDH | [optional] | |**template** | [**WhatsAppTemplate**](WhatsAppTemplate.md) | | [optional] | diff --git a/docs/Viber.md b/docs/Viber.md index 3f15c85..08e2a6f 100644 --- a/docs/Viber.md +++ b/docs/Viber.md @@ -16,7 +16,6 @@ Viber message content |**buttonUrl** | **String** | URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) | [optional] | |**buttonText** | **String** | Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) | [optional] | |**channel** | [**ChannelEnum**](#ChannelEnum) | The channel used to deliver the message | [optional] | -|**video** | [**ViberVideo**](ViberVideo.md) | | [optional] | diff --git a/docs/ViberVideo.md b/docs/ViberVideo.md deleted file mode 100644 index 17187ed..0000000 --- a/docs/ViberVideo.md +++ /dev/null @@ -1,17 +0,0 @@ - - -# ViberVideo - -Viber video object - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**url** | **String** | URL pointing to the video resource. | | -|**thumbnail** | **String** | URL pointing to the video thumbnail resource. | | -|**fileSize** | **Integer** | Size of the video file in bytes. Cannot be larger than 200MB. | | -|**duration** | **Integer** | Duration of the video in seconds. Cannot be longer than 600 seconds. | | - - - diff --git a/pom.xml b/pom.xml index 6569aac..02ee81b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ messente-api jar messente-api - 4.3.0 + 4.2.1 https://github.com/messente/messente-api-java Java library for Messente API diff --git a/src/main/java/com/messente/ApiClient.java b/src/main/java/com/messente/ApiClient.java index a0e85b9..c8b3cee 100644 --- a/src/main/java/com/messente/ApiClient.java +++ b/src/main/java/com/messente/ApiClient.java @@ -141,7 +141,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/4.3.0/java"); + setUserAgent("OpenAPI-Generator/4.2.1/java"); authentications = new HashMap(); } diff --git a/src/main/java/com/messente/Configuration.java b/src/main/java/com/messente/Configuration.java index 30c1863..4a71e8c 100644 --- a/src/main/java/com/messente/Configuration.java +++ b/src/main/java/com/messente/Configuration.java @@ -15,7 +15,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") public class Configuration { - public static final String VERSION = "4.3.0"; + public static final String VERSION = "4.2.1"; private static ApiClient defaultApiClient = new ApiClient(); diff --git a/src/main/java/com/messente/JSON.java b/src/main/java/com/messente/JSON.java index 1b0c0dd..0c3b072 100644 --- a/src/main/java/com/messente/JSON.java +++ b/src/main/java/com/messente/JSON.java @@ -140,7 +140,6 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.messente.api.SyncNumberLookupSuccess.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.Telegram.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.Viber.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.messente.api.ViberVideo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsApp.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppComponent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppCurrency.CustomTypeAdapterFactory()); diff --git a/src/main/java/com/messente/api/OmnimessageMessagesInner.java b/src/main/java/com/messente/api/OmnimessageMessagesInner.java index fc773f0..f1e02cc 100644 --- a/src/main/java/com/messente/api/OmnimessageMessagesInner.java +++ b/src/main/java/com/messente/api/OmnimessageMessagesInner.java @@ -22,7 +22,6 @@ import com.messente.api.SMS; import com.messente.api.Telegram; import com.messente.api.Viber; -import com.messente.api.ViberVideo; import com.messente.api.WhatsApp; import com.messente.api.WhatsAppTemplate; import java.io.IOException; diff --git a/src/main/java/com/messente/api/Viber.java b/src/main/java/com/messente/api/Viber.java index 95b7c53..514bf0a 100644 --- a/src/main/java/com/messente/api/Viber.java +++ b/src/main/java/com/messente/api/Viber.java @@ -19,7 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.messente.api.ViberVideo; import java.io.IOException; import java.util.Arrays; @@ -134,10 +133,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_CHANNEL) private ChannelEnum channel = ChannelEnum.VIBER; - public static final String SERIALIZED_NAME_VIDEO = "video"; - @SerializedName(SERIALIZED_NAME_VIDEO) - private ViberVideo video; - public Viber() { } @@ -292,25 +287,6 @@ public void setChannel(ChannelEnum channel) { this.channel = channel; } - - public Viber video(ViberVideo video) { - this.video = video; - return this; - } - - /** - * Get video - * @return video - **/ - @javax.annotation.Nullable - public ViberVideo getVideo() { - return video; - } - - public void setVideo(ViberVideo video) { - this.video = video; - } - /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -373,14 +349,13 @@ public boolean equals(Object o) { Objects.equals(this.imageUrl, viber.imageUrl) && Objects.equals(this.buttonUrl, viber.buttonUrl) && Objects.equals(this.buttonText, viber.buttonText) && - Objects.equals(this.channel, viber.channel) && - Objects.equals(this.video, viber.video)&& + Objects.equals(this.channel, viber.channel)&& Objects.equals(this.additionalProperties, viber.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sender, validity, ttl, text, imageUrl, buttonUrl, buttonText, channel, video, additionalProperties); + return Objects.hash(sender, validity, ttl, text, imageUrl, buttonUrl, buttonText, channel, additionalProperties); } @Override @@ -395,7 +370,6 @@ public String toString() { sb.append(" buttonUrl: ").append(toIndentedString(buttonUrl)).append("\n"); sb.append(" buttonText: ").append(toIndentedString(buttonText)).append("\n"); sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); - sb.append(" video: ").append(toIndentedString(video)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -427,7 +401,6 @@ private String toIndentedString(Object o) { openapiFields.add("button_url"); openapiFields.add("button_text"); openapiFields.add("channel"); - openapiFields.add("video"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -468,10 +441,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("channel") != null && !jsonObj.get("channel").isJsonNull()) { ChannelEnum.validateJsonElement(jsonObj.get("channel")); } - // validate the optional field `video` - if (jsonObj.get("video") != null && !jsonObj.get("video").isJsonNull()) { - ViberVideo.validateJsonElement(jsonObj.get("video")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/com/messente/api/ViberVideo.java b/src/main/java/com/messente/api/ViberVideo.java deleted file mode 100644 index bfb42e8..0000000 --- a/src/main/java/com/messente/api/ViberVideo.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Messente API - * [Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. - * - * The version of the OpenAPI document: 2.0.0 - * Contact: messente@messente.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.messente.api; - -import java.util.Objects; -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 java.io.IOException; -import java.util.Arrays; - -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 com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.messente.JSON; - -/** - * Viber video object - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") -public class ViberVideo { - public static final String SERIALIZED_NAME_URL = "url"; - @SerializedName(SERIALIZED_NAME_URL) - private String url; - - public static final String SERIALIZED_NAME_THUMBNAIL = "thumbnail"; - @SerializedName(SERIALIZED_NAME_THUMBNAIL) - private String thumbnail; - - public static final String SERIALIZED_NAME_FILE_SIZE = "file_size"; - @SerializedName(SERIALIZED_NAME_FILE_SIZE) - private Integer fileSize; - - public static final String SERIALIZED_NAME_DURATION = "duration"; - @SerializedName(SERIALIZED_NAME_DURATION) - private Integer duration; - - public ViberVideo() { - } - - public ViberVideo url(String url) { - this.url = url; - return this; - } - - /** - * URL pointing to the video resource. - * @return url - **/ - @javax.annotation.Nonnull - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - - public ViberVideo thumbnail(String thumbnail) { - this.thumbnail = thumbnail; - return this; - } - - /** - * URL pointing to the video thumbnail resource. - * @return thumbnail - **/ - @javax.annotation.Nonnull - public String getThumbnail() { - return thumbnail; - } - - public void setThumbnail(String thumbnail) { - this.thumbnail = thumbnail; - } - - - public ViberVideo fileSize(Integer fileSize) { - this.fileSize = fileSize; - return this; - } - - /** - * Size of the video file in bytes. Cannot be larger than 200MB. - * @return fileSize - **/ - @javax.annotation.Nonnull - public Integer getFileSize() { - return fileSize; - } - - public void setFileSize(Integer fileSize) { - this.fileSize = fileSize; - } - - - public ViberVideo duration(Integer duration) { - this.duration = duration; - return this; - } - - /** - * Duration of the video in seconds. Cannot be longer than 600 seconds. - * @return duration - **/ - @javax.annotation.Nonnull - public Integer getDuration() { - return duration; - } - - public void setDuration(Integer duration) { - this.duration = duration; - } - - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ViberVideo instance itself - */ - public ViberVideo putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ViberVideo viberVideo = (ViberVideo) o; - return Objects.equals(this.url, viberVideo.url) && - Objects.equals(this.thumbnail, viberVideo.thumbnail) && - Objects.equals(this.fileSize, viberVideo.fileSize) && - Objects.equals(this.duration, viberVideo.duration)&& - Objects.equals(this.additionalProperties, viberVideo.additionalProperties); - } - - @Override - public int hashCode() { - return Objects.hash(url, thumbnail, fileSize, duration, additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ViberVideo {\n"); - sb.append(" url: ").append(toIndentedString(url)).append("\n"); - sb.append(" thumbnail: ").append(toIndentedString(thumbnail)).append("\n"); - sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); - sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).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("url"); - openapiFields.add("thumbnail"); - openapiFields.add("file_size"); - openapiFields.add("duration"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("url"); - openapiRequiredFields.add("thumbnail"); - openapiRequiredFields.add("file_size"); - openapiRequiredFields.add("duration"); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ViberVideo - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!ViberVideo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in ViberVideo is not found in the empty JSON string", ViberVideo.openapiRequiredFields.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ViberVideo.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (!jsonObj.get("url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); - } - if (!jsonObj.get("thumbnail").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `thumbnail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thumbnail").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ViberVideo.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ViberVideo' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ViberVideo.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, ViberVideo value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } - elementAdapter.write(out, obj); - } - - @Override - public ViberVideo read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ViberVideo instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - - }.nullSafe(); - } - } - - /** - * Create an instance of ViberVideo given an JSON string - * - * @param jsonString JSON string - * @return An instance of ViberVideo - * @throws IOException if the JSON string is invalid with respect to ViberVideo - */ - public static ViberVideo fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ViberVideo.class); - } - - /** - * Convert an instance of ViberVideo to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - From 645c9789f8e0177008736e92f61ee68fa1aeb808 Mon Sep 17 00:00:00 2001 From: api-librarian Date: Thu, 12 Sep 2024 16:00:15 +0000 Subject: [PATCH 5/5] Travis update: Sep 2024 (Build 801) [skip ci] --- .openapi-generator/FILES | 2 + README.md | 10 +- api/openapi.yaml | 64 +++ build.gradle | 2 +- build.sbt | 2 +- docs/OmnimessageMessagesInner.md | 1 + docs/Viber.md | 1 + docs/ViberVideo.md | 17 + pom.xml | 2 +- src/main/java/com/messente/ApiClient.java | 2 +- src/main/java/com/messente/Configuration.java | 2 +- src/main/java/com/messente/JSON.java | 1 + .../api/OmnimessageMessagesInner.java | 1 + src/main/java/com/messente/api/Viber.java | 35 +- .../java/com/messente/api/ViberVideo.java | 379 ++++++++++++++++++ 15 files changed, 509 insertions(+), 12 deletions(-) create mode 100644 docs/ViberVideo.md create mode 100644 src/main/java/com/messente/api/ViberVideo.java diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index e068305..3c517ba 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -64,6 +64,7 @@ docs/SyncNumberLookupSuccess.md docs/Telegram.md docs/TextStore.md docs/Viber.md +docs/ViberVideo.md docs/WhatsApp.md docs/WhatsAppComponent.md docs/WhatsAppCurrency.md @@ -153,6 +154,7 @@ src/main/java/com/messente/api/SyncNumberLookupSuccess.java src/main/java/com/messente/api/Telegram.java src/main/java/com/messente/api/TextStore.java src/main/java/com/messente/api/Viber.java +src/main/java/com/messente/api/ViberVideo.java src/main/java/com/messente/api/WhatsApp.java src/main/java/com/messente/api/WhatsAppComponent.java src/main/java/com/messente/api/WhatsAppCurrency.java diff --git a/README.md b/README.md index d7c93df..52f335e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Messente API Library - Messente API version: 2.0.0 -- Java artifact version: 4.2.1 +- Java artifact version: 4.3.0 [Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. @@ -13,7 +13,7 @@ Install Messente API library via Maven, Gradle, Ivy or manual build. ```groovy dependencies { - implementation 'com.messente.api:messente-api:4.2.1' + implementation 'com.messente.api:messente-api:4.3.0' } ``` @@ -23,14 +23,14 @@ dependencies { com.messente.api messente-api - 4.2.1 + 4.3.0 ``` ### Ivy ```xml - + ``` ### Manual Build @@ -43,7 +43,7 @@ mvn clean package Install -- `target/messente-api-4.2.1.jar` +- `target/messente-api-4.3.0.jar` - `target/lib/*.jar` ## Features diff --git a/api/openapi.yaml b/api/openapi.yaml index 5945126..7f93068 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -2035,6 +2035,11 @@ components: validity: 360 text: text button_text: button_text + video: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2043,6 +2048,11 @@ components: validity: 360 text: text button_text: button_text + video: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 to: to priority: low @@ -2107,6 +2117,11 @@ components: validity: 360 text: text button_text: button_text + video: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 properties: sender: @@ -2151,6 +2166,35 @@ components: enum: - viber type: string + video: + $ref: '#/components/schemas/ViberVideo' + type: object + ViberVideo: + description: Viber video object + example: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 + properties: + url: + description: URL pointing to the video resource. + type: string + thumbnail: + description: URL pointing to the video thumbnail resource. + type: string + file_size: + description: Size of the video file in bytes. Cannot be larger than 200MB. + type: integer + duration: + description: Duration of the video in seconds. Cannot be longer than 600 + seconds. + type: integer + required: + - duration + - file_size + - thumbnail + - url type: object WhatsApp: description: |- @@ -2628,6 +2672,11 @@ components: validity: 360 text: text button_text: button_text + video: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2636,6 +2685,11 @@ components: validity: 360 text: text button_text: button_text + video: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 to: to priority: low @@ -2650,6 +2704,11 @@ components: validity: 360 text: text button_text: button_text + video: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 - sender: sender image_url: image_url @@ -2658,6 +2717,11 @@ components: validity: 360 text: text button_text: button_text + video: + duration: 6 + thumbnail: thumbnail + url: url + file_size: 0 ttl: 21600 to: to priority: low diff --git a/build.gradle b/build.gradle index cb3756b..b4adea6 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'com.messente.api' -version = '4.2.1' +version = '4.3.0' ext { jakarta_annotation_version = "1.3.5" diff --git a/build.sbt b/build.sbt index 1db1b39..b675345 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.messente.api", name := "messente-api", - version := "4.2.1", + version := "4.3.0", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/docs/OmnimessageMessagesInner.md b/docs/OmnimessageMessagesInner.md index ca6e234..9e81b34 100644 --- a/docs/OmnimessageMessagesInner.md +++ b/docs/OmnimessageMessagesInner.md @@ -15,6 +15,7 @@ |**buttonUrl** | **String** | URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) | [optional] | |**buttonText** | **String** | Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) | [optional] | |**channel** | [**ChannelEnum**](#ChannelEnum) | The channel used to deliver the message | [optional] | +|**video** | [**ViberVideo**](ViberVideo.md) | | [optional] | |**autoconvert** | [**AutoconvertEnum**](#AutoconvertEnum) | Defines how non-GSM characters will be treated: - \"on\" Use replacement settings from the account's [API Auto Replace settings page](https://dashboard.messente.com/api-settings/auto-replace) (default) - \"full\" All non GSM 03.38 characters will be replaced with suitable alternatives - \"off\" Message content is not modified in any way | [optional] | |**udh** | **String** | hex-encoded string containing SMS UDH | [optional] | |**template** | [**WhatsAppTemplate**](WhatsAppTemplate.md) | | [optional] | diff --git a/docs/Viber.md b/docs/Viber.md index 08e2a6f..3f15c85 100644 --- a/docs/Viber.md +++ b/docs/Viber.md @@ -16,6 +16,7 @@ Viber message content |**buttonUrl** | **String** | URL of the button, must be specified along with ''text'', ''button_text'' and ''image_url'' (optional) | [optional] | |**buttonText** | **String** | Must be specified along with ''text'', ''button_url'', ''button_text'', ''image_url'' (optional) | [optional] | |**channel** | [**ChannelEnum**](#ChannelEnum) | The channel used to deliver the message | [optional] | +|**video** | [**ViberVideo**](ViberVideo.md) | | [optional] | diff --git a/docs/ViberVideo.md b/docs/ViberVideo.md new file mode 100644 index 0000000..17187ed --- /dev/null +++ b/docs/ViberVideo.md @@ -0,0 +1,17 @@ + + +# ViberVideo + +Viber video object + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**url** | **String** | URL pointing to the video resource. | | +|**thumbnail** | **String** | URL pointing to the video thumbnail resource. | | +|**fileSize** | **Integer** | Size of the video file in bytes. Cannot be larger than 200MB. | | +|**duration** | **Integer** | Duration of the video in seconds. Cannot be longer than 600 seconds. | | + + + diff --git a/pom.xml b/pom.xml index 02ee81b..6569aac 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ messente-api jar messente-api - 4.2.1 + 4.3.0 https://github.com/messente/messente-api-java Java library for Messente API diff --git a/src/main/java/com/messente/ApiClient.java b/src/main/java/com/messente/ApiClient.java index c8b3cee..a0e85b9 100644 --- a/src/main/java/com/messente/ApiClient.java +++ b/src/main/java/com/messente/ApiClient.java @@ -141,7 +141,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/4.2.1/java"); + setUserAgent("OpenAPI-Generator/4.3.0/java"); authentications = new HashMap(); } diff --git a/src/main/java/com/messente/Configuration.java b/src/main/java/com/messente/Configuration.java index 4a71e8c..30c1863 100644 --- a/src/main/java/com/messente/Configuration.java +++ b/src/main/java/com/messente/Configuration.java @@ -15,7 +15,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") public class Configuration { - public static final String VERSION = "4.2.1"; + public static final String VERSION = "4.3.0"; private static ApiClient defaultApiClient = new ApiClient(); diff --git a/src/main/java/com/messente/JSON.java b/src/main/java/com/messente/JSON.java index 0c3b072..1b0c0dd 100644 --- a/src/main/java/com/messente/JSON.java +++ b/src/main/java/com/messente/JSON.java @@ -140,6 +140,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.messente.api.SyncNumberLookupSuccess.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.Telegram.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.Viber.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.messente.api.ViberVideo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsApp.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppComponent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppCurrency.CustomTypeAdapterFactory()); diff --git a/src/main/java/com/messente/api/OmnimessageMessagesInner.java b/src/main/java/com/messente/api/OmnimessageMessagesInner.java index f1e02cc..fc773f0 100644 --- a/src/main/java/com/messente/api/OmnimessageMessagesInner.java +++ b/src/main/java/com/messente/api/OmnimessageMessagesInner.java @@ -22,6 +22,7 @@ import com.messente.api.SMS; import com.messente.api.Telegram; import com.messente.api.Viber; +import com.messente.api.ViberVideo; import com.messente.api.WhatsApp; import com.messente.api.WhatsAppTemplate; import java.io.IOException; diff --git a/src/main/java/com/messente/api/Viber.java b/src/main/java/com/messente/api/Viber.java index 514bf0a..95b7c53 100644 --- a/src/main/java/com/messente/api/Viber.java +++ b/src/main/java/com/messente/api/Viber.java @@ -19,6 +19,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.messente.api.ViberVideo; import java.io.IOException; import java.util.Arrays; @@ -133,6 +134,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_CHANNEL) private ChannelEnum channel = ChannelEnum.VIBER; + public static final String SERIALIZED_NAME_VIDEO = "video"; + @SerializedName(SERIALIZED_NAME_VIDEO) + private ViberVideo video; + public Viber() { } @@ -287,6 +292,25 @@ public void setChannel(ChannelEnum channel) { this.channel = channel; } + + public Viber video(ViberVideo video) { + this.video = video; + return this; + } + + /** + * Get video + * @return video + **/ + @javax.annotation.Nullable + public ViberVideo getVideo() { + return video; + } + + public void setVideo(ViberVideo video) { + this.video = video; + } + /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -349,13 +373,14 @@ public boolean equals(Object o) { Objects.equals(this.imageUrl, viber.imageUrl) && Objects.equals(this.buttonUrl, viber.buttonUrl) && Objects.equals(this.buttonText, viber.buttonText) && - Objects.equals(this.channel, viber.channel)&& + Objects.equals(this.channel, viber.channel) && + Objects.equals(this.video, viber.video)&& Objects.equals(this.additionalProperties, viber.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sender, validity, ttl, text, imageUrl, buttonUrl, buttonText, channel, additionalProperties); + return Objects.hash(sender, validity, ttl, text, imageUrl, buttonUrl, buttonText, channel, video, additionalProperties); } @Override @@ -370,6 +395,7 @@ public String toString() { sb.append(" buttonUrl: ").append(toIndentedString(buttonUrl)).append("\n"); sb.append(" buttonText: ").append(toIndentedString(buttonText)).append("\n"); sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); + sb.append(" video: ").append(toIndentedString(video)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -401,6 +427,7 @@ private String toIndentedString(Object o) { openapiFields.add("button_url"); openapiFields.add("button_text"); openapiFields.add("channel"); + openapiFields.add("video"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -441,6 +468,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("channel") != null && !jsonObj.get("channel").isJsonNull()) { ChannelEnum.validateJsonElement(jsonObj.get("channel")); } + // validate the optional field `video` + if (jsonObj.get("video") != null && !jsonObj.get("video").isJsonNull()) { + ViberVideo.validateJsonElement(jsonObj.get("video")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/com/messente/api/ViberVideo.java b/src/main/java/com/messente/api/ViberVideo.java new file mode 100644 index 0000000..bfb42e8 --- /dev/null +++ b/src/main/java/com/messente/api/ViberVideo.java @@ -0,0 +1,379 @@ +/* + * Messente API + * [Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: messente@messente.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.messente.api; + +import java.util.Objects; +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 java.io.IOException; +import java.util.Arrays; + +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 com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.messente.JSON; + +/** + * Viber video object + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class ViberVideo { + public static final String SERIALIZED_NAME_URL = "url"; + @SerializedName(SERIALIZED_NAME_URL) + private String url; + + public static final String SERIALIZED_NAME_THUMBNAIL = "thumbnail"; + @SerializedName(SERIALIZED_NAME_THUMBNAIL) + private String thumbnail; + + public static final String SERIALIZED_NAME_FILE_SIZE = "file_size"; + @SerializedName(SERIALIZED_NAME_FILE_SIZE) + private Integer fileSize; + + public static final String SERIALIZED_NAME_DURATION = "duration"; + @SerializedName(SERIALIZED_NAME_DURATION) + private Integer duration; + + public ViberVideo() { + } + + public ViberVideo url(String url) { + this.url = url; + return this; + } + + /** + * URL pointing to the video resource. + * @return url + **/ + @javax.annotation.Nonnull + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + + public ViberVideo thumbnail(String thumbnail) { + this.thumbnail = thumbnail; + return this; + } + + /** + * URL pointing to the video thumbnail resource. + * @return thumbnail + **/ + @javax.annotation.Nonnull + public String getThumbnail() { + return thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + + public ViberVideo fileSize(Integer fileSize) { + this.fileSize = fileSize; + return this; + } + + /** + * Size of the video file in bytes. Cannot be larger than 200MB. + * @return fileSize + **/ + @javax.annotation.Nonnull + public Integer getFileSize() { + return fileSize; + } + + public void setFileSize(Integer fileSize) { + this.fileSize = fileSize; + } + + + public ViberVideo duration(Integer duration) { + this.duration = duration; + return this; + } + + /** + * Duration of the video in seconds. Cannot be longer than 600 seconds. + * @return duration + **/ + @javax.annotation.Nonnull + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ViberVideo instance itself + */ + public ViberVideo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ViberVideo viberVideo = (ViberVideo) o; + return Objects.equals(this.url, viberVideo.url) && + Objects.equals(this.thumbnail, viberVideo.thumbnail) && + Objects.equals(this.fileSize, viberVideo.fileSize) && + Objects.equals(this.duration, viberVideo.duration)&& + Objects.equals(this.additionalProperties, viberVideo.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(url, thumbnail, fileSize, duration, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ViberVideo {\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" thumbnail: ").append(toIndentedString(thumbnail)).append("\n"); + sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).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("url"); + openapiFields.add("thumbnail"); + openapiFields.add("file_size"); + openapiFields.add("duration"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("url"); + openapiRequiredFields.add("thumbnail"); + openapiRequiredFields.add("file_size"); + openapiRequiredFields.add("duration"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ViberVideo + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ViberVideo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ViberVideo is not found in the empty JSON string", ViberVideo.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ViberVideo.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + } + if (!jsonObj.get("thumbnail").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `thumbnail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("thumbnail").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ViberVideo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ViberVideo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ViberVideo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ViberVideo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ViberVideo read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ViberVideo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ViberVideo given an JSON string + * + * @param jsonString JSON string + * @return An instance of ViberVideo + * @throws IOException if the JSON string is invalid with respect to ViberVideo + */ + public static ViberVideo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ViberVideo.class); + } + + /** + * Convert an instance of ViberVideo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +