From 8718d8a4a8e9f202188e4f73938b0895067dd83d Mon Sep 17 00:00:00 2001 From: Sina Madani Date: Wed, 1 Nov 2023 12:23:24 +0000 Subject: [PATCH] refactor: Type inference hack for fromJson --- src/main/java/com/vonage/client/Jsonable.java | 49 +++++++++++++++++++ .../client/VonageApiResponseException.java | 20 +------- .../client/account/BalanceResponse.java | 2 +- .../client/account/ListSecretsResponse.java | 2 +- .../client/account/PrefixPricingResponse.java | 2 +- .../client/account/PricingResponse.java | 2 +- .../vonage/client/account/SecretResponse.java | 2 +- .../client/account/SettingsResponse.java | 2 +- .../client/application/Application.java | 2 +- .../client/application/ApplicationList.java | 2 +- .../com/vonage/client/incoming/CallEvent.java | 2 +- .../vonage/client/incoming/InputEvent.java | 2 +- .../vonage/client/incoming/MessageEvent.java | 2 +- .../vonage/client/incoming/NotifyEvent.java | 2 +- .../vonage/client/incoming/RecordEvent.java | 2 +- .../insight/AdvancedInsightResponse.java | 2 +- .../client/insight/BasicInsightResponse.java | 2 +- .../insight/StandardInsightResponse.java | 2 +- .../vonage/client/meetings/Application.java | 2 +- .../meetings/ListRecordingsResponse.java | 2 +- .../client/meetings/ListRoomsResponse.java | 2 +- .../vonage/client/meetings/MeetingRoom.java | 2 +- .../meetings/MeetingsEventCallback.java | 2 +- .../com/vonage/client/meetings/Recording.java | 2 +- .../com/vonage/client/meetings/Theme.java | 2 +- .../client/messages/InboundMessage.java | 2 +- .../client/messages/MessageResponse.java | 2 +- .../vonage/client/messages/MessageStatus.java | 13 +---- .../client/numbers/ListNumbersResponse.java | 2 +- .../client/numbers/SearchNumbersResponse.java | 2 +- .../client/proactiveconnect/ContactsList.java | 2 +- .../vonage/client/proactiveconnect/Event.java | 2 +- .../proactiveconnect/ListEventsResponse.java | 2 +- .../client/proactiveconnect/ListItem.java | 2 +- .../proactiveconnect/ListItemsResponse.java | 2 +- .../proactiveconnect/ListListsResponse.java | 2 +- .../client/proactiveconnect/SyncStatus.java | 2 +- .../UploadListItemsResponse.java | 2 +- .../client/sms/SmsSubmissionResponse.java | 2 +- .../vonage/client/subaccounts/Account.java | 2 +- .../subaccounts/ListSubaccountsResponse.java | 2 +- .../client/subaccounts/MoneyTransfer.java | 2 +- .../client/subaccounts/NumberTransfer.java | 2 +- .../java/com/vonage/client/users/User.java | 2 +- .../vonage/client/verify/ControlResponse.java | 2 +- .../client/verify/SearchVerifyResponse.java | 2 +- .../client/verify2/VerificationCallback.java | 2 +- .../java/com/vonage/client/voice/Call.java | 2 +- .../com/vonage/client/voice/CallEvent.java | 2 +- .../com/vonage/client/voice/CallInfo.java | 2 +- .../com/vonage/client/voice/CallInfoPage.java | 2 +- .../com/vonage/client/voice/DtmfResponse.java | 2 +- .../client/voice/ModifyCallResponse.java | 2 +- .../vonage/client/voice/StreamResponse.java | 2 +- .../com/vonage/client/voice/TalkResponse.java | 2 +- 55 files changed, 103 insertions(+), 83 deletions(-) diff --git a/src/main/java/com/vonage/client/Jsonable.java b/src/main/java/com/vonage/client/Jsonable.java index 2955c9a36..02a07e82c 100644 --- a/src/main/java/com/vonage/client/Jsonable.java +++ b/src/main/java/com/vonage/client/Jsonable.java @@ -29,6 +29,11 @@ */ public interface Jsonable { + /** + * Convenience method for creating an ObjectMapper with standard settings. + * + * @return A new ObjectMapper with appropriate configuration. + */ static ObjectMapper createDefaultObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); @@ -36,6 +41,11 @@ static ObjectMapper createDefaultObjectMapper() { return mapper; } + /** + * Serialises this class to a JSON payload. + * + * @return The JSON string representing this class's marked properties. + */ default String toJson() { try { return createDefaultObjectMapper().writeValueAsString(this); @@ -45,6 +55,13 @@ default String toJson() { } } + /** + * Updates this class's fields from the JSON payload. + * + * @param json The JSON string. + * + * @throws VonageResponseParseException If the JSON was invalid or this class couldn't be updated. + */ default void updateFromJson(String json) { if (json == null || json.trim().isEmpty()) { return; @@ -57,6 +74,38 @@ default void updateFromJson(String json) { } } + /** + * Delegates to {@linkplain #fromJson(String, Class)}, using the type varargs for inferring the class. + * + * @param json The JSON string to parse. + * @param type Unused. This is a hack to get the array class's component type. + * + * @return A new instance of the inferred Jsonable. + * + * @param A class which implements this interface. + * + * @throws VonageUnexpectedException If a no-args constructor for the class was not found. + * @throws VonageResponseParseException If the JSON was invalid or this class couldn't be updated. + */ + @SuppressWarnings("unchecked") + static J fromJson(String json, J... type) { + return fromJson(json, (Class) type.getClass().getComponentType()); + } + + /** + * Creates a new instance of the designated Jsonable class, calling its no-args constructor + * followed by {@link #updateFromJson(String)}. + * + * @param json The JSON string to parse. + * @param jsonable The Jsonable class to construct. + * + * @return A new instance of the Jsonable class. + * + * @param A class which implements this interface. + * + * @throws VonageUnexpectedException If a no-args constructor for the class was not found. + * @throws VonageResponseParseException If the JSON was invalid or this class couldn't be updated. + */ static J fromJson(String json, Class jsonable) { try { Constructor constructor = jsonable.getDeclaredConstructor(); diff --git a/src/main/java/com/vonage/client/VonageApiResponseException.java b/src/main/java/com/vonage/client/VonageApiResponseException.java index 8f90ae08b..dca89ef21 100644 --- a/src/main/java/com/vonage/client/VonageApiResponseException.java +++ b/src/main/java/com/vonage/client/VonageApiResponseException.java @@ -20,9 +20,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.introspect.AnnotatedMember; import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import org.apache.http.HttpResponse; -import org.apache.http.util.EntityUtils; -import java.io.IOException; import java.net.URI; import java.util.List; import java.util.Objects; @@ -219,21 +216,6 @@ protected static E fromJson(Class claz throw new VonageUnexpectedException(ex); } } - try { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(json, clazz); - } - catch (IOException ex) { - throw new VonageResponseParseException("Failed to produce "+clazz.getSimpleName()+" from json.", ex); - } - } - - protected static E fromHttpResponse(Class clazz, HttpResponse response) throws IOException { - E crx = fromJson(clazz, EntityUtils.toString(response.getEntity())); - if (crx.title == null) { - crx.title = response.getStatusLine().getReasonPhrase(); - } - crx.statusCode = response.getStatusLine().getStatusCode(); - return crx; + else return Jsonable.fromJson(json, clazz); } } diff --git a/src/main/java/com/vonage/client/account/BalanceResponse.java b/src/main/java/com/vonage/client/account/BalanceResponse.java index 68f0ab73f..e84e93cf5 100644 --- a/src/main/java/com/vonage/client/account/BalanceResponse.java +++ b/src/main/java/com/vonage/client/account/BalanceResponse.java @@ -43,6 +43,6 @@ public boolean isAutoReload() { } public static BalanceResponse fromJson(String json) { - return Jsonable.fromJson(json, BalanceResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/account/ListSecretsResponse.java b/src/main/java/com/vonage/client/account/ListSecretsResponse.java index 2578c2401..abca096b1 100644 --- a/src/main/java/com/vonage/client/account/ListSecretsResponse.java +++ b/src/main/java/com/vonage/client/account/ListSecretsResponse.java @@ -55,6 +55,6 @@ public void updateFromJson(String json) { } public static ListSecretsResponse fromJson(String json) { - return Jsonable.fromJson(json, ListSecretsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/account/PrefixPricingResponse.java b/src/main/java/com/vonage/client/account/PrefixPricingResponse.java index 8edbd8baa..423e0e45c 100644 --- a/src/main/java/com/vonage/client/account/PrefixPricingResponse.java +++ b/src/main/java/com/vonage/client/account/PrefixPricingResponse.java @@ -36,6 +36,6 @@ public List getCountries() { } public static PrefixPricingResponse fromJson(String json) { - return Jsonable.fromJson(json, PrefixPricingResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/account/PricingResponse.java b/src/main/java/com/vonage/client/account/PricingResponse.java index ada2abda5..a3e897a93 100644 --- a/src/main/java/com/vonage/client/account/PricingResponse.java +++ b/src/main/java/com/vonage/client/account/PricingResponse.java @@ -51,6 +51,6 @@ public List getNetworks() { } public static PricingResponse fromJson(String json) { - return Jsonable.fromJson(json, PricingResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/account/SecretResponse.java b/src/main/java/com/vonage/client/account/SecretResponse.java index 0269dc3e2..3513bf34c 100644 --- a/src/main/java/com/vonage/client/account/SecretResponse.java +++ b/src/main/java/com/vonage/client/account/SecretResponse.java @@ -64,6 +64,6 @@ public void updateFromJson(String json) { } public static SecretResponse fromJson(String json) { - return Jsonable.fromJson(json, SecretResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/account/SettingsResponse.java b/src/main/java/com/vonage/client/account/SettingsResponse.java index c53bfa426..876783847 100644 --- a/src/main/java/com/vonage/client/account/SettingsResponse.java +++ b/src/main/java/com/vonage/client/account/SettingsResponse.java @@ -69,6 +69,6 @@ public Integer getMaxApiCallsPerSecond() { } public static SettingsResponse fromJson(String json) { - return Jsonable.fromJson(json, SettingsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/application/Application.java b/src/main/java/com/vonage/client/application/Application.java index 4cfc2e917..b3101aa54 100644 --- a/src/main/java/com/vonage/client/application/Application.java +++ b/src/main/java/com/vonage/client/application/Application.java @@ -96,7 +96,7 @@ public Privacy getPrivacy() { } public static Application fromJson(String json) { - return Jsonable.fromJson(json, Application.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/application/ApplicationList.java b/src/main/java/com/vonage/client/application/ApplicationList.java index 31a373470..38d656c87 100644 --- a/src/main/java/com/vonage/client/application/ApplicationList.java +++ b/src/main/java/com/vonage/client/application/ApplicationList.java @@ -45,6 +45,6 @@ public List getApplications() { } public static ApplicationList fromJson(String json) { - return Jsonable.fromJson(json, ApplicationList.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/incoming/CallEvent.java b/src/main/java/com/vonage/client/incoming/CallEvent.java index 7c99260e9..23e0f8954 100644 --- a/src/main/java/com/vonage/client/incoming/CallEvent.java +++ b/src/main/java/com/vonage/client/incoming/CallEvent.java @@ -80,6 +80,6 @@ public CallStatusDetail getDetailEnum() { } public static CallEvent fromJson(String json) { - return Jsonable.fromJson(json, CallEvent.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/incoming/InputEvent.java b/src/main/java/com/vonage/client/incoming/InputEvent.java index c4249f6f3..d52281739 100644 --- a/src/main/java/com/vonage/client/incoming/InputEvent.java +++ b/src/main/java/com/vonage/client/incoming/InputEvent.java @@ -85,6 +85,6 @@ public SpeechResults getSpeech() { } public static InputEvent fromJson(String json) { - return Jsonable.fromJson(json, InputEvent.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/incoming/MessageEvent.java b/src/main/java/com/vonage/client/incoming/MessageEvent.java index 5ddcaef9b..e5cfb008b 100644 --- a/src/main/java/com/vonage/client/incoming/MessageEvent.java +++ b/src/main/java/com/vonage/client/incoming/MessageEvent.java @@ -125,6 +125,6 @@ public void updateFromJson(String json) { } public static MessageEvent fromJson(String json) { - return Jsonable.fromJson(json, MessageEvent.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/incoming/NotifyEvent.java b/src/main/java/com/vonage/client/incoming/NotifyEvent.java index 85282b5ba..120dcb9cb 100644 --- a/src/main/java/com/vonage/client/incoming/NotifyEvent.java +++ b/src/main/java/com/vonage/client/incoming/NotifyEvent.java @@ -62,6 +62,6 @@ public String toString() { } public static NotifyEvent fromJson(String json) { - return Jsonable.fromJson(json, NotifyEvent.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/incoming/RecordEvent.java b/src/main/java/com/vonage/client/incoming/RecordEvent.java index b6317efa5..0efa83199 100644 --- a/src/main/java/com/vonage/client/incoming/RecordEvent.java +++ b/src/main/java/com/vonage/client/incoming/RecordEvent.java @@ -62,6 +62,6 @@ public Date getTimestamp() { } public static RecordEvent fromJson(String json) { - return Jsonable.fromJson(json, RecordEvent.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/insight/AdvancedInsightResponse.java b/src/main/java/com/vonage/client/insight/AdvancedInsightResponse.java index e379c2df9..bf7effcad 100644 --- a/src/main/java/com/vonage/client/insight/AdvancedInsightResponse.java +++ b/src/main/java/com/vonage/client/insight/AdvancedInsightResponse.java @@ -33,7 +33,7 @@ public class AdvancedInsightResponse extends StandardInsightResponse { private String errorText; public static AdvancedInsightResponse fromJson(String json) { - return Jsonable.fromJson(json, AdvancedInsightResponse.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/insight/BasicInsightResponse.java b/src/main/java/com/vonage/client/insight/BasicInsightResponse.java index c8008a4a3..26cce2e1b 100644 --- a/src/main/java/com/vonage/client/insight/BasicInsightResponse.java +++ b/src/main/java/com/vonage/client/insight/BasicInsightResponse.java @@ -29,7 +29,7 @@ public class BasicInsightResponse implements Jsonable { countryCode, countryCodeIso3, countryName, countryPrefix; public static BasicInsightResponse fromJson(String json) { - return Jsonable.fromJson(json, BasicInsightResponse.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/insight/StandardInsightResponse.java b/src/main/java/com/vonage/client/insight/StandardInsightResponse.java index b77bc0b10..fac389d31 100644 --- a/src/main/java/com/vonage/client/insight/StandardInsightResponse.java +++ b/src/main/java/com/vonage/client/insight/StandardInsightResponse.java @@ -33,7 +33,7 @@ public class StandardInsightResponse extends BasicInsightResponse { private CallerType callerType; public static StandardInsightResponse fromJson(String json) { - return Jsonable.fromJson(json, StandardInsightResponse.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/meetings/Application.java b/src/main/java/com/vonage/client/meetings/Application.java index 1b31ef9b3..3454293f7 100644 --- a/src/main/java/com/vonage/client/meetings/Application.java +++ b/src/main/java/com/vonage/client/meetings/Application.java @@ -65,6 +65,6 @@ public UUID getDefaultThemeId() { * @return An instance of this class with the fields populated, if present. */ public static Application fromJson(String json) { - return Jsonable.fromJson(json, Application.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/meetings/ListRecordingsResponse.java b/src/main/java/com/vonage/client/meetings/ListRecordingsResponse.java index 2bcfc1003..580807ea5 100644 --- a/src/main/java/com/vonage/client/meetings/ListRecordingsResponse.java +++ b/src/main/java/com/vonage/client/meetings/ListRecordingsResponse.java @@ -33,6 +33,6 @@ public List getRecordings() { } public static ListRecordingsResponse fromJson(String json) { - return Jsonable.fromJson(json, ListRecordingsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/meetings/ListRoomsResponse.java b/src/main/java/com/vonage/client/meetings/ListRoomsResponse.java index 823cb03b8..9a18f4809 100644 --- a/src/main/java/com/vonage/client/meetings/ListRoomsResponse.java +++ b/src/main/java/com/vonage/client/meetings/ListRoomsResponse.java @@ -44,6 +44,6 @@ public List getMeetingRooms() { * @return An instance of this class with the fields populated, if present. */ public static ListRoomsResponse fromJson(String json) { - return Jsonable.fromJson(json, ListRoomsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/meetings/MeetingRoom.java b/src/main/java/com/vonage/client/meetings/MeetingRoom.java index 210d205fd..b2e945f44 100644 --- a/src/main/java/com/vonage/client/meetings/MeetingRoom.java +++ b/src/main/java/com/vonage/client/meetings/MeetingRoom.java @@ -251,7 +251,7 @@ public RoomLinks getLinks() { * @return An instance of this class with the fields populated, if present. */ public static MeetingRoom fromJson(String json) { - return Jsonable.fromJson(json, MeetingRoom.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/meetings/MeetingsEventCallback.java b/src/main/java/com/vonage/client/meetings/MeetingsEventCallback.java index b8fc49760..b07f832c2 100644 --- a/src/main/java/com/vonage/client/meetings/MeetingsEventCallback.java +++ b/src/main/java/com/vonage/client/meetings/MeetingsEventCallback.java @@ -197,6 +197,6 @@ public Boolean getIsHost() { * @throws VonageResponseParseException If the response could not be deserialized. */ public static MeetingsEventCallback fromJson(String json) { - return Jsonable.fromJson(json, MeetingsEventCallback.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/meetings/Recording.java b/src/main/java/com/vonage/client/meetings/Recording.java index bae495d74..0eeac152f 100644 --- a/src/main/java/com/vonage/client/meetings/Recording.java +++ b/src/main/java/com/vonage/client/meetings/Recording.java @@ -101,6 +101,6 @@ public URI getUrl() { * @return An instance of this class with the fields populated, if present. */ public static Recording fromJson(String json) { - return Jsonable.fromJson(json, Recording.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/meetings/Theme.java b/src/main/java/com/vonage/client/meetings/Theme.java index 832d60cd6..cf7ea1458 100644 --- a/src/main/java/com/vonage/client/meetings/Theme.java +++ b/src/main/java/com/vonage/client/meetings/Theme.java @@ -235,7 +235,7 @@ public String toJson() { * @return An instance of this class with the fields populated, if present. */ public static Theme fromJson(String json) { - return Jsonable.fromJson(json, Theme.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/messages/InboundMessage.java b/src/main/java/com/vonage/client/messages/InboundMessage.java index e5f7c4b97..23744ea56 100644 --- a/src/main/java/com/vonage/client/messages/InboundMessage.java +++ b/src/main/java/com/vonage/client/messages/InboundMessage.java @@ -300,6 +300,6 @@ public SmsInboundMetadata getSmsMetadata() { * @throws com.vonage.client.VonageResponseParseException If the response could not be deserialized. */ public static InboundMessage fromJson(String json) { - return Jsonable.fromJson(json, InboundMessage.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/messages/MessageResponse.java b/src/main/java/com/vonage/client/messages/MessageResponse.java index 6bd408b25..3c41254fe 100644 --- a/src/main/java/com/vonage/client/messages/MessageResponse.java +++ b/src/main/java/com/vonage/client/messages/MessageResponse.java @@ -56,6 +56,6 @@ public String toString() { * @return An instance of this class with the fields populated, if present. */ public static MessageResponse fromJson(String json) { - return Jsonable.fromJson(json, MessageResponse.class); + 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 f08300206..549884bf8 100644 --- a/src/main/java/com/vonage/client/messages/MessageStatus.java +++ b/src/main/java/com/vonage/client/messages/MessageStatus.java @@ -16,11 +16,7 @@ package com.vonage.client.messages; import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.vonage.client.Jsonable; -import com.vonage.client.VonageUnexpectedException; -import java.io.IOException; import java.net.URI; import java.time.Instant; import java.util.Currency; @@ -304,14 +300,7 @@ public Usage getUsage() { * @return An instance of this class with the fields populated, if present. */ public static MessageStatus fromJson(String json) { - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.registerModule(new JavaTimeModule()); - return mapper.readValue(json, MessageStatus.class); - } - catch (IOException ex) { - throw new VonageUnexpectedException("Failed to produce MessageStatus from json.", ex); - } + return Jsonable.fromJson(json); } @Override diff --git a/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java b/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java index dfb76f5d2..72be569c9 100644 --- a/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java +++ b/src/main/java/com/vonage/client/numbers/ListNumbersResponse.java @@ -35,6 +35,6 @@ public OwnedNumber[] getNumbers() { } public static ListNumbersResponse fromJson(String json) { - return Jsonable.fromJson(json, ListNumbersResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java b/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java index 6ae442917..a01bf8281 100644 --- a/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java +++ b/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java @@ -42,7 +42,7 @@ public AvailableNumber[] getNumbers() { } public static SearchNumbersResponse fromJson(String json) { - return Jsonable.fromJson(json, SearchNumbersResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/proactiveconnect/ContactsList.java b/src/main/java/com/vonage/client/proactiveconnect/ContactsList.java index 9fea84ac7..0c360cfdd 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/ContactsList.java +++ b/src/main/java/com/vonage/client/proactiveconnect/ContactsList.java @@ -171,7 +171,7 @@ public SyncStatus getSyncStatus() { * @return An instance of this class with the fields populated, if present. */ public static ContactsList fromJson(String json) { - return Jsonable.fromJson(json, ContactsList.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/proactiveconnect/Event.java b/src/main/java/com/vonage/client/proactiveconnect/Event.java index 80759ec88..76df6749e 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/Event.java +++ b/src/main/java/com/vonage/client/proactiveconnect/Event.java @@ -156,6 +156,6 @@ public EventType getType() { * @return An instance of this class with the fields populated, if present. */ public static Event fromJson(String json) { - return Jsonable.fromJson(json, Event.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/proactiveconnect/ListEventsResponse.java b/src/main/java/com/vonage/client/proactiveconnect/ListEventsResponse.java index c3a7b62e5..47d5fec2f 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/ListEventsResponse.java +++ b/src/main/java/com/vonage/client/proactiveconnect/ListEventsResponse.java @@ -59,6 +59,6 @@ public List getEvents() { * @return An instance of this class with the fields populated, if present. */ public static ListEventsResponse fromJson(String json) { - return Jsonable.fromJson(json, ListEventsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/proactiveconnect/ListItem.java b/src/main/java/com/vonage/client/proactiveconnect/ListItem.java index 17cba4e5f..852c4be39 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/ListItem.java +++ b/src/main/java/com/vonage/client/proactiveconnect/ListItem.java @@ -93,6 +93,6 @@ public UUID getListId() { * @return An instance of this class with the fields populated, if present. */ public static ListItem fromJson(String json) { - return Jsonable.fromJson(json, ListItem.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/proactiveconnect/ListItemsResponse.java b/src/main/java/com/vonage/client/proactiveconnect/ListItemsResponse.java index b49a68df0..42f63bb36 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/ListItemsResponse.java +++ b/src/main/java/com/vonage/client/proactiveconnect/ListItemsResponse.java @@ -60,6 +60,6 @@ public List getItems() { * @return An instance of this class with the fields populated, if present. */ public static ListItemsResponse fromJson(String json) { - return Jsonable.fromJson(json, ListItemsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/proactiveconnect/ListListsResponse.java b/src/main/java/com/vonage/client/proactiveconnect/ListListsResponse.java index 8b5215d01..23083aecb 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/ListListsResponse.java +++ b/src/main/java/com/vonage/client/proactiveconnect/ListListsResponse.java @@ -58,6 +58,6 @@ public List getLists() { * @return An instance of this class with the fields populated, if present. */ public static ListListsResponse fromJson(String json) { - return Jsonable.fromJson(json, ListListsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/proactiveconnect/SyncStatus.java b/src/main/java/com/vonage/client/proactiveconnect/SyncStatus.java index 60d0cb2cc..8812c3287 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/SyncStatus.java +++ b/src/main/java/com/vonage/client/proactiveconnect/SyncStatus.java @@ -90,6 +90,6 @@ public Boolean getDirty() { * @return An instance of this class with the fields populated, if present. */ public static SyncStatus fromJson(String json) { - return Jsonable.fromJson(json, SyncStatus.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/proactiveconnect/UploadListItemsResponse.java b/src/main/java/com/vonage/client/proactiveconnect/UploadListItemsResponse.java index 4fe91bedd..0e5fb88ea 100644 --- a/src/main/java/com/vonage/client/proactiveconnect/UploadListItemsResponse.java +++ b/src/main/java/com/vonage/client/proactiveconnect/UploadListItemsResponse.java @@ -68,6 +68,6 @@ public Integer getDeleted() { * @return An instance of this class with the fields populated, if present. */ public static UploadListItemsResponse fromJson(String json) { - return Jsonable.fromJson(json, UploadListItemsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/sms/SmsSubmissionResponse.java b/src/main/java/com/vonage/client/sms/SmsSubmissionResponse.java index d1018464e..f54d09001 100644 --- a/src/main/java/com/vonage/client/sms/SmsSubmissionResponse.java +++ b/src/main/java/com/vonage/client/sms/SmsSubmissionResponse.java @@ -26,7 +26,7 @@ public class SmsSubmissionResponse implements Jsonable { private List messages; public static SmsSubmissionResponse fromJson(String json) { - return Jsonable.fromJson(json, SmsSubmissionResponse.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/subaccounts/Account.java b/src/main/java/com/vonage/client/subaccounts/Account.java index 660a5030c..f51271a8f 100644 --- a/src/main/java/com/vonage/client/subaccounts/Account.java +++ b/src/main/java/com/vonage/client/subaccounts/Account.java @@ -131,6 +131,6 @@ public BigDecimal getCreditLimit() { * @return An instance of this class with the fields populated, if present. */ public static Account fromJson(String json) { - return Jsonable.fromJson(json, Account.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/subaccounts/ListSubaccountsResponse.java b/src/main/java/com/vonage/client/subaccounts/ListSubaccountsResponse.java index 5a7b098fc..7d38755f1 100644 --- a/src/main/java/com/vonage/client/subaccounts/ListSubaccountsResponse.java +++ b/src/main/java/com/vonage/client/subaccounts/ListSubaccountsResponse.java @@ -64,6 +64,6 @@ public List getSubaccounts() { * @return An instance of this class with the fields populated, if present. */ public static ListSubaccountsResponse fromJson(String json) { - return Jsonable.fromJson(json, ListSubaccountsResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/subaccounts/MoneyTransfer.java b/src/main/java/com/vonage/client/subaccounts/MoneyTransfer.java index 42315747f..c57464fac 100644 --- a/src/main/java/com/vonage/client/subaccounts/MoneyTransfer.java +++ b/src/main/java/com/vonage/client/subaccounts/MoneyTransfer.java @@ -91,7 +91,7 @@ public String getReference() { * @return An instance of this class with the fields populated, if present. */ public static MoneyTransfer fromJson(String json) { - return Jsonable.fromJson(json, MoneyTransfer.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/subaccounts/NumberTransfer.java b/src/main/java/com/vonage/client/subaccounts/NumberTransfer.java index a32aed20a..b289976eb 100644 --- a/src/main/java/com/vonage/client/subaccounts/NumberTransfer.java +++ b/src/main/java/com/vonage/client/subaccounts/NumberTransfer.java @@ -64,7 +64,7 @@ public String getNumber() { * @return An instance of this class with the fields populated, if present. */ public static NumberTransfer fromJson(String json) { - return Jsonable.fromJson(json, NumberTransfer.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/users/User.java b/src/main/java/com/vonage/client/users/User.java index cb291f80a..3e3257c4d 100644 --- a/src/main/java/com/vonage/client/users/User.java +++ b/src/main/java/com/vonage/client/users/User.java @@ -121,7 +121,7 @@ public boolean equals(Object o) { */ @JsonCreator public static User fromJson(String json) { - return Jsonable.fromJson(json, User.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/verify/ControlResponse.java b/src/main/java/com/vonage/client/verify/ControlResponse.java index 962dfd9fd..92dd5f368 100644 --- a/src/main/java/com/vonage/client/verify/ControlResponse.java +++ b/src/main/java/com/vonage/client/verify/ControlResponse.java @@ -54,6 +54,6 @@ public String getErrorText() { } public static ControlResponse fromJson(String json) { - return Jsonable.fromJson(json, ControlResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java b/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java index ce2d9d3d2..ce9748e5f 100644 --- a/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java +++ b/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java @@ -84,6 +84,6 @@ public void updateFromJson(String json) { } public static SearchVerifyResponse fromJson(String json) { - return Jsonable.fromJson(json, SearchVerifyResponse.class); + 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 5c747d5d3..b163b2818 100644 --- a/src/main/java/com/vonage/client/verify2/VerificationCallback.java +++ b/src/main/java/com/vonage/client/verify2/VerificationCallback.java @@ -179,6 +179,6 @@ public URI getSilentAuthUrl() { * @throws VonageResponseParseException If the response could not be deserialized. */ public static VerificationCallback fromJson(String json) { - return Jsonable.fromJson(json, VerificationCallback.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/voice/Call.java b/src/main/java/com/vonage/client/voice/Call.java index 195b557fa..aadf462a1 100644 --- a/src/main/java/com/vonage/client/voice/Call.java +++ b/src/main/java/com/vonage/client/voice/Call.java @@ -250,7 +250,7 @@ public Collection getNcco() { * @return An instance of this class with the fields populated, if present. */ public static Call fromJson(String json) { - return Jsonable.fromJson(json, Call.class); + return Jsonable.fromJson(json); } /** diff --git a/src/main/java/com/vonage/client/voice/CallEvent.java b/src/main/java/com/vonage/client/voice/CallEvent.java index da56a7965..73bc743fc 100644 --- a/src/main/java/com/vonage/client/voice/CallEvent.java +++ b/src/main/java/com/vonage/client/voice/CallEvent.java @@ -75,6 +75,6 @@ public void setDirection(CallDirection direction) { * @return An instance of this class with the fields populated, if present. */ public static CallEvent fromJson(String json) { - return Jsonable.fromJson(json, CallEvent.class); + return Jsonable.fromJson(json); } } \ No newline at end of file diff --git a/src/main/java/com/vonage/client/voice/CallInfo.java b/src/main/java/com/vonage/client/voice/CallInfo.java index 91beb30a4..570569b47 100644 --- a/src/main/java/com/vonage/client/voice/CallInfo.java +++ b/src/main/java/com/vonage/client/voice/CallInfo.java @@ -186,6 +186,6 @@ public String toString() { * @return An instance of this class with the fields populated, if present. */ public static CallInfo fromJson(String json) { - return Jsonable.fromJson(json, CallInfo.class); + return Jsonable.fromJson(json); } } \ No newline at end of file diff --git a/src/main/java/com/vonage/client/voice/CallInfoPage.java b/src/main/java/com/vonage/client/voice/CallInfoPage.java index b73c69362..b36fc6b3e 100644 --- a/src/main/java/com/vonage/client/voice/CallInfoPage.java +++ b/src/main/java/com/vonage/client/voice/CallInfoPage.java @@ -65,6 +65,6 @@ public Iterator iterator() { * @return An instance of this class with the fields populated, if present. */ public static CallInfoPage fromJson(String json) { - return Jsonable.fromJson(json, CallInfoPage.class); + return Jsonable.fromJson(json); } } \ No newline at end of file diff --git a/src/main/java/com/vonage/client/voice/DtmfResponse.java b/src/main/java/com/vonage/client/voice/DtmfResponse.java index ed73ff5ca..cc76a3b77 100644 --- a/src/main/java/com/vonage/client/voice/DtmfResponse.java +++ b/src/main/java/com/vonage/client/voice/DtmfResponse.java @@ -48,6 +48,6 @@ public String getMessage() { * @return An instance of this class with the fields populated, if present. */ public static DtmfResponse fromJson(String json) { - return Jsonable.fromJson(json, DtmfResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/voice/ModifyCallResponse.java b/src/main/java/com/vonage/client/voice/ModifyCallResponse.java index 131b21627..4d7b69fd1 100644 --- a/src/main/java/com/vonage/client/voice/ModifyCallResponse.java +++ b/src/main/java/com/vonage/client/voice/ModifyCallResponse.java @@ -46,6 +46,6 @@ public String getMessage() { * @return An instance of this class with the fields populated, if present. */ public static ModifyCallResponse fromJson(String json) { - return Jsonable.fromJson(json, ModifyCallResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/voice/StreamResponse.java b/src/main/java/com/vonage/client/voice/StreamResponse.java index 5041b5537..2f12671ad 100644 --- a/src/main/java/com/vonage/client/voice/StreamResponse.java +++ b/src/main/java/com/vonage/client/voice/StreamResponse.java @@ -48,6 +48,6 @@ public String getMessage() { * @return An instance of this class with the fields populated, if present. */ public static StreamResponse fromJson(String json) { - return Jsonable.fromJson(json, StreamResponse.class); + return Jsonable.fromJson(json); } } diff --git a/src/main/java/com/vonage/client/voice/TalkResponse.java b/src/main/java/com/vonage/client/voice/TalkResponse.java index ca5f24250..8c17c8720 100644 --- a/src/main/java/com/vonage/client/voice/TalkResponse.java +++ b/src/main/java/com/vonage/client/voice/TalkResponse.java @@ -48,6 +48,6 @@ public String getMessage() { * @return An instance of this class with the fields populated, if present. */ public static TalkResponse fromJson(String json) { - return Jsonable.fromJson(json, TalkResponse.class); + return Jsonable.fromJson(json); } }