From d174341bbfb6fadbe6ad918eb2c16ea31ed9e5b0 Mon Sep 17 00:00:00 2001 From: Giuseppe Compierchio Date: Tue, 5 Sep 2023 09:28:27 +0200 Subject: [PATCH 01/26] fix: adjust proxy implementation --- .../com/whatsapp/api/WhatsappApiServiceGenerator.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index 240eb7fa7..a0f9fe33f 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -58,7 +58,7 @@ private WhatsappApiServiceGenerator() { * *

* @param host the host (Not null) - * @param port the port (Not null) + * @param port the port * @param username the username * @param pwd the pwd * @see Proxy Selector @@ -66,13 +66,14 @@ private WhatsappApiServiceGenerator() { */ public static void setHttpProxy(String host, int port, String username, String pwd) { Objects.requireNonNull(host, "Host cannot be null"); - Objects.requireNonNull(port, "Http Port cannot be null"); CustomHttpProxySelector proxySelector = new CustomHttpProxySelector(host, port); + sharedClient = sharedClient.newBuilder() + .proxySelector(proxySelector) + .build(); + if (username == null || pwd == null) { - sharedClient = sharedClient.newBuilder() - .proxySelector(proxySelector) - .build(); + //Without authentication return; } From b676c367a2f11b0a0981cff334e35eab07ad0985 Mon Sep 17 00:00:00 2001 From: Giuseppe Compierchio Date: Tue, 5 Sep 2023 09:44:02 +0200 Subject: [PATCH 02/26] fix: add proxy object injection in shared object --- .../java/com/whatsapp/api/WhatsappApiServiceGenerator.java | 1 + .../whatsapp/api/utils/proxy/CustomHttpProxySelector.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index a0f9fe33f..2af6e96bf 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -70,6 +70,7 @@ public static void setHttpProxy(String host, int port, String username, String p sharedClient = sharedClient.newBuilder() .proxySelector(proxySelector) + .proxy(proxySelector.getProxy()) .build(); if (username == null || pwd == null) { diff --git a/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java b/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java index de5bed1dd..33daa8e04 100644 --- a/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java +++ b/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java @@ -13,6 +13,10 @@ public class CustomHttpProxySelector extends ProxySelector { private final Proxy proxy; + public Proxy getProxy() { + return proxy; + } + public CustomHttpProxySelector(String host, int port) { this.proxy = new Proxy(Type.HTTP, new InetSocketAddress(host, port)); } @@ -26,4 +30,6 @@ public List select(URI uri) { public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { // Do something here } + + } From ebb3c977785f0d29d38b296ce8ee2da559bf4ddf Mon Sep 17 00:00:00 2001 From: Giuseppe Compierchio Date: Tue, 5 Sep 2023 10:22:27 +0200 Subject: [PATCH 03/26] fix: removed proxy injection because have precedence to ProxySelector --- .../java/com/whatsapp/api/WhatsappApiServiceGenerator.java | 1 - .../com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index 2af6e96bf..a0f9fe33f 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -70,7 +70,6 @@ public static void setHttpProxy(String host, int port, String username, String p sharedClient = sharedClient.newBuilder() .proxySelector(proxySelector) - .proxy(proxySelector.getProxy()) .build(); if (username == null || pwd == null) { diff --git a/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java b/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java index 33daa8e04..a0256c4b4 100644 --- a/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java +++ b/src/main/java/com/whatsapp/api/utils/proxy/CustomHttpProxySelector.java @@ -13,10 +13,6 @@ public class CustomHttpProxySelector extends ProxySelector { private final Proxy proxy; - public Proxy getProxy() { - return proxy; - } - public CustomHttpProxySelector(String host, int port) { this.proxy = new Proxy(Type.HTTP, new InetSocketAddress(host, port)); } From eb4780fe1e30a916393ed048a8a5011a5fe61efd Mon Sep 17 00:00:00 2001 From: Giuseppe Compierchio Date: Tue, 5 Sep 2023 11:48:58 +0200 Subject: [PATCH 04/26] fix: remove authenticator to use ProxyAutenthicator like ProxySelector --- src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index a0f9fe33f..ef480e763 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -80,7 +80,7 @@ public static void setHttpProxy(String host, int port, String username, String p CustomProxyAuthenticator proxyAuthenticator = new CustomProxyAuthenticator(username, pwd); sharedClient = sharedClient.newBuilder() - .authenticator(proxyAuthenticator) + .proxyAuthenticator(proxyAuthenticator) .build(); } From dd2c43fd19066e66b9dd7e5dc29368cbb60e0160 Mon Sep 17 00:00:00 2001 From: Giuseppe Compierchio Date: Tue, 5 Sep 2023 11:49:18 +0200 Subject: [PATCH 05/26] fix: set credentials as final --- .../api/utils/proxy/CustomProxyAuthenticator.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java b/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java index f258ccee7..26eec8e8b 100644 --- a/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java +++ b/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java @@ -10,16 +10,20 @@ public class CustomProxyAuthenticator implements Authenticator { - private final String credential; + private final String CREDENTIALS; + + public String getCREDENTIALS() { + return CREDENTIALS; + } public CustomProxyAuthenticator(final String username, final String password) { - credential = Credentials.basic(username, password); + CREDENTIALS = Credentials.basic(username, password); } @Override public Request authenticate(final Route route, final Response response) throws IOException { return response.request().newBuilder() - .header("Proxy-Authorization", credential) + .header("Proxy-Authorization", CREDENTIALS) .build(); } } From f8b18d9d51967d5d3ef43a94fd477095e8153d35 Mon Sep 17 00:00:00 2001 From: Giuseppe Compierchio Date: Tue, 5 Sep 2023 12:21:57 +0200 Subject: [PATCH 06/26] fix: add test for proxy integration --- .../api/WhatsappApiServiceGenerator.java | 5 +- .../api/WhatsappApiServiceGeneratorTest.java | 119 ++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/whatsapp/api/WhatsappApiServiceGeneratorTest.java diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index ef480e763..f46c52fa7 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -37,8 +37,11 @@ private WhatsappApiServiceGenerator() { } static { + sharedClient = createDefaultHttpClient(); + } - sharedClient = new OkHttpClient.Builder()// + public static OkHttpClient createDefaultHttpClient(){ + return new OkHttpClient.Builder()// .callTimeout(20, TimeUnit.SECONDS)// .pingInterval(20, TimeUnit.SECONDS)// .build(); diff --git a/src/test/java/com/whatsapp/api/WhatsappApiServiceGeneratorTest.java b/src/test/java/com/whatsapp/api/WhatsappApiServiceGeneratorTest.java new file mode 100644 index 000000000..8678205d7 --- /dev/null +++ b/src/test/java/com/whatsapp/api/WhatsappApiServiceGeneratorTest.java @@ -0,0 +1,119 @@ +package com.whatsapp.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.io.IOException; +import java.net.ProxySelector; +import java.net.URISyntaxException; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.whatsapp.api.domain.errors.WhatsappApiError; +import com.whatsapp.api.exception.WhatsappApiException; +import com.whatsapp.api.utils.proxy.CustomHttpProxySelector; +import com.whatsapp.api.utils.proxy.CustomProxyAuthenticator; + +import okhttp3.Authenticator; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.ResponseBody; +import retrofit2.Response; + +public class WhatsappApiServiceGeneratorTest extends TestUtils { + + @BeforeEach + void resetProxy() { + WhatsappApiServiceGenerator.sharedClient = WhatsappApiServiceGenerator.createDefaultHttpClient(); + } + + /** + * Method under test: + * {@link WhatsappApiServiceGenerator#getSharedClient} + */ + @Test + void testGetSharedClient() { + + assertNotNull(WhatsappApiServiceGenerator.getSharedClient(), "Shared client should not be null"); + assertEquals(WhatsappApiServiceGenerator.getSharedClient().getClass(), OkHttpClient.class, "Shared client should be OkHttpClient"); + + } + + /** + * Method under test: + * {@link WhatsappApiServiceGenerator#getWhatsappApiError} + * + * @throws IOException + * @throws URISyntaxException + * @throws WhatsappApiException + */ + @Test + void testGetWhatsappApiError() throws IOException, URISyntaxException { + + String verifyCodeErrorBody = fromResource("/phone/verifyCodeError.json"); + + Response response = Response.error(400, ResponseBody.create(verifyCodeErrorBody, MediaType.parse("application/json"))); + WhatsappApiError apiError = WhatsappApiServiceGenerator.getWhatsappApiError(response); + + assertEquals(136025, apiError.error().code(), "Error code should be 136025"); + assertEquals(2388093, apiError.error().errorSubcode(), "Error code should be 136025"); + assertEquals(false, apiError.error().isTransient(), "Error code should be 136025"); + assertEquals("O c\u00F3digo inserido est\u00E1 incorreto.", apiError.error().errorUserMsg(), "Error code should be 136025"); + assertEquals("N\u00E3o foi poss\u00EDvel verificar o c\u00F3digo", apiError.error().errorUserSubtitle(), "Error code should be 136025"); + + } + + /** + * Method under test: + * {@link WhatsappApiServiceGenerator#setHttpProxy(String, int, String, String)} + */ + @Test + void testSetHttpProxy_WithoutAuthentication() { + + // Pre-condition Proxy + assertNull(WhatsappApiServiceGenerator.getSharedClient().proxy(), "Proxy should be null"); + assertEquals(ProxySelector.getDefault(), WhatsappApiServiceGenerator.getSharedClient().proxySelector(), + "Proxy selector should be null"); + + // Set proxy in shared client + WhatsappApiServiceGenerator.setHttpProxy("localhost", 8080, null, null); + + // Check if proxy is set + assertNotNull(WhatsappApiServiceGenerator.getSharedClient().proxySelector(), "Proxy selector should not be null"); + assertEquals(WhatsappApiServiceGenerator.getSharedClient().proxySelector().getClass(), CustomHttpProxySelector.class, "Proxy selector should be CustomHttpProxySelector"); + + // Check if authenticator is NONE + assertEquals(Authenticator.NONE, WhatsappApiServiceGenerator.getSharedClient().authenticator(), "Authenticator should be NONE"); + } + + /** + * Method under test: + * {@link WhatsappApiServiceGenerator#setHttpProxy(String, int, String, String)} + */ + @Test + void testSetHttpProxy_WithAuthentication() { + + // Pre-condition Proxy + assertNull(WhatsappApiServiceGenerator.getSharedClient().proxy(), "Proxy should be null"); + assertEquals(ProxySelector.getDefault(), WhatsappApiServiceGenerator.getSharedClient().proxySelector(), + "Proxy selector should be ProxySelector.getDefault()"); + + // Pre-condition Authenticator + assertEquals(Authenticator.NONE, WhatsappApiServiceGenerator.getSharedClient().authenticator(), "Authenticator should be NONE"); + assertEquals(Authenticator.NONE, WhatsappApiServiceGenerator.getSharedClient().proxyAuthenticator(), "Authenticator should be NONE"); + + // Set proxy with Authentication in shared client + WhatsappApiServiceGenerator.setHttpProxy("localhost", 8080, "Proxy-User", "Proxy-Pwd"); + + // Check if proxy is set + assertNotNull(WhatsappApiServiceGenerator.getSharedClient().proxySelector(), "Proxy selector should not be null"); + assertEquals(WhatsappApiServiceGenerator.getSharedClient().proxySelector().getClass(), CustomHttpProxySelector.class, "Proxy selector should be CustomHttpProxySelector"); + + // Check if authenticator is CustomProxyAuthenticator + assertNotNull(WhatsappApiServiceGenerator.getSharedClient().proxyAuthenticator(), "Proxy Authenticator should not be null"); + assertEquals(CustomProxyAuthenticator.class, WhatsappApiServiceGenerator.getSharedClient().proxyAuthenticator().getClass(), "Authenticator should be CustomProxyAuthenticator"); + + } +} From cf735496c9f3a046d69c7e9fe2a28479d1f4ca93 Mon Sep 17 00:00:00 2001 From: Giuseppe Compierchio Date: Tue, 5 Sep 2023 12:55:24 +0200 Subject: [PATCH 07/26] fix: remove credentials --- .../whatsapp/api/utils/proxy/CustomProxyAuthenticator.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java b/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java index 26eec8e8b..610102cbc 100644 --- a/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java +++ b/src/main/java/com/whatsapp/api/utils/proxy/CustomProxyAuthenticator.java @@ -12,10 +12,6 @@ public class CustomProxyAuthenticator implements Authenticator { private final String CREDENTIALS; - public String getCREDENTIALS() { - return CREDENTIALS; - } - public CustomProxyAuthenticator(final String username, final String password) { CREDENTIALS = Credentials.basic(username, password); } From e0d7fcebddd4ea434170b4b78674a0c28b9dd9b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 15:33:54 +0000 Subject: [PATCH 08/26] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.5.0 to 3.6.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.5.0...maven-javadoc-plugin-3.6.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c4a573c41..292ba4e24 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 + 3.6.0 17 ${project.basedir} From ed76bb5ba8236ba6c4fdac62064cb29a258c3e3f Mon Sep 17 00:00:00 2001 From: Zhou Date: Sat, 30 Sep 2023 16:16:24 +0800 Subject: [PATCH 09/26] fix https://github.com/Bindambc/whatsapp-business-java-api/issues/125 --- .../com/whatsapp/api/domain/messages/response/Message.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/whatsapp/api/domain/messages/response/Message.java b/src/main/java/com/whatsapp/api/domain/messages/response/Message.java index 1208cdde3..df34ff517 100644 --- a/src/main/java/com/whatsapp/api/domain/messages/response/Message.java +++ b/src/main/java/com/whatsapp/api/domain/messages/response/Message.java @@ -8,6 +8,6 @@ */ @JsonInclude(JsonInclude.Include.NON_NULL) public record Message( - - @JsonProperty("id") String id) { + @JsonProperty("id") String id, + @JsonProperty("message_status") String messageStatus){ } From fc2c73c651c25481ffdddd4879a08e6f29c464e7 Mon Sep 17 00:00:00 2001 From: Zhou Wei Date: Mon, 16 Oct 2023 15:24:40 +0800 Subject: [PATCH 10/26] fix #127 --- src/main/java/com/whatsapp/api/domain/webhook/WebHook.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/whatsapp/api/domain/webhook/WebHook.java b/src/main/java/com/whatsapp/api/domain/webhook/WebHook.java index e2380c177..8c087e45f 100644 --- a/src/main/java/com/whatsapp/api/domain/webhook/WebHook.java +++ b/src/main/java/com/whatsapp/api/domain/webhook/WebHook.java @@ -1,6 +1,7 @@ package com.whatsapp.api.domain.webhook; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; /** @@ -8,7 +9,7 @@ * Use this class to deserialize webhook events */ public final class WebHook { - private static final ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); /** * Construct WebHookEvent object From 4d5ec975e40c87d9ea4db3beacfd9c333a5c75a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:09:49 +0000 Subject: [PATCH 11/26] Bump org.jacoco:jacoco-maven-plugin from 0.8.10 to 0.8.11 Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.10 to 0.8.11. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.10...v0.8.11) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c4a573c41..46437c60c 100644 --- a/pom.xml +++ b/pom.xml @@ -141,7 +141,7 @@ org.jacoco jacoco-maven-plugin - 0.8.10 + 0.8.11 From 019830e93e4e59ff47b4609102f7e3c84092f34a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:58:16 +0000 Subject: [PATCH 12/26] Bump org.junit.jupiter.version from 5.10.0 to 5.10.1 Bumps `org.junit.jupiter.version` from 5.10.0 to 5.10.1. Updates `org.junit.jupiter:junit-jupiter-api` from 5.10.0 to 5.10.1 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.0...r5.10.1) Updates `org.junit.jupiter:junit-jupiter-engine` from 5.10.0 to 5.10.1 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.0...r5.10.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-api dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c4a573c41..d90999209 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ UTF-8 2.9.0 5.2.0 - 5.10.0 + 5.10.1 5.0.0-alpha.11 From 26064d37a4249ddc758bc5b97ca62173cc104edc Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Wed, 8 Nov 2023 12:31:08 +0530 Subject: [PATCH 13/26] fixed failing of - message_response: "accepted" unknown field sending template_message. ignoring any newer fields. --- .../com/whatsapp/api/WhatsappApiServiceGenerator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index 240eb7fa7..c4d049c1a 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -9,6 +9,9 @@ import com.whatsapp.api.utils.proxy.CustomProxyAuthenticator; import com.whatsapp.api.utils.proxy.CustomHttpProxySelector; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + import okhttp3.OkHttpClient; import okhttp3.ResponseBody; import retrofit2.Call; @@ -28,7 +31,10 @@ public class WhatsappApiServiceGenerator { static OkHttpClient sharedClient; - private static final Converter.Factory converterFactory = JacksonConverterFactory.create(); + private static final Converter.Factory converterFactory = JacksonConverterFactory.create( + new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + ); + @SuppressWarnings("unchecked") private static final Converter errorBodyConverter = (Converter) converterFactory.responseBodyConverter(WhatsappApiError.class, new Annotation[0], null); From 9206bf837582be4e2b21d73d695e78236295fc7e Mon Sep 17 00:00:00 2001 From: Martin Schelldorfer Date: Tue, 21 Nov 2023 11:28:51 +0100 Subject: [PATCH 14/26] add fields platfrom_type and throughput to PhoneNumber see https://developers.facebook.com/docs/whatsapp/business-platform/changelog/#september-12--2023 --- .../api/domain/phone/PhoneNumber.java | 34 ++- .../whatsapp/api/domain/phone/Throughput.java | 16 ++ .../api/domain/phone/type/LevelType.java | 38 +++ .../api/domain/phone/type/PlatformType.java | 38 +++ .../WhatsappBusinessManagementApiTest.java | 246 ++++++++++-------- src/test/resources/phone/phoneNumber.json | 4 + 6 files changed, 249 insertions(+), 127 deletions(-) create mode 100644 src/main/java/com/whatsapp/api/domain/phone/Throughput.java create mode 100644 src/main/java/com/whatsapp/api/domain/phone/type/LevelType.java create mode 100644 src/main/java/com/whatsapp/api/domain/phone/type/PlatformType.java diff --git a/src/main/java/com/whatsapp/api/domain/phone/PhoneNumber.java b/src/main/java/com/whatsapp/api/domain/phone/PhoneNumber.java index 74d3b131e..61708c3e2 100644 --- a/src/main/java/com/whatsapp/api/domain/phone/PhoneNumber.java +++ b/src/main/java/com/whatsapp/api/domain/phone/PhoneNumber.java @@ -4,24 +4,29 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.whatsapp.api.domain.phone.type.NameStatusType; +import com.whatsapp.api.domain.phone.type.PlatformType; import com.whatsapp.api.domain.phone.type.QualityRatingType; /** * The type Phone number. * - * @param id The ID associated with the phone number. - * @param displayPhoneNumber The string representation of the phone number. - * @param nameStatus The current status of the review of your business name. + * @param id The ID associated with the phone number. + * @param displayPhoneNumber The string representation of the phone number. + * @param nameStatus The current status of the review of your business name. * @param codeVerificationStatus Code Verification Status - * @param qualityRating The quality rating of the phone number based on how messages have been received by recipients in recent days. Valid values are: - *

- * @param verifiedName the verified name + * @param qualityRating The quality rating of the phone number based on how messages have been received by recipients in recent days. Valid values are: + * + * @param verifiedName the verified name + * @param platformType Platform the business phone number is registered with. + * @param throughput The business phone number's Cloud API throughput level. * @see About WhatsApp Business Account Message Quality Rating + * @see WhatsApp Business Phone Number + * @see WhatsApp Business Platform - Changelog - September 12, 2023 */ @JsonInclude(value = Include.NON_NULL) public record PhoneNumber( @@ -36,5 +41,10 @@ public record PhoneNumber( @JsonProperty("code_verification_status") String codeVerificationStatus, - @JsonProperty("name_status") NameStatusType nameStatus) { + @JsonProperty("name_status") NameStatusType nameStatus, + + @JsonProperty("platform_type") PlatformType platformType, + + @JsonProperty("throughput") Throughput throughput) +{ } \ No newline at end of file diff --git a/src/main/java/com/whatsapp/api/domain/phone/Throughput.java b/src/main/java/com/whatsapp/api/domain/phone/Throughput.java new file mode 100644 index 000000000..167c2e5c5 --- /dev/null +++ b/src/main/java/com/whatsapp/api/domain/phone/Throughput.java @@ -0,0 +1,16 @@ +package com.whatsapp.api.domain.phone; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.whatsapp.api.domain.phone.type.LevelType; + +/** + * The type Throughput. + */ +@JsonInclude(value = Include.NON_NULL) +public record Throughput( + + @JsonProperty("level") LevelType Level) +{ +} \ No newline at end of file diff --git a/src/main/java/com/whatsapp/api/domain/phone/type/LevelType.java b/src/main/java/com/whatsapp/api/domain/phone/type/LevelType.java new file mode 100644 index 000000000..0993400a1 --- /dev/null +++ b/src/main/java/com/whatsapp/api/domain/phone/type/LevelType.java @@ -0,0 +1,38 @@ +package com.whatsapp.api.domain.phone.type; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The enum Level type. + */ +public enum LevelType +{ + + /** + * Standard Level type. + */ + STANDARD("STANDARD"), + /** + * High Level type. + */ + HIGH("HIGH"), + NOT_APPLICABLE("NOT_APPLICABLE"); + + private final String value; + + LevelType(String value) + { + this.value = value; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() + { + return value; + } +} diff --git a/src/main/java/com/whatsapp/api/domain/phone/type/PlatformType.java b/src/main/java/com/whatsapp/api/domain/phone/type/PlatformType.java new file mode 100644 index 000000000..5e3856dad --- /dev/null +++ b/src/main/java/com/whatsapp/api/domain/phone/type/PlatformType.java @@ -0,0 +1,38 @@ +package com.whatsapp.api.domain.phone.type; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The enum Platform type. + */ +public enum PlatformType +{ + + /** + * Cloud API Platform type. + */ + CLOUD_API("CLOUD_API"), + /** + * On-Premises API Platform type. + */ + ON_PREMISE("ON_PREMISE"), + NOT_APPLICABLE("NOT_APPLICABLE"); + + private final String value; + + PlatformType(String value) + { + this.value = value; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() + { + return value; + } +} diff --git a/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java b/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java index 5161834b5..2c93ab9ed 100644 --- a/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java +++ b/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java @@ -7,18 +7,8 @@ import com.whatsapp.api.domain.config.CommerceDataItem; import com.whatsapp.api.domain.phone.RequestCode; import com.whatsapp.api.domain.phone.VerifyCode; -import com.whatsapp.api.domain.phone.type.CodeMethodType; -import com.whatsapp.api.domain.phone.type.NameStatusType; -import com.whatsapp.api.domain.phone.type.QualityRatingType; -import com.whatsapp.api.domain.templates.BodyComponent; -import com.whatsapp.api.domain.templates.ButtonComponent; -import com.whatsapp.api.domain.templates.Example; -import com.whatsapp.api.domain.templates.FooterComponent; -import com.whatsapp.api.domain.templates.HeaderComponent; -import com.whatsapp.api.domain.templates.MessageTemplate; -import com.whatsapp.api.domain.templates.PhoneNumberButton; -import com.whatsapp.api.domain.templates.QuickReplyButton; -import com.whatsapp.api.domain.templates.UrlButton; +import com.whatsapp.api.domain.phone.type.*; +import com.whatsapp.api.domain.templates.*; import com.whatsapp.api.domain.templates.type.ButtonType; import com.whatsapp.api.domain.templates.type.Category; import com.whatsapp.api.domain.templates.type.HeaderFormat; @@ -39,7 +29,8 @@ import static com.whatsapp.api.configuration.WhatsappApiConfig.API_VERSION; -class WhatsappBusinessManagementApiTest extends MockServerUtilsTest { +class WhatsappBusinessManagementApiTest extends MockServerUtilsTest +{ public final String DEFAULT_TEMPLATE_RESPONSE = """ { @@ -56,7 +47,8 @@ class WhatsappBusinessManagementApiTest extends MockServerUtilsTest { * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplate() throws InterruptedException, JSONException { + void testCreateMessageTemplate() throws InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -96,13 +88,13 @@ void testCreateMessageTemplate() throws InterruptedException, JSONException { .setCategory(Category.UTILITY)// .setLanguage(LanguageType.EN_US)// .addComponent(new HeaderComponent()// - .setText("Wellcome title")// - .setFormat(HeaderFormat.TEXT))// + .setText("Wellcome title")// + .setFormat(HeaderFormat.TEXT))// .addComponent(new BodyComponent()// - .setText("Hello {{1}}, welcome to our {{2}} test. ")// - .setExample(new Example()// - .addBodyTextExamples("Mr. José", "s")// - )); + .setText("Hello {{1}}, welcome to our {{2}} test. ")// + .setExample(new Example()// + .addBodyTextExamples("Mr. José", "s")// + )); var response = whatsappBusinessCloudApi.createMessageTemplate(WABA_ID, template); @@ -122,7 +114,8 @@ void testCreateMessageTemplate() throws InterruptedException, JSONException { * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplate2() throws IOException, URISyntaxException, InterruptedException, JSONException { + void testCreateMessageTemplate2() throws IOException, URISyntaxException, InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -137,13 +130,13 @@ void testCreateMessageTemplate2() throws IOException, URISyntaxException, Interr .setCategory(Category.TRANSACTIONAL)// .setLanguage(LanguageType.PT_BR)// .addComponent(new HeaderComponent()// - .setText("Código de confirmação")// - .setFormat(HeaderFormat.TEXT))// + .setText("Código de confirmação")// + .setFormat(HeaderFormat.TEXT))// .addComponent(new BodyComponent()// - .setText("Este é o seu código de confirmação: " + Formatter.bold("{{1}}."))// - .setExample(new Example()// - .addBodyTextExamples("1458425")// - ))// + .setText("Este é o seu código de confirmação: " + Formatter.bold("{{1}}."))// + .setExample(new Example()// + .addBodyTextExamples("1458425")// + ))// .addComponent(new FooterComponent().setText("Use este código para confirmar seu telefone.")); whatsappBusinessCloudApi.createMessageTemplate(WABA_ID, template); @@ -160,7 +153,8 @@ void testCreateMessageTemplate2() throws IOException, URISyntaxException, Interr * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplate3() throws IOException, URISyntaxException, InterruptedException, JSONException { + void testCreateMessageTemplate3() throws IOException, URISyntaxException, InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -174,18 +168,19 @@ void testCreateMessageTemplate3() throws IOException, URISyntaxException, Interr .setCategory(Category.TRANSACTIONAL)// .setLanguage(LanguageType.PT_BR)// .addComponent(new HeaderComponent()// - .setText("Confirmação de Atendimento")// - .setFormat(HeaderFormat.TEXT))// + .setText("Confirmação de Atendimento")// + .setFormat(HeaderFormat.TEXT))// .addComponent(new BodyComponent()// - .setText("Olá " + Formatter.bold("{{1}}") + ", passando aqui para confirmar seu horário no dia " + Formatter.bold("{{2}}") + " as " + Formatter.bold("{{3}}h") + ".\nVocê confirma que comparecerá?")// - .setExample(new Example()// - .addBodyTextExamples("Maria", "04/11/2022", "13:30")// - ))// + .setText("Olá " + Formatter.bold("{{1}}") + ", passando aqui para confirmar seu horário no dia " + Formatter.bold("{{2}}") + " as " + Formatter.bold( + "{{3}}h") + ".\nVocê confirma que comparecerá?")// + .setExample(new Example()// + .addBodyTextExamples("Maria", "04/11/2022", "13:30")// + ))// .addComponent(new ButtonComponent()// - .addButton(new QuickReplyButton("SIM"))// - .addButton(new QuickReplyButton("NÃO"))// - .addButton(new QuickReplyButton("REMARCAR")// - ))// + .addButton(new QuickReplyButton("SIM"))// + .addButton(new QuickReplyButton("NÃO"))// + .addButton(new QuickReplyButton("REMARCAR")// + ))// .addComponent(new FooterComponent().setText("Utilize um dos botões abaixo para a confirmação")); var response = whatsappBusinessCloudApi.createMessageTemplate(WABA_ID, template); @@ -203,7 +198,8 @@ void testCreateMessageTemplate3() throws IOException, URISyntaxException, Interr * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplate4() throws IOException, URISyntaxException, InterruptedException, JSONException { + void testCreateMessageTemplate4() throws IOException, URISyntaxException, InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -215,17 +211,18 @@ void testCreateMessageTemplate4() throws IOException, URISyntaxException, Interr .setCategory(Category.TRANSACTIONAL)// .setLanguage(LanguageType.PT_BR)// .addComponent(new HeaderComponent()// - .setText("Confirmação de Atendimento")// - .setFormat(HeaderFormat.TEXT))// + .setText("Confirmação de Atendimento")// + .setFormat(HeaderFormat.TEXT))// .addComponent(new BodyComponent()// - .setText("Olá " + Formatter.bold("{{1}}") + ", passando aqui para confirmar seu horário no dia " + Formatter.bold("{{2}}") + " as " + Formatter.bold("{{3}}h") + ".\nVocê confirma que comparecerá?")// - .setExample(new Example()// - .addBodyTextExamples("Maria", "04/11/2022", "13:30")// - ))// + .setText("Olá " + Formatter.bold("{{1}}") + ", passando aqui para confirmar seu horário no dia " + Formatter.bold("{{2}}") + " as " + Formatter.bold( + "{{3}}h") + ".\nVocê confirma que comparecerá?")// + .setExample(new Example()// + .addBodyTextExamples("Maria", "04/11/2022", "13:30")// + ))// .addComponent(new FooterComponent().setText("Utilize um dos botões abaixo para a confirmação"))// .addComponent(new ButtonComponent()// - .addButton(new QuickReplyButton("SIM"))// - .addButton(new QuickReplyButton("NÃO"))// + .addButton(new QuickReplyButton("SIM"))// + .addButton(new QuickReplyButton("NÃO"))// ); whatsappBusinessCloudApi.createMessageTemplate(WABA_ID, template); @@ -238,12 +235,12 @@ void testCreateMessageTemplate4() throws IOException, URISyntaxException, Interr JSONAssert.assertEquals(expectedJson, request.getBody().readUtf8(), JSONCompareMode.STRICT); } - /** * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplateUtility1() throws IOException, URISyntaxException, InterruptedException, JSONException { + void testCreateMessageTemplateUtility1() throws IOException, URISyntaxException, InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -255,18 +252,19 @@ void testCreateMessageTemplateUtility1() throws IOException, URISyntaxException, .setCategory(Category.UTILITY)// .setLanguage(LanguageType.PT_BR)// .addComponent(new HeaderComponent()// - .setFormat(HeaderFormat.DOCUMENT).setExample(new Example().addHeaderHandleExamples("4::aW1hZ2UvanBlZw==:ARb0a9E9s7-LdErXAXQCwyh7Oy-_h9gBo4ljPynnXo53CKOyyhHYUjCCREvS4fB-0CwfSQbNn9fJC3ikLOJve1CfQO-9aeWYdMmkMUJgGJI0g:e:1680011044:3449853982404722:100007529143136:ARZMcC4QfmCW8V85Lco")))// + .setFormat(HeaderFormat.DOCUMENT).setExample(new Example().addHeaderHandleExamples( + "4::aW1hZ2UvanBlZw==:ARb0a9E9s7-LdErXAXQCwyh7Oy-_h9gBo4ljPynnXo53CKOyyhHYUjCCREvS4fB-0CwfSQbNn9fJC3ikLOJve1CfQO-9aeWYdMmkMUJgGJI0g:e:1680011044:3449853982404722:100007529143136:ARZMcC4QfmCW8V85Lco")))// .addComponent(new BodyComponent()// - .setText("Olá {{1}}, seu professou publicou novas aulas na plataforma de ensino.")// - .setExample(new Example()// - .addBodyTextExamples("Maria")// - ))// + .setText("Olá {{1}}, seu professou publicou novas aulas na plataforma de ensino.")// + .setExample(new Example()// + .addBodyTextExamples("Maria")// + ))// .addComponent(new FooterComponent().setText("Click on the button below to watch now"))// .addComponent(new ButtonComponent()// - .addButton(new UrlButton("Assistir agora")// - .setUrl("https://www.coursera.org/{{1}}")// - .setUrlExample(Collections.singletonList("https://www.coursera.org/?authMode=login"))// - )); + .addButton(new UrlButton("Assistir agora")// + .setUrl("https://www.coursera.org/{{1}}")// + .setUrlExample(Collections.singletonList("https://www.coursera.org/?authMode=login"))// + )); whatsappBusinessCloudApi.createMessageTemplate(WABA_ID, template); @@ -282,7 +280,8 @@ void testCreateMessageTemplateUtility1() throws IOException, URISyntaxException, * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplateUtility2() throws IOException, URISyntaxException, InterruptedException, JSONException { + void testCreateMessageTemplateUtility2() throws IOException, URISyntaxException, InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -294,14 +293,15 @@ void testCreateMessageTemplateUtility2() throws IOException, URISyntaxException, .setCategory(Category.UTILITY)// .setLanguage(LanguageType.PT_BR)// .addComponent(new HeaderComponent()// - .setText("Problemas com a entrega do seu pedido")// - .setFormat(HeaderFormat.TEXT))// + .setText("Problemas com a entrega do seu pedido")// + .setFormat(HeaderFormat.TEXT))// .addComponent(new BodyComponent()// - .setText("Olá {{1}}, Tivemos um problema com a entrega do seu pedido {{2}}. Por favor, entre em contato com a central de atendimento para obter mais detalhes")// - .setExample(new Example()// - .addBodyTextExamples("Maria", "FE-15454T45001")))// + .setText( + "Olá {{1}}, Tivemos um problema com a entrega do seu pedido {{2}}. Por favor, entre em contato com a central de atendimento para obter mais detalhes")// + .setExample(new Example()// + .addBodyTextExamples("Maria", "FE-15454T45001")))// .addComponent(new ButtonComponent()// - .addButton(new PhoneNumberButton("Ligar agora", "16503087300"))// + .addButton(new PhoneNumberButton("Ligar agora", "16503087300"))// )// .addComponent(new FooterComponent().setText("Clique no botão abaixo para ligar agora.")); @@ -319,7 +319,8 @@ void testCreateMessageTemplateUtility2() throws IOException, URISyntaxException, * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplateAuthentication() throws IOException, URISyntaxException, InterruptedException, JSONException { + void testCreateMessageTemplateAuthentication() throws IOException, URISyntaxException, InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -331,15 +332,15 @@ void testCreateMessageTemplateAuthentication() throws IOException, URISyntaxExce .setCategory(Category.AUTHENTICATION)// .setLanguage(LanguageType.EN_US)// .addComponent(new HeaderComponent()// - .setFormat(HeaderFormat.TEXT).setText("Your authentication code for {{1}}")// - .setExample(new Example().addHeaderTextExamples("App X")))// + .setFormat(HeaderFormat.TEXT).setText("Your authentication code for {{1}}")// + .setExample(new Example().addHeaderTextExamples("App X")))// .addComponent(new BodyComponent()// - .setText("Please use the code {{1}} to sign in to your account. Do not provide this code to third parties.")// - .setExample(new Example()// - .addBodyTextExamples("784-H45-7R4")))// + .setText("Please use the code {{1}} to sign in to your account. Do not provide this code to third parties.")// + .setExample(new Example()// + .addBodyTextExamples("784-H45-7R4")))// .addComponent(new FooterComponent().setText("Did you not request the code? Click on 'Not me'"))// .addComponent(new ButtonComponent()// - .addButton(new QuickReplyButton("Not me"))// + .addButton(new QuickReplyButton("Not me"))// ); whatsappBusinessCloudApi.createMessageTemplate(WABA_ID, template); @@ -352,12 +353,12 @@ void testCreateMessageTemplateAuthentication() throws IOException, URISyntaxExce JSONAssert.assertEquals(expectedJson, request.getBody().readUtf8(), JSONCompareMode.STRICT); } - /** * Method under test: {@link WhatsappBusinessManagementApi#createMessageTemplate(String, MessageTemplate)} */ @Test - void testCreateMessageTemplateMarketing2() throws IOException, URISyntaxException, InterruptedException, JSONException { + void testCreateMessageTemplateMarketing2() throws IOException, URISyntaxException, InterruptedException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -369,21 +370,21 @@ void testCreateMessageTemplateMarketing2() throws IOException, URISyntaxExceptio .setCategory(Category.MARKETING)// .setLanguage(LanguageType.PT_BR)// .addComponent(new HeaderComponent()// - .setFormat(HeaderFormat.IMAGE).setExample(new Example().addHeaderHandleExamples("4::aW1hZ2UvanBlZw==:ARZdpGlLrA9uwIGGZc-UFu5viAD1BkqTCYGL8je2d7xovDZphaWG8gJPTSJfekNchsL3SWdY8-jTA9ZRq_MWro-1wfJnApfbb0ByrUoDb6nNZA:e:1679805732:3449824985304722:100002914375136:ARauotmqlFdTcNENzt0")))// + .setFormat(HeaderFormat.IMAGE).setExample(new Example().addHeaderHandleExamples( + "4::aW1hZ2UvanBlZw==:ARZdpGlLrA9uwIGGZc-UFu5viAD1BkqTCYGL8je2d7xovDZphaWG8gJPTSJfekNchsL3SWdY8-jTA9ZRq_MWro-1wfJnApfbb0ByrUoDb6nNZA:e:1679805732:3449824985304722:100002914375136:ARauotmqlFdTcNENzt0")))// .addComponent(new BodyComponent()// - .setText("Venha aproveitar nossos cafés especiais em nossa super promoção. Nossos expressos são a partir de R${{1}}")// - .setExample(new Example()// - .addBodyTextExamples("15")// - ))// + .setText("Venha aproveitar nossos cafés especiais em nossa super promoção. Nossos expressos são a partir de R${{1}}")// + .setExample(new Example()// + .addBodyTextExamples("15")// + ))// .addComponent(new ButtonComponent()// - .addButton(new QuickReplyButton("Saiba mais"))// - .addButton(new QuickReplyButton("Parar promoções")// - ))// + .addButton(new QuickReplyButton("Saiba mais"))// + .addButton(new QuickReplyButton("Parar promoções")// + ))// .addComponent(new FooterComponent().setText("Sem interesse? Clique em parar promoções")); - whatsappBusinessCloudApi.createMessageTemplate(WABA_ID, template); var request = mockWebServer.takeRequest(); @@ -398,7 +399,8 @@ void testCreateMessageTemplateMarketing2() throws IOException, URISyntaxExceptio * Method under test: {@link WhatsappBusinessManagementApi#updateMessageTemplate(String, String, MessageTemplate)} */ @Test - void testUpdateMessageTemplate() throws IOException, URISyntaxException { + void testUpdateMessageTemplate() throws IOException, URISyntaxException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -411,25 +413,25 @@ void testUpdateMessageTemplate() throws IOException, URISyntaxException { .setCategory(Category.TRANSACTIONAL)// .setLanguage(LanguageType.EN_US)// .addComponent(new HeaderComponent()// - .setText("Wellcome title")// - .setFormat(HeaderFormat.TEXT))// + .setText("Wellcome title")// + .setFormat(HeaderFormat.TEXT))// .addComponent(new BodyComponent()// - .setText("Hello {{1}}, welcome to our {{2}} test. ")// - .setExample(new Example()// - .addBodyTextExamples("Mr. José", "satisfaction")// - )); + .setText("Hello {{1}}, welcome to our {{2}} test. ")// + .setExample(new Example()// + .addBodyTextExamples("Mr. José", "satisfaction")// + )); var response = whatsappBusinessCloudApi.updateMessageTemplate(WABA_ID, "952305634123456", template); Assertions.assertEquals("952305634123456", response.id()); } - /** * Method under test: {@link WhatsappBusinessManagementApi#deleteMessageTemplate(String, String)} */ @Test - void testDeleteMessageTemplate() throws IOException, URISyntaxException { + void testDeleteMessageTemplate() throws IOException, URISyntaxException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -443,7 +445,8 @@ void testDeleteMessageTemplate() throws IOException, URISyntaxException { } @Test - void testRetrieveMessageTemplate1() throws IOException, URISyntaxException, JSONException { + void testRetrieveMessageTemplate1() throws IOException, URISyntaxException, JSONException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); var expectedJson = fromResource("/retTemplate1.json"); @@ -467,11 +470,11 @@ void testRetrieveMessageTemplate1() throws IOException, URISyntaxException, JSON Assertions.assertEquals(ButtonType.QUICK_REPLY, buttonComponent.getButtons().get(0).getType()); - } @Test - void testRetrieveMessageTemplate2() throws IOException, URISyntaxException { + void testRetrieveMessageTemplate2() throws IOException, URISyntaxException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -479,7 +482,6 @@ void testRetrieveMessageTemplate2() throws IOException, URISyntaxException { var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID, 2); - Assertions.assertEquals(2, templates.data().size()); Assertions.assertEquals("welcome_template3", templates.data().get(0).name()); Assertions.assertEquals("Hello {{1}}, welcome to our {{2}} test.", templates.data().get(0).components().get(1).getText()); @@ -488,7 +490,8 @@ void testRetrieveMessageTemplate2() throws IOException, URISyntaxException { } @Test - void testRetrieveMessageTemplate3() throws IOException, URISyntaxException { + void testRetrieveMessageTemplate3() throws IOException, URISyntaxException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -496,7 +499,6 @@ void testRetrieveMessageTemplate3() throws IOException, URISyntaxException { var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID, "welcome_template3"); - Assertions.assertEquals(1, templates.data().size()); Assertions.assertEquals("welcome_template3", templates.data().get(0).name()); Assertions.assertEquals("Hello {{1}}, welcome to our {{2}} test.", templates.data().get(0).components().get(1).getText()); @@ -504,7 +506,8 @@ void testRetrieveMessageTemplate3() throws IOException, URISyntaxException { } @Test - void testRetrieveMessageTemplate3WithLimit() throws IOException, URISyntaxException { + void testRetrieveMessageTemplate3WithLimit() throws IOException, URISyntaxException + { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); @@ -512,7 +515,6 @@ void testRetrieveMessageTemplate3WithLimit() throws IOException, URISyntaxExcept var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID, 1, "10"); - Assertions.assertEquals(1, templates.data().size()); Assertions.assertEquals("welcome_template3", templates.data().get(0).name()); Assertions.assertEquals("Hello {{1}}, welcome to our {{2}} test.", templates.data().get(0).components().get(1).getText()); @@ -520,7 +522,8 @@ void testRetrieveMessageTemplate3WithLimit() throws IOException, URISyntaxExcept } @Test - void testRetrievePhoneNumber() throws IOException, URISyntaxException, InterruptedException { + void testRetrievePhoneNumber() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/phone/phoneNumber.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -537,12 +540,15 @@ void testRetrievePhoneNumber() throws IOException, URISyntaxException, Interrupt Assertions.assertNull(phoneNumber.nameStatus()); Assertions.assertEquals(QualityRatingType.GREEN, phoneNumber.qualityRating()); Assertions.assertEquals("NOT_VERIFIED", phoneNumber.codeVerificationStatus()); + Assertions.assertEquals(PlatformType.CLOUD_API, phoneNumber.platformType()); + Assertions.assertEquals(LevelType.STANDARD, phoneNumber.throughput().Level()); Assertions.assertEquals("109219645287979", phoneNumber.id()); } @Test - void testRetrievePhoneNumberWithSpecificFields() throws IOException, URISyntaxException, InterruptedException { + void testRetrievePhoneNumberWithSpecificFields() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/phone/phoneWithSpecificFields.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -564,7 +570,8 @@ void testRetrievePhoneNumberWithSpecificFields() throws IOException, URISyntaxEx } @Test - void testRetrievePhoneNumbers() throws IOException, URISyntaxException, InterruptedException { + void testRetrievePhoneNumbers() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/phone/phoneNumbersList.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -593,7 +600,8 @@ void testRetrievePhoneNumbers() throws IOException, URISyntaxException, Interrup } @Test - void testRetrievePhoneNumberNotFoundError() throws IOException, URISyntaxException, InterruptedException { + void testRetrievePhoneNumberNotFoundError() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(fromResource("/phone/phoneNumberNotFoundError.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -606,7 +614,9 @@ void testRetrievePhoneNumberNotFoundError() throws IOException, URISyntaxExcepti Assertions.assertEquals("GET", recordedRequest.getMethod()); Assertions.assertEquals("/" + API_VERSION + "/" + "454545", recordedRequest.getPath()); - Assertions.assertEquals("Unsupported get request. Object with ID '454545' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api", ex.getMessage()); + Assertions.assertEquals( + "Unsupported get request. Object with ID '454545' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api", + ex.getMessage()); } @@ -614,7 +624,8 @@ void testRetrievePhoneNumberNotFoundError() throws IOException, URISyntaxExcepti * Method under test: {@link WhatsappBusinessManagementApi#requestCode(String, RequestCode)}} */ @Test - void requestCode() throws IOException, URISyntaxException, InterruptedException { + void requestCode() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/reponse.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -636,7 +647,8 @@ void requestCode() throws IOException, URISyntaxException, InterruptedException * Method under test: {@link WhatsappBusinessManagementApi#requestCode(String, RequestCode)}} */ @Test - void requestCodeError() throws IOException, URISyntaxException, InterruptedException { + void requestCodeError() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(fromResource("/phone/requestCodeError.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -658,7 +670,8 @@ void requestCodeError() throws IOException, URISyntaxException, InterruptedExcep * Method under test: {@link WhatsappBusinessManagementApi#verifyCode(String, VerifyCode)} */ @Test - void verifyCode() throws IOException, URISyntaxException, InterruptedException { + void verifyCode() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/reponse.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -680,7 +693,8 @@ void verifyCode() throws IOException, URISyntaxException, InterruptedException { * Method under test: {@link WhatsappBusinessManagementApi#verifyCode(String, VerifyCode)} */ @Test - void verifyCodeError() throws IOException, URISyntaxException, InterruptedException { + void verifyCodeError() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(fromResource("/phone/verifyCodeError.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -702,10 +716,11 @@ void verifyCodeError() throws IOException, URISyntaxException, InterruptedExcept * Method under test: {@link WhatsappBusinessManagementApi#getWhatsappCommerceSettings(String, String...)} */ @Test - void getWhatsappCommerceSettings() throws IOException, URISyntaxException, InterruptedException { + void getWhatsappCommerceSettings() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse() - .setResponseCode(200) - .setBody(fromResource("/config/commerceSettings.json"))); + .setResponseCode(200) + .setBody(fromResource("/config/commerceSettings.json"))); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -726,10 +741,11 @@ void getWhatsappCommerceSettings() throws IOException, URISyntaxException, Inter * Method under test: {@link WhatsappBusinessManagementApi#updateWhatsappCommerceSettings(String, CommerceDataItem)} */ @Test - void updateWhatsappCommerceSettings() throws IOException, URISyntaxException, InterruptedException { + void updateWhatsappCommerceSettings() throws IOException, URISyntaxException, InterruptedException + { mockWebServer.enqueue(new MockResponse() - .setResponseCode(200) - .setBody(fromResource("/reponse.json")) + .setResponseCode(200) + .setBody(fromResource("/reponse.json")) ); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); diff --git a/src/test/resources/phone/phoneNumber.json b/src/test/resources/phone/phoneNumber.json index 8898b9a48..2754d2261 100644 --- a/src/test/resources/phone/phoneNumber.json +++ b/src/test/resources/phone/phoneNumber.json @@ -3,5 +3,9 @@ "code_verification_status": "NOT_VERIFIED", "display_phone_number": "11111111111", "quality_rating": "GREEN", + "platform_type": "CLOUD_API", + "throughput": { + "level": "STANDARD" + }, "id": "109219645287979" } \ No newline at end of file From ce491907291f298ea905b7e330172f06390e6e7f Mon Sep 17 00:00:00 2001 From: Martin Schelldorfer Date: Tue, 21 Nov 2023 15:56:41 +0100 Subject: [PATCH 15/26] issue #125 - New message_status on com.whatsapp.api.domain.messages.response.Message --- .../com/whatsapp/api/domain/messages/response/Message.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/whatsapp/api/domain/messages/response/Message.java b/src/main/java/com/whatsapp/api/domain/messages/response/Message.java index 1208cdde3..326ed01a3 100644 --- a/src/main/java/com/whatsapp/api/domain/messages/response/Message.java +++ b/src/main/java/com/whatsapp/api/domain/messages/response/Message.java @@ -9,5 +9,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public record Message( - @JsonProperty("id") String id) { + @JsonProperty("id") String id, + @JsonProperty("message_status") String messageStatus) +{ } From a472db9445832f26ce71ce6469f89e7a0d5d5e7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:42:35 +0000 Subject: [PATCH 16/26] Bump actions/setup-java from 3 to 4 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/javadoc.yml | 2 +- .github/workflows/maven-ci.yml | 2 +- .github/workflows/maven-publish.yml | 2 +- .github/workflows/test-javadoc.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0abdde844..5a9440e8f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -44,7 +44,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index a5c0889b3..fbd092bdd 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -28,7 +28,7 @@ jobs: git config --local user.name "github-actions[bot]" git merge origin/main - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' diff --git a/.github/workflows/maven-ci.yml b/.github/workflows/maven-ci.yml index 91e4a64b0..0a672ed76 100644 --- a/.github/workflows/maven-ci.yml +++ b/.github/workflows/maven-ci.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 030351c7c..607466da9 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -17,7 +17,7 @@ jobs: packages: write steps: - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' diff --git a/.github/workflows/test-javadoc.yml b/.github/workflows/test-javadoc.yml index bb44393bb..9a9232b41 100644 --- a/.github/workflows/test-javadoc.yml +++ b/.github/workflows/test-javadoc.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' From 0524c8bbc0807bdd6922715a2e7845fee4a04830 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 15:33:56 +0000 Subject: [PATCH 17/26] Bump actions/labeler from 4 to 5 Bumps [actions/labeler](https://github.com/actions/labeler) from 4 to 5. - [Release notes](https://github.com/actions/labeler/releases) - [Commits](https://github.com/actions/labeler/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/labeler dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index ad476f722..724e40e64 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -17,6 +17,6 @@ jobs: pull-requests: write steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From 6825bd13dcd806c1f1345c821fdf92efc03e0b2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 15:45:08 +0000 Subject: [PATCH 18/26] Bump github/codeql-action from 2 to 3 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0abdde844..ea81eea40 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -64,7 +64,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -78,6 +78,6 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" From 9d560a91f20f244739eef11d46ec0ce7fd14e748 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 21:45:27 +0000 Subject: [PATCH 19/26] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.1.2 to 3.2.5 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.1.2 to 3.2.5. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.2...surefire-3.2.5) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4b2e088ad..6ef7d1c2f 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.2.5 org.apache.maven.plugins From a2f1c7b0f88be49936ae410ead94ed3209d3d14b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 22:08:39 +0000 Subject: [PATCH 20/26] Bump org.apache.maven.plugins:maven-compiler-plugin Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.11.0 to 3.12.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.11.0...maven-compiler-plugin-3.12.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4b2e088ad..3f64ba9ca 100644 --- a/pom.xml +++ b/pom.xml @@ -116,7 +116,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 17 17 From 5a6f383871a7546745d2f49ae3e9bf26271f4041 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 22:16:12 +0000 Subject: [PATCH 21/26] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.0 to 3.6.3 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.0 to 3.6.3. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.0...maven-javadoc-plugin-3.6.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4fda3118e..aee11f14b 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.6.3 17 ${project.basedir} From 60bb4f2a59b2ae3ddd46098048a1ea68bd8502e3 Mon Sep 17 00:00:00 2001 From: Mauricio Binda da Costa Date: Fri, 26 Jan 2024 19:32:37 -0300 Subject: [PATCH 22/26] downgrade codecov action - v3 --- .github/workflows/maven-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-ci.yml b/.github/workflows/maven-ci.yml index 0a672ed76..3aae14feb 100644 --- a/.github/workflows/maven-ci.yml +++ b/.github/workflows/maven-ci.yml @@ -26,4 +26,4 @@ jobs: run: mvn -B package --file pom.xml #coverage - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 From 29b3d59e47eb2dc09472824412dc4d73f5d63f43 Mon Sep 17 00:00:00 2001 From: Mauricio Binda da Costa Date: Fri, 26 Jan 2024 19:44:47 -0300 Subject: [PATCH 23/26] Update labeler.yml --- .github/labeler.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 7dccf8144..5b9828a50 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,13 +1,25 @@ tests: - - src/test/**/* + - changed-files: + - any-glob-to-any-file: 'src/test/**/*' + java: - - '**/*.java' + - changed-files: + - any-glob-to-any-file: '**/*.java' + documentation: - - '**/*.md' + - changed-files: + - any-glob-to-any-file: '**/*.md' + markdown: - - '**/*.md' + - changed-files: + - any-glob-to-any-file: '**/*.md' + github-actions: - - .github/**/* + - changed-files: + - any-glob-to-any-file: '.github/**/*' + dependencies: - - pom.xml + - changed-files: + - any-glob-to-any-file: 'pom.xml' + From 012c4b02e966c2ae7bdc767f6ad539da65726313 Mon Sep 17 00:00:00 2001 From: BernardoGiordano Date: Thu, 7 Mar 2024 10:57:43 +0100 Subject: [PATCH 24/26] Don't throw exception on unmapped property deserialization --- .../java/com/whatsapp/api/WhatsappApiServiceGenerator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index a5907cdfd..e9690cfdc 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -32,7 +32,10 @@ public class WhatsappApiServiceGenerator { static OkHttpClient sharedClient; private static final Converter.Factory converterFactory = JacksonConverterFactory.create( - new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false) + .configure(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS, false) ); @SuppressWarnings("unchecked") From 78a9f280411823830a3bc38a11d51b098c17f0a0 Mon Sep 17 00:00:00 2001 From: BernardoGiordano Date: Fri, 8 Mar 2024 15:03:00 +0100 Subject: [PATCH 25/26] Gracefully handle deserialization error on unmapped FLOW Button type --- src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java index e9690cfdc..606688e9d 100644 --- a/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java +++ b/src/main/java/com/whatsapp/api/WhatsappApiServiceGenerator.java @@ -36,6 +36,7 @@ public class WhatsappApiServiceGenerator { .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS, false) + .configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false) ); @SuppressWarnings("unchecked") From ff249b52bee09a6baea2cb6223a00d20fc64df27 Mon Sep 17 00:00:00 2001 From: BernardoGiordano Date: Wed, 13 Mar 2024 10:13:25 +0100 Subject: [PATCH 26/26] Expose Whatsapp API error details needed if handling SDK errors is necessary --- .../java/com/whatsapp/api/exception/WhatsappApiException.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/whatsapp/api/exception/WhatsappApiException.java b/src/main/java/com/whatsapp/api/exception/WhatsappApiException.java index f601507b7..1f32c712c 100644 --- a/src/main/java/com/whatsapp/api/exception/WhatsappApiException.java +++ b/src/main/java/com/whatsapp/api/exception/WhatsappApiException.java @@ -51,4 +51,8 @@ public String getMessage() { return super.getMessage(); } + public WhatsappApiError getError() { + return whatsappApiError; + } + }