diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index 30cff58..0000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
-# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
-#
-# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)
-
-name: Java CI with Maven
-
-on:
- push:
- branches: [ main, master ]
- pull_request:
- branches: [ main, master ]
-
-jobs:
- build:
- name: Build Messente API
- runs-on: ubuntu-latest
- strategy:
- matrix:
- java: [ 17, 21 ]
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK
- uses: actions/setup-java@v4
- with:
- java-version: ${{ matrix.java }}
- distribution: 'temurin'
- cache: maven
- - name: Build with Maven
- run: mvn -B package --no-transfer-progress --file pom.xml
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000..752daed
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,23 @@
+name: Publish package to the Maven Central Repository
+on:
+ push:
+ tags:
+ - *
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Java
+ uses: actions/setup-java@v4
+ with:
+ java-version: '11'
+ distribution: 'temurin'
+
+ - name: Publish Artifacts
+ env:
+ ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
+ ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
+ ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.PGP_SECRET }}
+ ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PGP_PASSPHRASE }}
+ run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-configuration-cache --no-daemon
diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES
index 3c517ba..e2401ef 100644
--- a/.openapi-generator/FILES
+++ b/.openapi-generator/FILES
@@ -73,6 +73,7 @@ docs/WhatsAppLanguage.md
docs/WhatsAppMedia.md
docs/WhatsAppParameter.md
docs/WhatsAppTemplate.md
+docs/WhatsAppText.md
git_push.sh
gradle.properties
gradle/wrapper/gradle-wrapper.jar
@@ -163,6 +164,7 @@ src/main/java/com/messente/api/WhatsAppLanguage.java
src/main/java/com/messente/api/WhatsAppMedia.java
src/main/java/com/messente/api/WhatsAppParameter.java
src/main/java/com/messente/api/WhatsAppTemplate.java
+src/main/java/com/messente/api/WhatsAppText.java
src/main/java/com/messente/auth/ApiKeyAuth.java
src/main/java/com/messente/auth/Authentication.java
src/main/java/com/messente/auth/HttpBasicAuth.java
diff --git a/README.md b/README.md
index 52f335e..9a71c62 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.4.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.3.0'
+ implementation 'com.messente.api:messente-api:4.4.0'
}
```
@@ -23,14 +23,14 @@ dependencies {
com.messente.api
messente-api
- 4.3.0
+ 4.4.0
```
### Ivy
```xml
-
+
```
### Manual Build
@@ -43,7 +43,7 @@ mvn clean package
Install
-- `target/messente-api-4.3.0.jar`
+- `target/messente-api-4.4.0.jar`
- `target/lib/*.jar`
## Features
diff --git a/api/openapi.yaml b/api/openapi.yaml
index 7f93068..b34f6a8 100644
--- a/api/openapi.yaml
+++ b/api/openapi.yaml
@@ -2218,6 +2218,8 @@ components:
type: integer
template:
$ref: '#/components/schemas/WhatsAppTemplate'
+ text:
+ $ref: '#/components/schemas/WhatsAppText'
channel:
default: whatsapp
description: The channel used to deliver the message
@@ -2418,9 +2420,29 @@ components:
$ref: '#/components/schemas/WhatsAppMedia'
video:
$ref: '#/components/schemas/WhatsAppMedia'
+ coupon_code:
+ description: A coupon code.
+ type: string
+ payload:
+ description: A payload.
+ type: string
required:
- type
type: object
+ WhatsAppText:
+ description: A text
+ properties:
+ preview_url:
+ default: true
+ description: Whether to display link preview if the message contains a hyperlink
+ type: boolean
+ body:
+ description: "Plaintext content for WhatsApp, can contain URLs, emojis and\
+ \ formatting"
+ type: string
+ required:
+ - body
+ type: object
ErrorCodeOmnichannel:
description: |-
Matches the following error title.
diff --git a/build.gradle b/build.gradle
index b4adea6..abd31d2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,9 +11,8 @@ buildscript {
plugins {
id "java-library"
- id "maven-publish"
- id "signing"
- id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
+ id "com.vanniktech.maven.publish" version "0.30.0"
+
}
apply plugin: 'idea'
@@ -22,7 +21,7 @@ apply plugin: 'java'
apply plugin: 'com.diffplug.spotless'
group = 'com.messente.api'
-version = '4.3.0'
+version = '4.4.0'
ext {
jakarta_annotation_version = "1.3.5"
@@ -45,58 +44,38 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
-publishing {
- publications {
- mavenJava(MavenPublication) {
- from components.java
- artifactId = 'messente-api'
-
- pom {
- name = "messente-api"
- description = "Messente API - Connecting Services to People"
- url = "https://github.com/messente/messente-api-java"
- inceptionYear = "2019"
- licenses {
- license {
- name = "The Apache Software License, Version 2.0"
- url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
- distribution = "repo"
- }
- }
- developers {
- developer {
- id = "messente"
- name = "Messente Communications OU"
- email = "developers@messente.com"
- }
- }
- scm {
- connection = "scm:https://github.com/messente/messente-api-java.git"
- developerConnection = "scm:git@github.com:messente/messente-api-java.git"
- url = "https://github.com/messente/messente-api-java"
- }
+import com.vanniktech.maven.publish.SonatypeHost
+mavenPublishing {
+ publishToMavenCentral(SonatypeHost.DEFAULT)
+ signAllPublications()
+
+ pom {
+ name = "messente-api"
+ description = "Messente API - Connecting Services to People"
+ url = "https://github.com/messente/messente-api-java"
+ inceptionYear = "2019"
+ licenses {
+ license {
+ name = "The Apache Software License, Version 2.0"
+ url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
+ distribution = "repo"
}
}
- }
- repositories {
- mavenCentral()
- }
-}
-
-nexusPublishing {
- repositories {
- sonatype()
+ developers {
+ developer {
+ id = "messente"
+ name = "Messente Communications OU"
+ email = "developers@messente.com"
+ }
+ }
+ scm {
+ connection = "scm:https://github.com/messente/messente-api-java.git"
+ developerConnection = "scm:git@github.com:messente/messente-api-java.git"
+ url = "https://github.com/messente/messente-api-java"
+ }
}
}
-def skipSigning = project.hasProperty('skipSigning')
-
-// Configure signing only if skipSigning property is not set
-if (!skipSigning) {
- signing {
- sign publishing.publications.mavenJava
- }
-}
repositories {
mavenCentral()
@@ -109,7 +88,6 @@ sourceSets {
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
- withJavadocJar()
withSourcesJar()
}
diff --git a/build.sbt b/build.sbt
index b675345..b6ae01a 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.4.0",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
javacOptions in compile ++= Seq("-Xlint:deprecation"),
diff --git a/docs/WhatsApp.md b/docs/WhatsApp.md
index 8c295b2..30de753 100644
--- a/docs/WhatsApp.md
+++ b/docs/WhatsApp.md
@@ -12,6 +12,7 @@ WhatsApp message content. Only one of \"text\", \"image\", \"document\" or \"a
|**validity** | **Integer** | After how many minutes this channel is considered as failed and the next channel is attempted | [optional] |
|**ttl** | **Integer** | After how many seconds this channel is considered as failed and the next channel is attempted. Only one of \"ttl\" and \"validity\" can be used. | [optional] |
|**template** | [**WhatsAppTemplate**](WhatsAppTemplate.md) | | [optional] |
+|**text** | [**WhatsAppText**](WhatsAppText.md) | | [optional] |
|**channel** | [**ChannelEnum**](#ChannelEnum) | The channel used to deliver the message | [optional] |
diff --git a/docs/WhatsAppParameter.md b/docs/WhatsAppParameter.md
index c7f2c89..dfdd7b6 100644
--- a/docs/WhatsAppParameter.md
+++ b/docs/WhatsAppParameter.md
@@ -15,6 +15,8 @@ Whatsapp component parameter.
|**image** | [**WhatsAppMedia**](WhatsAppMedia.md) | | [optional] |
|**document** | [**WhatsAppMedia**](WhatsAppMedia.md) | | [optional] |
|**video** | [**WhatsAppMedia**](WhatsAppMedia.md) | | [optional] |
+|**couponCode** | **String** | A coupon code. | [optional] |
+|**payload** | **String** | A payload. | [optional] |
diff --git a/docs/WhatsAppText.md b/docs/WhatsAppText.md
new file mode 100644
index 0000000..752acbe
--- /dev/null
+++ b/docs/WhatsAppText.md
@@ -0,0 +1,15 @@
+
+
+# WhatsAppText
+
+A text
+
+## Properties
+
+| Name | Type | Description | Notes |
+|------------ | ------------- | ------------- | -------------|
+|**previewUrl** | **Boolean** | Whether to display link preview if the message contains a hyperlink | [optional] |
+|**body** | **String** | Plaintext content for WhatsApp, can contain URLs, emojis and formatting | |
+
+
+
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/pom.xml b/pom.xml
index 6569aac..9968914 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
messente-api
jar
messente-api
- 4.3.0
+ 4.4.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 a0e85b9..14ede20 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.4.0/java");
authentications = new HashMap();
}
diff --git a/src/main/java/com/messente/Configuration.java b/src/main/java/com/messente/Configuration.java
index 30c1863..d292503 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.4.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 1b0c0dd..75fffb7 100644
--- a/src/main/java/com/messente/JSON.java
+++ b/src/main/java/com/messente/JSON.java
@@ -149,6 +149,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppMedia.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppParameter.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppTemplate.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(new com.messente.api.WhatsAppText.CustomTypeAdapterFactory());
gson = gsonBuilder.create();
}
diff --git a/src/main/java/com/messente/api/WhatsApp.java b/src/main/java/com/messente/api/WhatsApp.java
index bbf29be..20f5f67 100644
--- a/src/main/java/com/messente/api/WhatsApp.java
+++ b/src/main/java/com/messente/api/WhatsApp.java
@@ -20,6 +20,7 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.messente.api.WhatsAppTemplate;
+import com.messente.api.WhatsAppText;
import java.io.IOException;
import java.util.Arrays;
@@ -68,6 +69,10 @@ public class WhatsApp {
@SerializedName(SERIALIZED_NAME_TEMPLATE)
private WhatsAppTemplate template;
+ public static final String SERIALIZED_NAME_TEXT = "text";
+ @SerializedName(SERIALIZED_NAME_TEXT)
+ private WhatsAppText text;
+
/**
* The channel used to deliver the message
*/
@@ -201,6 +206,25 @@ public void setTemplate(WhatsAppTemplate template) {
}
+ public WhatsApp text(WhatsAppText text) {
+ this.text = text;
+ return this;
+ }
+
+ /**
+ * Get text
+ * @return text
+ **/
+ @javax.annotation.Nullable
+ public WhatsAppText getText() {
+ return text;
+ }
+
+ public void setText(WhatsAppText text) {
+ this.text = text;
+ }
+
+
public WhatsApp channel(ChannelEnum channel) {
this.channel = channel;
return this;
@@ -278,13 +302,14 @@ public boolean equals(Object o) {
Objects.equals(this.validity, whatsApp.validity) &&
Objects.equals(this.ttl, whatsApp.ttl) &&
Objects.equals(this.template, whatsApp.template) &&
+ Objects.equals(this.text, whatsApp.text) &&
Objects.equals(this.channel, whatsApp.channel)&&
Objects.equals(this.additionalProperties, whatsApp.additionalProperties);
}
@Override
public int hashCode() {
- return Objects.hash(sender, validity, ttl, template, channel, additionalProperties);
+ return Objects.hash(sender, validity, ttl, template, text, channel, additionalProperties);
}
@Override
@@ -295,6 +320,7 @@ public String toString() {
sb.append(" validity: ").append(toIndentedString(validity)).append("\n");
sb.append(" ttl: ").append(toIndentedString(ttl)).append("\n");
sb.append(" template: ").append(toIndentedString(template)).append("\n");
+ sb.append(" text: ").append(toIndentedString(text)).append("\n");
sb.append(" channel: ").append(toIndentedString(channel)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}");
@@ -323,6 +349,7 @@ private String toIndentedString(Object o) {
openapiFields.add("validity");
openapiFields.add("ttl");
openapiFields.add("template");
+ openapiFields.add("text");
openapiFields.add("channel");
// a set of required properties/fields (JSON key names)
@@ -349,6 +376,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
if (jsonObj.get("template") != null && !jsonObj.get("template").isJsonNull()) {
WhatsAppTemplate.validateJsonElement(jsonObj.get("template"));
}
+ // validate the optional field `text`
+ if (jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) {
+ WhatsAppText.validateJsonElement(jsonObj.get("text"));
+ }
if ((jsonObj.get("channel") != null && !jsonObj.get("channel").isJsonNull()) && !jsonObj.get("channel").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `channel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("channel").toString()));
}
diff --git a/src/main/java/com/messente/api/WhatsAppParameter.java b/src/main/java/com/messente/api/WhatsAppParameter.java
index 17a7708..7f9662a 100644
--- a/src/main/java/com/messente/api/WhatsAppParameter.java
+++ b/src/main/java/com/messente/api/WhatsAppParameter.java
@@ -82,6 +82,14 @@ public class WhatsAppParameter {
@SerializedName(SERIALIZED_NAME_VIDEO)
private WhatsAppMedia video;
+ public static final String SERIALIZED_NAME_COUPON_CODE = "coupon_code";
+ @SerializedName(SERIALIZED_NAME_COUPON_CODE)
+ private String couponCode;
+
+ public static final String SERIALIZED_NAME_PAYLOAD = "payload";
+ @SerializedName(SERIALIZED_NAME_PAYLOAD)
+ private String payload;
+
public WhatsAppParameter() {
}
@@ -217,6 +225,44 @@ public void setVideo(WhatsAppMedia video) {
this.video = video;
}
+
+ public WhatsAppParameter couponCode(String couponCode) {
+ this.couponCode = couponCode;
+ return this;
+ }
+
+ /**
+ * A coupon code.
+ * @return couponCode
+ **/
+ @javax.annotation.Nullable
+ public String getCouponCode() {
+ return couponCode;
+ }
+
+ public void setCouponCode(String couponCode) {
+ this.couponCode = couponCode;
+ }
+
+
+ public WhatsAppParameter payload(String payload) {
+ this.payload = payload;
+ return this;
+ }
+
+ /**
+ * A payload.
+ * @return payload
+ **/
+ @javax.annotation.Nullable
+ public String getPayload() {
+ return payload;
+ }
+
+ public void setPayload(String payload) {
+ this.payload = payload;
+ }
+
/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
@@ -278,13 +324,15 @@ public boolean equals(Object o) {
Objects.equals(this.dateTime, whatsAppParameter.dateTime) &&
Objects.equals(this.image, whatsAppParameter.image) &&
Objects.equals(this.document, whatsAppParameter.document) &&
- Objects.equals(this.video, whatsAppParameter.video)&&
+ Objects.equals(this.video, whatsAppParameter.video) &&
+ Objects.equals(this.couponCode, whatsAppParameter.couponCode) &&
+ Objects.equals(this.payload, whatsAppParameter.payload)&&
Objects.equals(this.additionalProperties, whatsAppParameter.additionalProperties);
}
@Override
public int hashCode() {
- return Objects.hash(type, text, currency, dateTime, image, document, video, additionalProperties);
+ return Objects.hash(type, text, currency, dateTime, image, document, video, couponCode, payload, additionalProperties);
}
@Override
@@ -298,6 +346,8 @@ public String toString() {
sb.append(" image: ").append(toIndentedString(image)).append("\n");
sb.append(" document: ").append(toIndentedString(document)).append("\n");
sb.append(" video: ").append(toIndentedString(video)).append("\n");
+ sb.append(" couponCode: ").append(toIndentedString(couponCode)).append("\n");
+ sb.append(" payload: ").append(toIndentedString(payload)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}");
return sb.toString();
@@ -328,6 +378,8 @@ private String toIndentedString(Object o) {
openapiFields.add("image");
openapiFields.add("document");
openapiFields.add("video");
+ openapiFields.add("coupon_code");
+ openapiFields.add("payload");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
@@ -380,6 +432,12 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
if (jsonObj.get("video") != null && !jsonObj.get("video").isJsonNull()) {
WhatsAppMedia.validateJsonElement(jsonObj.get("video"));
}
+ if ((jsonObj.get("coupon_code") != null && !jsonObj.get("coupon_code").isJsonNull()) && !jsonObj.get("coupon_code").isJsonPrimitive()) {
+ throw new IllegalArgumentException(String.format("Expected the field `coupon_code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("coupon_code").toString()));
+ }
+ if ((jsonObj.get("payload") != null && !jsonObj.get("payload").isJsonNull()) && !jsonObj.get("payload").isJsonPrimitive()) {
+ throw new IllegalArgumentException(String.format("Expected the field `payload` to be a primitive type in the JSON string but got `%s`", jsonObj.get("payload").toString()));
+ }
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
diff --git a/src/main/java/com/messente/api/WhatsAppText.java b/src/main/java/com/messente/api/WhatsAppText.java
new file mode 100644
index 0000000..66bde96
--- /dev/null
+++ b/src/main/java/com/messente/api/WhatsAppText.java
@@ -0,0 +1,321 @@
+/*
+ * 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;
+
+/**
+ * A text
+ */
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
+public class WhatsAppText {
+ public static final String SERIALIZED_NAME_PREVIEW_URL = "preview_url";
+ @SerializedName(SERIALIZED_NAME_PREVIEW_URL)
+ private Boolean previewUrl = true;
+
+ public static final String SERIALIZED_NAME_BODY = "body";
+ @SerializedName(SERIALIZED_NAME_BODY)
+ private String body;
+
+ public WhatsAppText() {
+ }
+
+ public WhatsAppText previewUrl(Boolean previewUrl) {
+ this.previewUrl = previewUrl;
+ return this;
+ }
+
+ /**
+ * Whether to display link preview if the message contains a hyperlink
+ * @return previewUrl
+ **/
+ @javax.annotation.Nullable
+ public Boolean getPreviewUrl() {
+ return previewUrl;
+ }
+
+ public void setPreviewUrl(Boolean previewUrl) {
+ this.previewUrl = previewUrl;
+ }
+
+
+ public WhatsAppText body(String body) {
+ this.body = body;
+ return this;
+ }
+
+ /**
+ * Plaintext content for WhatsApp, can contain URLs, emojis and formatting
+ * @return body
+ **/
+ @javax.annotation.Nonnull
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
+ /**
+ * 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 WhatsAppText instance itself
+ */
+ public WhatsAppText 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;
+ }
+ WhatsAppText whatsAppText = (WhatsAppText) o;
+ return Objects.equals(this.previewUrl, whatsAppText.previewUrl) &&
+ Objects.equals(this.body, whatsAppText.body)&&
+ Objects.equals(this.additionalProperties, whatsAppText.additionalProperties);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(previewUrl, body, additionalProperties);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class WhatsAppText {\n");
+ sb.append(" previewUrl: ").append(toIndentedString(previewUrl)).append("\n");
+ sb.append(" body: ").append(toIndentedString(body)).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("preview_url");
+ openapiFields.add("body");
+
+ // a set of required properties/fields (JSON key names)
+ openapiRequiredFields = new HashSet();
+ openapiRequiredFields.add("body");
+ }
+
+ /**
+ * 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 WhatsAppText
+ */
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!WhatsAppText.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
+ throw new IllegalArgumentException(String.format("The required field(s) %s in WhatsAppText is not found in the empty JSON string", WhatsAppText.openapiRequiredFields.toString()));
+ }
+ }
+
+ // check to make sure all required properties/fields are present in the JSON string
+ for (String requiredField : WhatsAppText.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("body").isJsonPrimitive()) {
+ throw new IllegalArgumentException(String.format("Expected the field `body` to be a primitive type in the JSON string but got `%s`", jsonObj.get("body").toString()));
+ }
+ }
+
+ public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public TypeAdapter create(Gson gson, TypeToken type) {
+ if (!WhatsAppText.class.isAssignableFrom(type.getRawType())) {
+ return null; // this class only serializes 'WhatsAppText' and its subtypes
+ }
+ final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
+ final TypeAdapter thisAdapter
+ = gson.getDelegateAdapter(this, TypeToken.get(WhatsAppText.class));
+
+ return (TypeAdapter) new TypeAdapter() {
+ @Override
+ public void write(JsonWriter out, WhatsAppText 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 WhatsAppText read(JsonReader in) throws IOException {
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
+ // store additional fields in the deserialized instance
+ WhatsAppText 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 WhatsAppText given an JSON string
+ *
+ * @param jsonString JSON string
+ * @return An instance of WhatsAppText
+ * @throws IOException if the JSON string is invalid with respect to WhatsAppText
+ */
+ public static WhatsAppText fromJson(String jsonString) throws IOException {
+ return JSON.getGson().fromJson(jsonString, WhatsAppText.class);
+ }
+
+ /**
+ * Convert an instance of WhatsAppText to an JSON string
+ *
+ * @return JSON string
+ */
+ public String toJson() {
+ return JSON.getGson().toJson(this);
+ }
+}
+