diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ca53ba5e..7ec81347b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +# [8.12.0] - 2024-10-?? +- Added `network_apis` capability to Application API +- Added `@JsonCreator` annotation to webhook classes' `fromJson(String)` method + # [8.11.0] - 2024-09-25 - Added custom user agent property setting to `HttpConfig` - Added RCS channel to Messages API diff --git a/src/main/java/com/vonage/client/application/Application.java b/src/main/java/com/vonage/client/application/Application.java index 44fa0e68c..0d5f079d0 100644 --- a/src/main/java/com/vonage/client/application/Application.java +++ b/src/main/java/com/vonage/client/application/Application.java @@ -336,10 +336,10 @@ public Verify getVerify() { * Network APIs capability. * * @return The Network APIs capability, or {@code null} if absent. - * @since 8.9.0 + * @since 8.12.0 */ @JsonProperty("network_apis") - public NetworkApis networkApis() { + public NetworkApis getNetworkApis() { return networkApis; } diff --git a/src/main/java/com/vonage/client/application/capabilities/Capability.java b/src/main/java/com/vonage/client/application/capabilities/Capability.java index a77c383d7..ebaa307c7 100644 --- a/src/main/java/com/vonage/client/application/capabilities/Capability.java +++ b/src/main/java/com/vonage/client/application/capabilities/Capability.java @@ -91,7 +91,7 @@ public enum Type { /** * Network APIs * - * @since 8.9.0 + * @since 8.12.0 */ NETWORK } diff --git a/src/main/java/com/vonage/client/application/capabilities/NetworkApis.java b/src/main/java/com/vonage/client/application/capabilities/NetworkApis.java index 8a376564f..503114292 100644 --- a/src/main/java/com/vonage/client/application/capabilities/NetworkApis.java +++ b/src/main/java/com/vonage/client/application/capabilities/NetworkApis.java @@ -21,7 +21,7 @@ /** * Network APIs capability configuration settings. * - * @since 8.9.0 + * @since 8.12.0 */ public final class NetworkApis extends Capability { private URI redirectUri; diff --git a/src/main/java/com/vonage/client/messages/InboundMessage.java b/src/main/java/com/vonage/client/messages/InboundMessage.java index 82087f961..e9d867abd 100644 --- a/src/main/java/com/vonage/client/messages/InboundMessage.java +++ b/src/main/java/com/vonage/client/messages/InboundMessage.java @@ -434,6 +434,7 @@ public List getContent() { * @return The deserialized webhook response object. * @throws com.vonage.client.VonageResponseParseException If the response could not be deserialized. */ + @JsonCreator public static InboundMessage fromJson(String json) { return Jsonable.fromJson(json); } diff --git a/src/main/java/com/vonage/client/messages/MessageStatus.java b/src/main/java/com/vonage/client/messages/MessageStatus.java index 8176779e4..ecfdde2a6 100644 --- a/src/main/java/com/vonage/client/messages/MessageStatus.java +++ b/src/main/java/com/vonage/client/messages/MessageStatus.java @@ -330,6 +330,7 @@ public String getWhatsappConversationId() { * * @return An instance of this class with the fields populated, if present. */ + @JsonCreator public static MessageStatus fromJson(String json) { return Jsonable.fromJson(json); } diff --git a/src/main/java/com/vonage/client/sms/MessageEvent.java b/src/main/java/com/vonage/client/sms/MessageEvent.java index 9480d7f66..5aece2e98 100644 --- a/src/main/java/com/vonage/client/sms/MessageEvent.java +++ b/src/main/java/com/vonage/client/sms/MessageEvent.java @@ -15,6 +15,7 @@ */ package com.vonage.client.sms; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.vonage.client.Jsonable; @@ -198,6 +199,7 @@ public Integer getConcatPart() { * * @return An instance of this class with the fields populated, if present. */ + @JsonCreator public static MessageEvent fromJson(String json) { return Jsonable.fromJson(json); } diff --git a/src/main/java/com/vonage/client/verify2/VerificationCallback.java b/src/main/java/com/vonage/client/verify2/VerificationCallback.java index 988bd246d..a0e5c848b 100644 --- a/src/main/java/com/vonage/client/verify2/VerificationCallback.java +++ b/src/main/java/com/vonage/client/verify2/VerificationCallback.java @@ -15,6 +15,7 @@ */ package com.vonage.client.verify2; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.vonage.client.Jsonable; @@ -176,6 +177,7 @@ public URI getSilentAuthUrl() { * @return The deserialized webhook response object. * @throws VonageResponseParseException If the response could not be deserialized. */ + @JsonCreator public static VerificationCallback fromJson(String json) { return Jsonable.fromJson(json); } diff --git a/src/main/java/com/vonage/client/voice/AnswerWebhook.java b/src/main/java/com/vonage/client/voice/AnswerWebhook.java index c969277f1..177d53730 100644 --- a/src/main/java/com/vonage/client/voice/AnswerWebhook.java +++ b/src/main/java/com/vonage/client/voice/AnswerWebhook.java @@ -15,6 +15,7 @@ */ package com.vonage.client.voice; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.vonage.client.Jsonable; @@ -107,6 +108,7 @@ public URI getRegionUrl() { * * @return A new instance of this class. */ + @JsonCreator public static AnswerWebhook fromJson(String json) { return Jsonable.fromJson(json); } diff --git a/src/main/java/com/vonage/client/voice/EventWebhook.java b/src/main/java/com/vonage/client/voice/EventWebhook.java index f7aa7ebdc..ef75e7d18 100644 --- a/src/main/java/com/vonage/client/voice/EventWebhook.java +++ b/src/main/java/com/vonage/client/voice/EventWebhook.java @@ -16,6 +16,7 @@ package com.vonage.client.voice; import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.vonage.client.Jsonable; import com.vonage.client.JsonableBaseObject; @@ -292,6 +293,7 @@ public String getReason() { * * @return A new instance of this class. */ + @JsonCreator public static EventWebhook fromJson(String json) { return Jsonable.fromJson(json); } diff --git a/src/test/java/com/vonage/client/application/ApplicationClientTest.java b/src/test/java/com/vonage/client/application/ApplicationClientTest.java index 4796d6b96..9a18c0acf 100644 --- a/src/test/java/com/vonage/client/application/ApplicationClientTest.java +++ b/src/test/java/com/vonage/client/application/ApplicationClientTest.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.*; import org.junit.jupiter.api.function.Executable; +import java.net.URI; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -73,6 +74,10 @@ public class ApplicationClientTest extends AbstractClientTest " }\n" + " }\n" + " },\n" + + " \"network_apis\": {\n" + + " \"network_application_id\": \"2bzfIFqRG128IcjSj1YhZNtw6LADG\",\n" + + " \"redirect_uri\": \"https://my-redirect-uri.example.com\"\n" + + " },\n" + " \"rtc\": {\n" + " \"webhooks\": {\n" + " \"event_url\": {\n" + @@ -133,6 +138,11 @@ static void assertEqualsSampleApplication(Application response) { assertEquals("https://example.com/webhooks/status", message.getWebhooks().get(Webhook.Type.STATUS).getAddress()); assertEquals(HttpMethod.POST, message.getWebhooks().get(Webhook.Type.STATUS).getMethod()); + NetworkApis networkApis = capabilities.getNetworkApis(); + assertEquals(Capability.Type.NETWORK, networkApis.getType()); + assertEquals("2bzfIFqRG128IcjSj1YhZNtw6LADG", networkApis.getNetworkApplicationId()); + assertEquals(URI.create("https://my-redirect-uri.example.com"), networkApis.getRedirectUri()); + Rtc rtc = capabilities.getRtc(); assertEquals(Capability.Type.RTC, rtc.getType()); assertEquals("https://example.com/webhooks/event", rtc.getWebhooks().get(Webhook.Type.EVENT).getAddress()); diff --git a/src/test/java/com/vonage/client/application/ApplicationTest.java b/src/test/java/com/vonage/client/application/ApplicationTest.java index 6f6f31788..a7842e2ef 100644 --- a/src/test/java/com/vonage/client/application/ApplicationTest.java +++ b/src/test/java/com/vonage/client/application/ApplicationTest.java @@ -167,17 +167,36 @@ public void testAddVerifyCapabilityWithStatusWebhooks() { @Test public void testAddMessagesCapabilityWithInboundWebhook() { String json = "{\"capabilities\":{\"messages\":{\"webhooks\":{\"inbound_url\":{\"address\":\"https://example.com/inbound\",\"http_method\":\"POST\"}}}}}"; - Application application = Application.builder() - .addCapability( - Messages.builder() - .addWebhook(Webhook.Type.INBOUND, new Webhook("https://example.com/inbound", HttpMethod.POST)) - .build()) - .build(); + Application application = Application.builder().addCapability( + Messages.builder() + .addWebhook(Webhook.Type.INBOUND, new Webhook("https://example.com/inbound", HttpMethod.POST)) + .build() + ) + .build(); assertEquals(json, application.toJson()); testJsonableBaseObject(application); } + @Test + public void testAddNetworkApisCapabilityWithRedirectUriAndId() { + String redirectUri = "http://localhost:8080/camara/redirect", + networkApplicationId = "my-network-application-id", + expectedJson = "{\"capabilities\":{\"network_apis\":{\"redirect_uri\":\"" + + redirectUri + "\",\"network_application_id\":\""+networkApplicationId+"\"}}}"; + + Application application = Application.builder().addCapability( + NetworkApis.builder() + .redirectUri(redirectUri) + .networkApplicationId(networkApplicationId) + .build() + ) + .build(); + + testJsonableBaseObject(application); + assertEquals(expectedJson, application.toJson()); + } + @Test public void testUpdatingApplication() { String json = "{\"name\":\"updated\"}"; diff --git a/src/test/java/com/vonage/client/insight/StandardInsightResponseTest.java b/src/test/java/com/vonage/client/insight/StandardInsightResponseTest.java index d4b29964f..688abf543 100644 --- a/src/test/java/com/vonage/client/insight/StandardInsightResponseTest.java +++ b/src/test/java/com/vonage/client/insight/StandardInsightResponseTest.java @@ -59,7 +59,6 @@ public void testFromJson() { " }\n" + "}"); - TestUtils.testJsonableBaseObject(response); assertEquals(InsightStatus.LOOKUP_NOT_RETURNED, response.getStatus()); assertEquals(43, response.getStatus().getInsightStatus()); assertEquals("Lookup not returned", response.getStatusMessage());