From 4f66d203c2339882350d785467cd67ffce55d670 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 8 Sep 2021 21:46:13 +0000 Subject: [PATCH] [Librarian] Regenerated @ fdad267944635962308083659322c23f28226702 --- CHANGES.md | 18 ++ .../rest/insights/v1/CallSummariesReader.java | 38 ++-- .../rest/messaging/v1/BrandRegistration.java | 27 ++- .../v1/BrandRegistrationCreator.java | 20 +++ .../messaging/v1/service/UsAppToPerson.java | 23 ++- .../rest/taskrouter/v1/WorkspaceCreator.java | 11 +- .../rest/taskrouter/v1/WorkspaceUpdater.java | 18 +- .../rest/verify/v2/VerificationTemplate.java | 166 ++++++++++++++++++ .../verify/v2/VerificationTemplateReader.java | 160 +++++++++++++++++ .../rest/insights/v1/CallSummariesTest.java | 40 ++++- .../messaging/v1/BrandRegistrationTest.java | 6 +- .../v1/service/UsAppToPersonTest.java | 6 +- .../v1/service/UsAppToPersonUsecaseTest.java | 4 +- .../twilio/rest/pricing/v2/CountryTest.java | 2 +- .../twilio/rest/pricing/v2/NumberTest.java | 14 +- .../verify/v2/VerificationTemplateTest.java | 70 ++++++++ 16 files changed, 578 insertions(+), 45 deletions(-) create mode 100644 src/main/java/com/twilio/rest/verify/v2/VerificationTemplate.java create mode 100644 src/main/java/com/twilio/rest/verify/v2/VerificationTemplateReader.java create mode 100644 src/test/java/com/twilio/rest/verify/v2/VerificationTemplateTest.java diff --git a/CHANGES.md b/CHANGES.md index c86762dbd3..7f94d8fb6b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,24 @@ twilio-java changelog ===================== +[2021-09-08] Version 8.19.1 +--------------------------- +**Library - Fix** +- [PR #644](https://github.com/twilio/twilio-java/pull/644): deploy issues. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)! + +**Api** +- Revert adding `siprec` resource +- Add `siprec` resource + +**Messaging** +- Add 'mock' as an optional field to brand_registration api +- Add 'mock' as an optional field to us_app_to_person api +- Adds more Use Cases in us_app_to_person_usecase api transaction and updates us_app_to_person_usecase docs + +**Verify** +- Verify List Templates API endpoint added. + + [2021-08-25] Version 8.19.0 --------------------------- **Library - Chore** diff --git a/src/main/java/com/twilio/rest/insights/v1/CallSummariesReader.java b/src/main/java/com/twilio/rest/insights/v1/CallSummariesReader.java index 0a32f3a650..4bd80ccfe1 100644 --- a/src/main/java/com/twilio/rest/insights/v1/CallSummariesReader.java +++ b/src/main/java/com/twilio/rest/insights/v1/CallSummariesReader.java @@ -34,9 +34,9 @@ public class CallSummariesReader extends Reader { private Boolean hasTag; private String startTime; private String endTime; - private List callType; - private List callState; - private CallSummaries.CallDirection direction; + private List callType; + private List callState; + private List direction; private CallSummaries.ProcessingStateRequest processingState; private CallSummaries.SortBy sortBy; private String subaccount; @@ -229,7 +229,7 @@ public CallSummariesReader setEndTime(final String endTime) { * @param callType The call_type * @return this */ - public CallSummariesReader setCallType(final List callType) { + public CallSummariesReader setCallType(final List callType) { this.callType = callType; return this; } @@ -240,7 +240,7 @@ public CallSummariesReader setCallType(final List callType) { * @param callType The call_type * @return this */ - public CallSummariesReader setCallType(final String callType) { + public CallSummariesReader setCallType(final CallSummaries.CallType callType) { return setCallType(Promoter.listOfOne(callType)); } @@ -250,7 +250,7 @@ public CallSummariesReader setCallType(final String callType) { * @param callState The call_state * @return this */ - public CallSummariesReader setCallState(final List callState) { + public CallSummariesReader setCallState(final List callState) { this.callState = callState; return this; } @@ -261,7 +261,7 @@ public CallSummariesReader setCallState(final List callState) { * @param callState The call_state * @return this */ - public CallSummariesReader setCallState(final String callState) { + public CallSummariesReader setCallState(final CallSummaries.CallState callState) { return setCallState(Promoter.listOfOne(callState)); } @@ -271,11 +271,21 @@ public CallSummariesReader setCallState(final String callState) { * @param direction The direction * @return this */ - public CallSummariesReader setDirection(final CallSummaries.CallDirection direction) { + public CallSummariesReader setDirection(final List direction) { this.direction = direction; return this; } + /** + * The direction. + * + * @param direction The direction + * @return this + */ + public CallSummariesReader setDirection(final CallSummaries.CallDirection direction) { + return setDirection(Promoter.listOfOne(direction)); + } + /** * The processing_state. * @@ -493,19 +503,21 @@ private void addQueryParams(final Request request) { } if (callType != null) { - for (String prop : callType) { - request.addQueryParam("CallType", prop); + for (CallSummaries.CallType prop : callType) { + request.addQueryParam("CallType", prop.toString()); } } if (callState != null) { - for (String prop : callState) { - request.addQueryParam("CallState", prop); + for (CallSummaries.CallState prop : callState) { + request.addQueryParam("CallState", prop.toString()); } } if (direction != null) { - request.addQueryParam("Direction", direction.toString()); + for (CallSummaries.CallDirection prop : direction) { + request.addQueryParam("Direction", prop.toString()); + } } if (processingState != null) { diff --git a/src/main/java/com/twilio/rest/messaging/v1/BrandRegistration.java b/src/main/java/com/twilio/rest/messaging/v1/BrandRegistration.java index 53cfae0db2..3e35a51228 100644 --- a/src/main/java/com/twilio/rest/messaging/v1/BrandRegistration.java +++ b/src/main/java/com/twilio/rest/messaging/v1/BrandRegistration.java @@ -40,7 +40,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class BrandRegistration extends Resource { - private static final long serialVersionUID = 22690009711624L; + private static final long serialVersionUID = 5353915230753L; public enum Status { PENDING("PENDING"), @@ -149,6 +149,7 @@ public static BrandRegistration fromJson(final InputStream json, final ObjectMap private final String failureReason; private final URI url; private final Integer brandScore; + private final Boolean mock; @JsonCreator private BrandRegistration(@JsonProperty("sid") @@ -174,7 +175,9 @@ private BrandRegistration(@JsonProperty("sid") @JsonProperty("url") final URI url, @JsonProperty("brand_score") - final Integer brandScore) { + final Integer brandScore, + @JsonProperty("mock") + final Boolean mock) { this.sid = sid; this.accountSid = accountSid; this.customerProfileBundleSid = customerProfileBundleSid; @@ -187,6 +190,7 @@ private BrandRegistration(@JsonProperty("sid") this.failureReason = failureReason; this.url = url; this.brandScore = brandScore; + this.mock = mock; } /** @@ -297,6 +301,19 @@ public final Integer getBrandScore() { return this.brandScore; } + /** + * Returns A boolean that specifies whether brand should be a mock or not. If + * true, brand will be registered as a mock brand. Defaults to false if no value + * is provided.. + * + * @return A boolean that specifies whether brand should be a mock or not. If + * true, brand will be registered as a mock brand. Defaults to false if + * no value is provided. + */ + public final Boolean getMock() { + return this.mock; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -320,7 +337,8 @@ public boolean equals(final Object o) { Objects.equals(tcrId, other.tcrId) && Objects.equals(failureReason, other.failureReason) && Objects.equals(url, other.url) && - Objects.equals(brandScore, other.brandScore); + Objects.equals(brandScore, other.brandScore) && + Objects.equals(mock, other.mock); } @Override @@ -336,6 +354,7 @@ public int hashCode() { tcrId, failureReason, url, - brandScore); + brandScore, + mock); } } \ No newline at end of file diff --git a/src/main/java/com/twilio/rest/messaging/v1/BrandRegistrationCreator.java b/src/main/java/com/twilio/rest/messaging/v1/BrandRegistrationCreator.java index 02ce84c209..80cf69a65e 100644 --- a/src/main/java/com/twilio/rest/messaging/v1/BrandRegistrationCreator.java +++ b/src/main/java/com/twilio/rest/messaging/v1/BrandRegistrationCreator.java @@ -25,6 +25,7 @@ public class BrandRegistrationCreator extends Creator { private final String customerProfileBundleSid; private final String a2PProfileBundleSid; private String brandType; + private Boolean mock; /** * Construct a new BrandRegistrationCreator. @@ -50,6 +51,21 @@ public BrandRegistrationCreator setBrandType(final String brandType) { return this; } + /** + * A boolean that specifies whether brand should be a mock or not. If true, + * brand will be registered as a mock brand. Defaults to false if no value is + * provided.. + * + * @param mock A boolean that specifies whether brand should be a mock or not. + * If true, brand will be registered as a mock brand. Defaults to + * false if no value is provided. + * @return this + */ + public BrandRegistrationCreator setMock(final Boolean mock) { + this.mock = mock; + return this; + } + /** * Make the request to the Twilio API to perform the create. * @@ -98,5 +114,9 @@ private void addPostParams(final Request request) { if (brandType != null) { request.addPostParam("BrandType", brandType); } + + if (mock != null) { + request.addPostParam("Mock", mock.toString()); + } } } \ No newline at end of file diff --git a/src/main/java/com/twilio/rest/messaging/v1/service/UsAppToPerson.java b/src/main/java/com/twilio/rest/messaging/v1/service/UsAppToPerson.java index 95d6ce0c34..d182f66524 100644 --- a/src/main/java/com/twilio/rest/messaging/v1/service/UsAppToPerson.java +++ b/src/main/java/com/twilio/rest/messaging/v1/service/UsAppToPerson.java @@ -41,7 +41,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class UsAppToPerson extends Resource { - private static final long serialVersionUID = 131982293842514L; + private static final long serialVersionUID = 156924875301398L; /** * Create a UsAppToPersonCreator to execute create. @@ -161,6 +161,7 @@ public static UsAppToPerson fromJson(final InputStream json, final ObjectMapper private final ZonedDateTime dateCreated; private final ZonedDateTime dateUpdated; private final URI url; + private final Boolean mock; @JsonCreator private UsAppToPerson(@JsonProperty("sid") @@ -194,7 +195,9 @@ private UsAppToPerson(@JsonProperty("sid") @JsonProperty("date_updated") final String dateUpdated, @JsonProperty("url") - final URI url) { + final URI url, + @JsonProperty("mock") + final Boolean mock) { this.sid = sid; this.accountSid = accountSid; this.brandRegistrationSid = brandRegistrationSid; @@ -211,6 +214,7 @@ private UsAppToPerson(@JsonProperty("sid") this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); this.url = url; + this.mock = mock; } /** @@ -360,6 +364,15 @@ public final URI getUrl() { return this.url; } + /** + * Returns A boolean that specifies whether campaign is a mock or not.. + * + * @return A boolean that specifies whether campaign is a mock or not. + */ + public final Boolean getMock() { + return this.mock; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -387,7 +400,8 @@ public boolean equals(final Object o) { Objects.equals(rateLimits, other.rateLimits) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && - Objects.equals(url, other.url); + Objects.equals(url, other.url) && + Objects.equals(mock, other.mock); } @Override @@ -407,6 +421,7 @@ public int hashCode() { rateLimits, dateCreated, dateUpdated, - url); + url, + mock); } } \ No newline at end of file diff --git a/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceCreator.java b/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceCreator.java index a139201547..bfccf6f816 100644 --- a/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceCreator.java +++ b/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceCreator.java @@ -81,11 +81,12 @@ public WorkspaceCreator setEventsFilter(final String eventsFilter) { /** * Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or - * `false` to disable it. The default is `false`. Multi-tasking allows Workers - * to handle multiple Tasks simultaneously. When enabled (`true`), each Worker - * can receive parallel reservations up to the per-channel maximums defined in - * the Workers section. Otherwise, each Worker will only receive a new - * reservation when the previous task is completed. Learn more at Multitasking.. * * @param multiTaskEnabled Whether multi-tasking is enabled diff --git a/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceUpdater.java b/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceUpdater.java index 6e0401eab0..eb57f9880a 100644 --- a/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceUpdater.java +++ b/src/main/java/com/twilio/rest/taskrouter/v1/WorkspaceUpdater.java @@ -106,11 +106,15 @@ public WorkspaceUpdater setFriendlyName(final String friendlyName) { /** * Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or - * `false` to disable it. The default is `false`. Multi-tasking allows Workers - * to handle multiple Tasks simultaneously. When enabled (`true`), each Worker - * can receive parallel reservations up to the per-channel maximums defined in - * the Workers section. Otherwise, each Worker will only receive a new - * reservation when the previous task is completed. Learn more at Multitasking.. * * @param multiTaskEnabled Whether multi-tasking is enabled @@ -137,8 +141,8 @@ public WorkspaceUpdater setTimeoutActivitySid(final String timeoutActivitySid) { /** * The type of TaskQueue to prioritize when Workers are receiving Tasks from - * both types of TaskQueues. Can be: `LIFO` or `FIFO` and the default is `FIFO`. - * For more information, see Queue * Ordering.. * diff --git a/src/main/java/com/twilio/rest/verify/v2/VerificationTemplate.java b/src/main/java/com/twilio/rest/verify/v2/VerificationTemplate.java new file mode 100644 index 0000000000..37e185f3ac --- /dev/null +++ b/src/main/java/com/twilio/rest/verify/v2/VerificationTemplate.java @@ -0,0 +1,166 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +package com.twilio.rest.verify.v2; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.Converter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; +import lombok.ToString; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Objects; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class VerificationTemplate extends Resource { + private static final long serialVersionUID = 55612496215958L; + + /** + * Create a VerificationTemplateReader to execute read. + * + * @return VerificationTemplateReader capable of executing the read + */ + public static VerificationTemplateReader reader() { + return new VerificationTemplateReader(); + } + + /** + * Converts a JSON String into a VerificationTemplate object using the provided + * ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return VerificationTemplate object represented by the provided JSON + */ + public static VerificationTemplate fromJson(final String json, final ObjectMapper objectMapper) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, VerificationTemplate.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a VerificationTemplate object using the + * provided ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return VerificationTemplate object represented by the provided JSON + */ + public static VerificationTemplate fromJson(final InputStream json, final ObjectMapper objectMapper) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, VerificationTemplate.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String sid; + private final String accountSid; + private final String friendlyName; + private final Map translations; + + @JsonCreator + private VerificationTemplate(@JsonProperty("sid") + final String sid, + @JsonProperty("account_sid") + final String accountSid, + @JsonProperty("friendly_name") + final String friendlyName, + @JsonProperty("translations") + final Map translations) { + this.sid = sid; + this.accountSid = accountSid; + this.friendlyName = friendlyName; + this.translations = translations; + } + + /** + * Returns A string that uniquely identifies this Template. + * + * @return A string that uniquely identifies this Template + */ + public final String getSid() { + return this.sid; + } + + /** + * Returns Account Sid. + * + * @return Account Sid + */ + public final String getAccountSid() { + return this.accountSid; + } + + /** + * Returns A string to describe the verification template. + * + * @return A string to describe the verification template + */ + public final String getFriendlyName() { + return this.friendlyName; + } + + /** + * Returns Ojbect with the template translations.. + * + * @return Ojbect with the template translations. + */ + public final Map getTranslations() { + return this.translations; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + VerificationTemplate other = (VerificationTemplate) o; + + return Objects.equals(sid, other.sid) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(friendlyName, other.friendlyName) && + Objects.equals(translations, other.translations); + } + + @Override + public int hashCode() { + return Objects.hash(sid, + accountSid, + friendlyName, + translations); + } +} \ No newline at end of file diff --git a/src/main/java/com/twilio/rest/verify/v2/VerificationTemplateReader.java b/src/main/java/com/twilio/rest/verify/v2/VerificationTemplateReader.java new file mode 100644 index 0000000000..0766cfb7ec --- /dev/null +++ b/src/main/java/com/twilio/rest/verify/v2/VerificationTemplateReader.java @@ -0,0 +1,160 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +package com.twilio.rest.verify.v2; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class VerificationTemplateReader extends Reader { + private String friendlyName; + + /** + * String filter used to query templates with a given friendly name. + * + * @param friendlyName Filter templates using friendly name + * @return this + */ + public VerificationTemplateReader setFriendlyName(final String friendlyName) { + this.friendlyName = friendlyName; + return this; + } + + /** + * Make the request to the Twilio API to perform the read. + * + * @param client TwilioRestClient with which to make the request + * @return VerificationTemplate ResourceSet + */ + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + /** + * Make the request to the Twilio API to perform the read. + * + * @param client TwilioRestClient with which to make the request + * @return VerificationTemplate ResourceSet + */ + @Override + @SuppressWarnings("checkstyle:linelength") + public Page firstPage(final TwilioRestClient client) { + Request request = new Request( + HttpMethod.GET, + Domains.VERIFY.toString(), + "/v2/Templates" + ); + + addQueryParams(request); + return pageForRequest(client, request); + } + + /** + * Retrieve the target page from the Twilio API. + * + * @param targetUrl API-generated URL for the requested results page + * @param client TwilioRestClient with which to make the request + * @return VerificationTemplate ResourceSet + */ + @Override + @SuppressWarnings("checkstyle:linelength") + public Page getPage(final String targetUrl, final TwilioRestClient client) { + Request request = new Request( + HttpMethod.GET, + targetUrl + ); + + return pageForRequest(client, request); + } + + /** + * Retrieve the next page from the Twilio API. + * + * @param page current page + * @param client TwilioRestClient with which to make the request + * @return Next Page + */ + @Override + public Page nextPage(final Page page, + final TwilioRestClient client) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.VERIFY.toString()) + ); + return pageForRequest(client, request); + } + + /** + * Retrieve the previous page from the Twilio API. + * + * @param page current page + * @param client TwilioRestClient with which to make the request + * @return Previous Page + */ + @Override + public Page previousPage(final Page page, + final TwilioRestClient client) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.VERIFY.toString()) + ); + return pageForRequest(client, request); + } + + /** + * Generate a Page of VerificationTemplate Resources for a given request. + * + * @param client TwilioRestClient with which to make the request + * @param request Request to generate a page for + * @return Page for the Request + */ + private Page pageForRequest(final TwilioRestClient client, final Request request) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException("VerificationTemplate read failed: Unable to connect to server"); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper()); + if (restException == null) { + throw new ApiException("Server Error, no content"); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "templates", + response.getContent(), + VerificationTemplate.class, + client.getObjectMapper() + ); + } + + /** + * Add the requested query string arguments to the Request. + * + * @param request Request to add query string arguments to + */ + private void addQueryParams(final Request request) { + if (friendlyName != null) { + request.addQueryParam("FriendlyName", friendlyName); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} \ No newline at end of file diff --git a/src/test/java/com/twilio/rest/insights/v1/CallSummariesTest.java b/src/test/java/com/twilio/rest/insights/v1/CallSummariesTest.java index 75896fd75e..a9b208d4b7 100644 --- a/src/test/java/com/twilio/rest/insights/v1/CallSummariesTest.java +++ b/src/test/java/com/twilio/rest/insights/v1/CallSummariesTest.java @@ -69,10 +69,46 @@ public void testReadEmptyResponse() { } @Test - public void testReadFullResponse() { + public void testReadWithCarrierResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"meta\": {\"page\": 0,\"page_size\": 25,\"first_page_url\": \"https://insights.twilio.com/v1/Voice/Summaries?PageSize=25&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"key\": \"call_summaries\",\"url\": \"https://insights.twilio.com/v1/Voice/Summaries?PageSize=25&Page=0\"},\"call_summaries\": [{\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"created_time\": \"2021-06-09T02:51:44Z\",\"start_time\": \"2018-12-20T20:00:00Z\",\"end_time\": \"2018-12-20T20:00:26Z\",\"duration\": 27,\"connect_duration\": 26,\"call_type\": \"client\",\"call_state\": \"completed\",\"to\": {},\"from\": {},\"processing_state\": \"complete\",\"sdk_edge\": {},\"client_edge\": {},\"tags\": [\"high_packet_loss\",\"high_jitter\"],\"attributes\": {},\"properties\": {},\"trust\": {},\"url\": \"https://insights.twilio.com/v1/Voice/Summaries\",\"sip_edge\": {},\"carrier_edge\": {}}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"meta\": {\"page\": 0,\"page_size\": 25,\"first_page_url\": \"https://insights.twilio.com/v1/Voice/Summaries?ToCarrier=AT%26T+Wireless&StartTime=4h&PageSize=25&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"key\": \"call_summaries\",\"url\": \"https://insights.twilio.com/v1/Voice/Summaries?ToCarrier=AT%26T+Wireless&StartTime=4h&PageSize=25&Page=0\"},\"call_summaries\": [{\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"created_time\": \"2021-08-25T03:40:25Z\",\"start_time\": \"2021-08-25T03:40:25Z\",\"end_time\": \"2021-08-25T03:40:45Z\",\"duration\": 20,\"connect_duration\": 20,\"call_type\": \"carrier\",\"call_state\": \"completed\",\"from\": {\"caller\": \"+15555555555\",\"carrier\": \"T-Mobile USA, Inc.\",\"connection\": \"mobile\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 40.83885,\"lon\": -74.04568},\"country_code\": \"US\"},\"to\": {\"callee\": \"+15555555556\",\"carrier\": \"AT&T Wireless\",\"connection\": \"mobile\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 33.42767,\"lon\": -86.886475},\"country_code\": \"US\"},\"processing_state\": \"complete\",\"sdk_edge\": null,\"sip_edge\": null,\"client_edge\": null,\"carrier_edge\": {\"properties\": {\"media_region\": \"us1\",\"signaling_region\": \"us1\",\"edge_location\": \"xxxxx\",\"direction\": \"inbound\"},\"metrics\": {\"inbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_received\": 202,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 1.48209,\"avg\": 0.483035}},\"outbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_sent\": 218,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 0.51868,\"avg\": 0.364434}}}},\"tags\": [\"high_packet_loss\",\"high_jitter\"],\"attributes\": {\"conference_participant\": false},\"properties\": {\"last_sip_response_num\": 200,\"pdd_ms\": 121,\"disconnected_by\": \"callee\",\"direction\": \"inbound\"},\"trust\": {\"verified_caller\": {\"verified\": true}},\"url\": \"https://insights.twilio.com/v1/Voice/Summaries\"},{\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"created_time\": \"2021-08-25T02:20:25Z\",\"start_time\": \"2021-08-25T02:20:25Z\",\"end_time\": \"2021-08-25T02:40:45Z\",\"duration\": 18,\"connect_duration\": 18,\"call_type\": \"carrier\",\"call_state\": \"completed\",\"from\": {\"caller\": \"+15555555555\",\"carrier\": \"T-Mobile USA, Inc.\",\"connection\": \"mobile\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 40.83885,\"lon\": -74.04568},\"country_code\": \"US\"},\"to\": {\"callee\": \"+15555555556\",\"carrier\": \"AT&T Wireless\",\"connection\": \"mobile\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 33.42767,\"lon\": -86.886475},\"country_code\": \"US\"},\"processing_state\": \"complete\",\"sdk_edge\": null,\"sip_edge\": null,\"client_edge\": null,\"carrier_edge\": {\"properties\": {\"media_region\": \"us1\",\"signaling_region\": \"us1\",\"edge_location\": \"xxxxx\",\"direction\": \"inbound\"},\"metrics\": {\"inbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_received\": 100,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 1.48209,\"avg\": 0.483035}},\"outbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_sent\": 102,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 0.51868,\"avg\": 0.364434}}}},\"tags\": null,\"attributes\": {\"conference_participant\": false},\"properties\": {\"last_sip_response_num\": 200,\"pdd_ms\": 121,\"disconnected_by\": \"callee\",\"direction\": \"inbound\"},\"trust\": {\"verified_caller\": {\"verified\": true}},\"url\": \"https://insights.twilio.com/v1/Voice/Summaries\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); + twilioRestClient.getObjectMapper(); + result = new ObjectMapper(); + }}; + + assertNotNull(CallSummaries.reader().read()); + } + + @Test + public void testReadWithSubaccountResponse() { + new NonStrictExpectations() {{ + twilioRestClient.request((Request) any); + result = new Response("{\"meta\": {\"page\": 0,\"page_size\": 25,\"first_page_url\": \"https://insights.twilio.com/v1/Voice/Summaries?CallType=client&StartTime=7d&HasTag=True&Subaccount=ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab&PageSize=25&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"key\": \"call_summaries\",\"url\": \"https://insights.twilio.com/v1/Voice/Summaries?CallType=client&StartTime=7d&HasTag=True&Subaccount=ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab&PageSize=25&Page=0\"},\"call_summaries\": [{\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\",\"created_time\": \"2021-08-25T04:16:35Z\",\"start_time\": \"2021-08-25T04:16:36Z\",\"end_time\": \"2021-08-25T04:16:42Z\",\"duration\": 7,\"connect_duration\": 6,\"call_type\": \"client\",\"call_state\": \"completed\",\"from\": {\"caller\": \"client:+15555555555\",\"connection\": \"twilio_sdk\"},\"to\": {\"callee\": \"client:TBBXXXXXXXXXXXX\",\"connection\": \"twilio_sdk\"},\"processing_state\": \"complete\",\"sdk_edge\": null,\"sip_edge\": null,\"client_edge\": {\"properties\": {\"media_region\": \"us1\",\"signaling_region\": \"us1\",\"twilio_media_ip\": \"54.xxx.xx.xxx\",\"external_media_ip\": \"54.xxx.xx.xxx\",\"edge_location\": \"xxxxxx\",\"direction\": \"inbound\"},\"metrics\": {\"inbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_received\": 252,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 5.60994,\"avg\": 0.933334}},\"outbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_sent\": 229,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 0.960786,\"avg\": 0.399859}}}},\"carrier_edge\": null,\"tags\": [\"high_pdd\"],\"attributes\": {\"conference_participant\": false},\"properties\": {\"last_sip_response_num\": 200,\"pdd_ms\": 58,\"disconnected_by\": \"callee\",\"direction\": \"inbound\"},\"trust\": null,\"url\": \"https://insights.twilio.com/v1/Voice/Summaries\"},{\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\",\"created_time\": \"2021-08-25T04:16:35Z\",\"start_time\": \"2021-08-25T04:16:37Z\",\"end_time\": \"2021-08-25T04:16:40Z\",\"duration\": 5,\"connect_duration\": 3,\"call_type\": \"client\",\"call_state\": \"completed\",\"from\": {\"caller\": \"+15555555555\",\"carrier\": \"Verizon\",\"connection\": \"landline\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 40.83885,\"lon\": -74.04568},\"country_code\": \"US\"},\"to\": {\"callee\": \"client:TBBTXXXXXX\",\"connection\": \"twilio_sdk\"},\"processing_state\": \"complete\",\"sdk_edge\": null,\"sip_edge\": null,\"client_edge\": {\"properties\": {\"media_region\": \"us1\",\"signaling_region\": \"us1\",\"twilio_media_ip\": \"54.xxx.xx.xxx\",\"external_media_ip\": \"54.xxx.xx.xxx\",\"edge_location\": \"xxxxx\",\"direction\": \"outbound\"},\"metrics\": {\"inbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_received\": 110,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 1.05918,\"avg\": 0.461966}},\"outbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_sent\": 147,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 0.869174,\"avg\": 0.319674}}}},\"carrier_edge\": null,\"tags\": null,\"attributes\": {\"conference_participant\": false},\"properties\": {\"last_sip_response_num\": 200,\"pdd_ms\": 35,\"disconnected_by\": \"callee\",\"direction\": \"outbound_api\"},\"trust\": null,\"url\": \"https://insights.twilio.com/v1/Voice/Summaries\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); + twilioRestClient.getObjectMapper(); + result = new ObjectMapper(); + }}; + + assertNotNull(CallSummaries.reader().read()); + } + + @Test + public void testReadWithTrustResponse() { + new NonStrictExpectations() {{ + twilioRestClient.request((Request) any); + result = new Response("{\"meta\": {\"page\": 0,\"page_size\": 25,\"first_page_url\": \"https://insights.twilio.com/v1/Voice/Summaries?Direction=outbound_api&StartTime=1d&VerifiedCaller=True&PageSize=25&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"key\": \"call_summaries\",\"url\": \"https://insights.twilio.com/v1/Voice/Summaries?Direction=outbound_api&StartTime=1d&VerifiedCaller=True&PageSize=25&Page=0\"},\"call_summaries\": [{\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"created_time\": \"2021-08-25T14:03:31Z\",\"start_time\": \"2021-08-25T14:03:32Z\",\"end_time\": \"2021-08-25T14:03:38Z\",\"duration\": 7,\"connect_duration\": 6,\"call_type\": \"carrier\",\"call_state\": \"completed\",\"from\": {\"caller\": \"+15555555555\",\"carrier\": \"T-Mobile USA, Inc.\",\"connection\": \"mobile\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 40.83885,\"lon\": -74.04568},\"country_code\": \"US\"},\"to\": {\"callee\": \"+15555555556\",\"carrier\": \"T-Mobile USA, Inc.\",\"connection\": \"mobile\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 34.186115,\"lon\": -118.43555},\"country_code\": \"US\"},\"processing_state\": \"complete\",\"sdk_edge\": null,\"sip_edge\": null,\"client_edge\": null,\"carrier_edge\": {\"properties\": {\"media_region\": \"us1\",\"signaling_region\": \"us1\",\"edge_location\": \"xxxx\",\"direction\": \"outbound\"},\"metrics\": {\"inbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_received\": 229,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 1.10303,\"avg\": 0.449886}},\"outbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_sent\": 273,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 0.410031,\"avg\": 0.295951}}}},\"tags\": null,\"attributes\": {\"conference_participant\": false},\"properties\": {\"last_sip_response_num\": 200,\"pdd_ms\": 315,\"disconnected_by\": \"callee\",\"direction\": \"outbound_api\"},\"trust\": {\"verified_caller\": {\"verified\": true}},\"url\": \"https://insights.twilio.com/v1/Voice/Summaries\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); + twilioRestClient.getObjectMapper(); + result = new ObjectMapper(); + }}; + + assertNotNull(CallSummaries.reader().read()); + } + + @Test + public void testReadWithAbnormalSessionResponse() { + new NonStrictExpectations() {{ + twilioRestClient.request((Request) any); + result = new Response("{\"meta\": {\"page\": 0,\"page_size\": 25,\"first_page_url\": \"https://insights.twilio.com/v1/Voice/Summaries?CallType=sip&CallState=completed&StartTime=15d&AbnormalSession=True&PageSize=25&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"key\": \"call_summaries\",\"url\": \"https://insights.twilio.com/v1/Voice/Summaries?CallType=sip&CallState=completed&StartTime=15d&AbnormalSession=True&PageSize=25&Page=0\"},\"call_summaries\": [{\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"created_time\": \"2021-08-25T14:46:40Z\",\"start_time\": \"2021-08-25T14:46:40Z\",\"end_time\": \"2021-08-25T14:46:52Z\",\"duration\": 12,\"connect_duration\": 12,\"call_type\": \"sip\",\"call_state\": \"completed\",\"from\": {\"caller\": \"+15555555555\",\"carrier\": \"XO Communications, Inc.\",\"connection\": \"landline\",\"number_prefix\": \"1555\",\"location\": {\"lat\": 40.83885,\"lon\": -74.04568},\"country_code\": \"US\"},\"to\": {\"callee\": \"sip:xxxx@xx.xxx.xx.xxx\",\"connection\": \"sip_interface\"},\"processing_state\": \"complete\",\"sdk_edge\": null,\"sip_edge\": {\"properties\": {\"media_region\": \"us1\",\"signaling_region\": \"us1\",\"twilio_media_ip\": \"xx.xxx.xx.xxx\",\"twilio_signaling_ip\": \"xx.xx.xx.xx\",\"external_media_ip\": \"xx.xxx.xx.xxx\",\"external_signaling_ip\": \"xx.xxx.xx.xxx\",\"sip_call_id\": \"xxxxxxxx@0.0.0.0\",\"edge_location\": \"xxxxx\",\"direction\": \"outbound\"},\"metrics\": {\"inbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_received\": 525,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 0.554729,\"avg\": 0.229541}},\"outbound\": {\"codec\": 0,\"codec_name\": \"pcmu\",\"packets_sent\": 245,\"packets_lost\": 0,\"packets_loss_percentage\": 0.0,\"jitter\": {\"max\": 1.03548,\"avg\": 0.344092}}}},\"client_edge\": null,\"carrier_edge\": null,\"tags\": null,\"attributes\": {\"conference_participant\": false},\"properties\": {\"last_sip_response_num\": 200,\"pdd_ms\": 255,\"disconnected_by\": \"callee\",\"direction\": \"outbound_dial\"},\"trust\": null,\"url\": \"https://insights.twilio.com/v1/Voice/Summaries\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; diff --git a/src/test/java/com/twilio/rest/messaging/v1/BrandRegistrationTest.java b/src/test/java/com/twilio/rest/messaging/v1/BrandRegistrationTest.java index 96bceb5930..c7bc60bd23 100644 --- a/src/test/java/com/twilio/rest/messaging/v1/BrandRegistrationTest.java +++ b/src/test/java/com/twilio/rest/messaging/v1/BrandRegistrationTest.java @@ -60,7 +60,7 @@ public void testFetchRequest() { public void testFetchResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"sid\": \"BN0044409f7e067e279523808d267e2d85\",\"account_sid\": \"AC78e8e67fc0246521490fb9907fd0c165\",\"customer_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"a2p_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"date_created\": \"2021-01-27T14:18:35Z\",\"date_updated\": \"2021-01-27T14:18:36Z\",\"brand_type\": \"STANDARD\",\"status\": \"PENDING\",\"tcr_id\": \"BXXXXXX\",\"failure_reason\": \"Registration error\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85\",\"brand_score\": 42}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"sid\": \"BN0044409f7e067e279523808d267e2d85\",\"account_sid\": \"AC78e8e67fc0246521490fb9907fd0c165\",\"customer_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"a2p_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"date_created\": \"2021-01-27T14:18:35Z\",\"date_updated\": \"2021-01-27T14:18:36Z\",\"brand_type\": \"STANDARD\",\"status\": \"PENDING\",\"tcr_id\": \"BXXXXXX\",\"failure_reason\": \"Registration error\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85\",\"brand_score\": 42,\"mock\": false}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; @@ -92,7 +92,7 @@ public void testReadRequest() { public void testReadResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations?PageSize=50&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"key\": \"data\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations?PageSize=50&Page=0\"},\"data\": [{\"sid\": \"BN0044409f7e067e279523808d267e2d85\",\"account_sid\": \"AC78e8e67fc0246521490fb9907fd0c165\",\"customer_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"a2p_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"date_created\": \"2021-01-27T14:18:35Z\",\"date_updated\": \"2021-01-27T14:18:36Z\",\"brand_type\": \"STANDARD\",\"status\": \"APPROVED\",\"tcr_id\": \"BXXXXXX\",\"failure_reason\": \"Registration error\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85\",\"brand_score\": 42}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations?PageSize=50&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"key\": \"data\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations?PageSize=50&Page=0\"},\"data\": [{\"sid\": \"BN0044409f7e067e279523808d267e2d85\",\"account_sid\": \"AC78e8e67fc0246521490fb9907fd0c165\",\"customer_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"a2p_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"date_created\": \"2021-01-27T14:18:35Z\",\"date_updated\": \"2021-01-27T14:18:36Z\",\"brand_type\": \"STANDARD\",\"status\": \"APPROVED\",\"tcr_id\": \"BXXXXXX\",\"failure_reason\": \"Registration error\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85\",\"brand_score\": 42,\"mock\": false}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; @@ -125,7 +125,7 @@ public void testCreateRequest() { public void testCreateResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"sid\": \"BN0044409f7e067e279523808d267e2d85\",\"account_sid\": \"AC78e8e67fc0246521490fb9907fd0c165\",\"customer_profile_bundle_sid\": \"BU0000009f7e067e279523808d267e2d90\",\"a2p_profile_bundle_sid\": \"BU1111109f7e067e279523808d267e2d85\",\"date_created\": \"2021-01-28T10:45:51Z\",\"date_updated\": \"2021-01-28T10:45:51Z\",\"brand_type\": \"STANDARD\",\"status\": \"PENDING\",\"tcr_id\": \"BXXXXXX\",\"failure_reason\": \"Registration error\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85\",\"brand_score\": 42}", TwilioRestClient.HTTP_STATUS_CODE_CREATED); + result = new Response("{\"sid\": \"BN0044409f7e067e279523808d267e2d85\",\"account_sid\": \"AC78e8e67fc0246521490fb9907fd0c165\",\"customer_profile_bundle_sid\": \"BU0000009f7e067e279523808d267e2d90\",\"a2p_profile_bundle_sid\": \"BU1111109f7e067e279523808d267e2d85\",\"date_created\": \"2021-01-28T10:45:51Z\",\"date_updated\": \"2021-01-28T10:45:51Z\",\"brand_type\": \"STANDARD\",\"status\": \"PENDING\",\"tcr_id\": \"BXXXXXX\",\"failure_reason\": \"Registration error\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85\",\"brand_score\": 42,\"mock\": false}", TwilioRestClient.HTTP_STATUS_CODE_CREATED); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; diff --git a/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonTest.java b/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonTest.java index 7e1d9dbcc9..6e1a3f4def 100644 --- a/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonTest.java +++ b/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonTest.java @@ -65,7 +65,7 @@ public void testCreateRequest() { public void testCreateResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"sid\": \"QE2c6890da8086d771620e9b13fadeba0b\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"brand_registration_sid\": \"BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"messaging_service_sid\": \"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"description\": \"Send marketing messages about sales to opted in customers.\",\"message_samples\": [\"EXPRESS: Denim Days Event is ON\",\"LAST CHANCE: Book your next flight for just 1 (ONE) EUR\"],\"us_app_to_person_usecase\": \"MARKETING\",\"has_embedded_links\": true,\"has_embedded_phone\": false,\"campaign_status\": \"PENDING\",\"campaign_id\": \"CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"is_externally_registered\": false,\"rate_limits\": {\"att\": {\"mps\": 600,\"msg_class\": \"A\"},\"tmobile\": {\"brand_tier\": \"TOP\"}},\"date_created\": \"2021-02-18T14:48:52Z\",\"date_updated\": \"2021-02-18T14:48:52Z\",\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b\"}", TwilioRestClient.HTTP_STATUS_CODE_CREATED); + result = new Response("{\"sid\": \"QE2c6890da8086d771620e9b13fadeba0b\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"brand_registration_sid\": \"BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"messaging_service_sid\": \"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"description\": \"Send marketing messages about sales to opted in customers.\",\"message_samples\": [\"EXPRESS: Denim Days Event is ON\",\"LAST CHANCE: Book your next flight for just 1 (ONE) EUR\"],\"us_app_to_person_usecase\": \"MARKETING\",\"has_embedded_links\": true,\"has_embedded_phone\": false,\"campaign_status\": \"PENDING\",\"campaign_id\": \"CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"is_externally_registered\": false,\"rate_limits\": {\"att\": {\"mps\": 600,\"msg_class\": \"A\"},\"tmobile\": {\"brand_tier\": \"TOP\"}},\"date_created\": \"2021-02-18T14:48:52Z\",\"date_updated\": \"2021-02-18T14:48:52Z\",\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b\",\"mock\": false}", TwilioRestClient.HTTP_STATUS_CODE_CREATED); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; @@ -129,7 +129,7 @@ public void testReadRequest() { public void testReadFullResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"compliance\": [{\"sid\": \"QE2c6890da8086d771620e9b13fadeba0b\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"brand_registration_sid\": \"BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"messaging_service_sid\": \"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"description\": \"Send marketing messages about sales to opted in customers.\",\"message_samples\": [\"EXPRESS: Denim Days Event is ON\",\"LAST CHANCE: Book your next flight for just 1 (ONE) EUR\"],\"us_app_to_person_usecase\": \"MARKETING\",\"has_embedded_links\": true,\"has_embedded_phone\": false,\"campaign_status\": \"PENDING\",\"campaign_id\": \"CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"is_externally_registered\": false,\"rate_limits\": {\"att\": {\"mps\": 600,\"msg_class\": \"A\"},\"tmobile\": {\"brand_tier\": \"TOP\"}},\"date_created\": \"2021-02-18T14:48:52Z\",\"date_updated\": \"2021-02-18T14:48:52Z\",\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b\"}],\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0\",\"key\": \"compliance\"}}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"compliance\": [{\"sid\": \"QE2c6890da8086d771620e9b13fadeba0b\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"brand_registration_sid\": \"BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"messaging_service_sid\": \"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"description\": \"Send marketing messages about sales to opted in customers.\",\"message_samples\": [\"EXPRESS: Denim Days Event is ON\",\"LAST CHANCE: Book your next flight for just 1 (ONE) EUR\"],\"us_app_to_person_usecase\": \"MARKETING\",\"has_embedded_links\": true,\"has_embedded_phone\": false,\"campaign_status\": \"PENDING\",\"campaign_id\": \"CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"is_externally_registered\": false,\"rate_limits\": {\"att\": {\"mps\": 600,\"msg_class\": \"A\"},\"tmobile\": {\"brand_tier\": \"TOP\"}},\"date_created\": \"2021-02-18T14:48:52Z\",\"date_updated\": \"2021-02-18T14:48:52Z\",\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b\",\"mock\": false}],\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0\",\"previous_page_url\": null,\"next_page_url\": null,\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0\",\"key\": \"compliance\"}}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; @@ -161,7 +161,7 @@ public void testFetchRequest() { public void testFetchResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"sid\": \"QE2c6890da8086d771620e9b13fadeba0b\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"brand_registration_sid\": \"BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"messaging_service_sid\": \"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"description\": \"Send marketing messages about sales to opted in customers.\",\"message_samples\": [\"EXPRESS: Denim Days Event is ON\",\"LAST CHANCE: Book your next flight for just 1 (ONE) EUR\"],\"us_app_to_person_usecase\": \"MARKETING\",\"has_embedded_links\": true,\"has_embedded_phone\": false,\"campaign_status\": \"PENDING\",\"campaign_id\": \"CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"is_externally_registered\": false,\"rate_limits\": {\"att\": {\"mps\": 600,\"msg_class\": \"A\"},\"tmobile\": {\"brand_tier\": \"TOP\"}},\"date_created\": \"2021-02-18T14:48:52Z\",\"date_updated\": \"2021-02-18T14:48:52Z\",\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b\"}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"sid\": \"QE2c6890da8086d771620e9b13fadeba0b\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"brand_registration_sid\": \"BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"messaging_service_sid\": \"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"description\": \"Send marketing messages about sales to opted in customers.\",\"message_samples\": [\"EXPRESS: Denim Days Event is ON\",\"LAST CHANCE: Book your next flight for just 1 (ONE) EUR\"],\"us_app_to_person_usecase\": \"MARKETING\",\"has_embedded_links\": true,\"has_embedded_phone\": false,\"campaign_status\": \"PENDING\",\"campaign_id\": \"CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"is_externally_registered\": false,\"rate_limits\": {\"att\": {\"mps\": 600,\"msg_class\": \"A\"},\"tmobile\": {\"brand_tier\": \"TOP\"}},\"date_created\": \"2021-02-18T14:48:52Z\",\"date_updated\": \"2021-02-18T14:48:52Z\",\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b\",\"mock\": false}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; diff --git a/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonUsecaseTest.java b/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonUsecaseTest.java index 814c2643c3..d9a722b258 100644 --- a/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonUsecaseTest.java +++ b/src/test/java/com/twilio/rest/messaging/v1/service/UsAppToPersonUsecaseTest.java @@ -60,7 +60,7 @@ public void testFetchRequest() { public void testFetchWithBrandRegistrationSidResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"us_app_to_person_usecases\": [{\"code\": \"MARKETING\",\"name\": \"Marketing\",\"description\": \"Send marketing messages about sales and offers to opted in customers.\"},{\"code\": \"DELIVERY_NOTIFICATION\",\"name\": \"Delivery Notification\",\"description\": \"Information about the status of the delivery of a product or service.\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"us_app_to_person_usecases\": [{\"code\": \"2FA\",\"name\": \"Two-Factor authentication (2FA)\",\"description\": \"Two-Factor authentication, one-time use password, password reset\"},{\"code\": \"ACCOUNT_NOTIFICATION\",\"name\": \"Account Notification\",\"description\": \"All reminders, alerts, and notifications. (Examples include: flight delayed, hotel booked, appointment reminders.)\"},{\"code\": \"AGENTS_FRANCHISES\",\"name\": \"Agents and Franchises\",\"description\": \"For brands that have multiple agents, franchises or offices in the same brand vertical, but require individual localised numbers per agent/location/office.\"},{\"code\": \"CHARITY\",\"name\": \"Charity\",\"description\": \"Includes:5013C Charity\\nDoes not include: Religious organizations\"},{\"code\": \"CONVERSATIONAL\",\"name\": \"Conversational Messaging\",\"description\": \"Peer-to-peer app-based group messaging with proxy/pooled numbers (For example: GroupMe)\\nSupporting personalized services and non-exposure of personal numbers for enterprise or A2P communications. (Examples include: Uber and AirBnb.)\"},{\"code\": \"CUSTOMER_CARE\",\"name\": \"Customer Care\",\"description\": \"All customer care messaging, including account management and support\"},{\"code\": \"DELIVERY_NOTIFICATION\",\"name\": \"Delivery Notification\",\"description\": \"Information about the status of the delivery of a product or service\"},{\"code\": \"EMERGENCY\",\"name\": \"Emergency\",\"description\": \"Notification services designed to support public safety / health during natural disasters, armed conflicts, pandemics and other national or regional emergencies\"},{\"code\": \"FRAUD_ALERT\",\"name\": \"Fraud Alert Messaging\",\"description\": \"Fraud alert notification\"},{\"code\": \"HIGHER_EDUCATION\",\"name\": \"Higher Education\",\"description\": \"For campaigns created on behalf of Colleges or Universities and will also include School Districts etc that fall outside of any \\\"free to the consumer\\\" messaging model\"},{\"code\": \"LOW_VOLUME\",\"name\": \"Low Volume Mixed\",\"description\": \"Low throughput, any combination of use-cases. Examples include:test, demo accounts\"},{\"code\": \"MARKETING\",\"name\": \"Marketing\",\"description\": \"Any communication with marketing and/or promotional content\"},{\"code\": \"MIXED\",\"name\": \"Mixed\",\"description\": \"Mixed messaging reserved for specific consumer service industry\"},{\"code\": \"POLLING_VOTING\",\"name\": \"Polling and voting\",\"description\": \"Polling and voting\"},{\"code\": \"PUBLIC_SERVICE_ANNOUNCEMENT\",\"name\": \"Public Service Announcement\",\"description\": \"An informational message that is meant to raise the audience awareness about an important issue\"},{\"code\": \"SECURITY_ALERT\",\"name\": \"Security Alert\",\"description\": \"A notification that the security of a system, either software or hardware, has been compromised in some way and there is an action you need to take\"},{\"code\": \"SOCIAL\",\"name\": \"Social\",\"description\": \"Communication within or between closed communities (For example: influencers alerts)\"},{\"code\": \"SWEEPSTAKE\",\"name\": \"Sweepstake\",\"description\": \"Sweepstake\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; @@ -72,7 +72,7 @@ public void testFetchWithBrandRegistrationSidResponse() { public void testFetchWithoutBrandRegistrationSidResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"us_app_to_person_usecases\": [{\"code\": \"MARKETING\",\"name\": \"Marketing\",\"description\": \"Send marketing messages about sales and offers to opted in customers.\"},{\"code\": \"DELIVERY_NOTIFICATION\",\"name\": \"Delivery Notification\",\"description\": \"Information about the status of the delivery of a product or service.\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"us_app_to_person_usecases\": [{\"code\": \"2FA\",\"name\": \"Two-Factor authentication (2FA)\",\"description\": \"Two-Factor authentication, one-time use password, password reset\"},{\"code\": \"ACCOUNT_NOTIFICATION\",\"name\": \"Account Notification\",\"description\": \"All reminders, alerts, and notifications. (Examples include: flight delayed, hotel booked, appointment reminders.)\"},{\"code\": \"AGENTS_FRANCHISES\",\"name\": \"Agents and Franchises\",\"description\": \"For brands that have multiple agents, franchises or offices in the same brand vertical, but require individual localised numbers per agent/location/office.\"},{\"code\": \"CHARITY\",\"name\": \"Charity\",\"description\": \"Includes:5013C Charity\\nDoes not include: Religious organizations\"},{\"code\": \"CONVERSATIONAL\",\"name\": \"Conversational Messaging\",\"description\": \"Peer-to-peer app-based group messaging with proxy/pooled numbers (For example: GroupMe)\\nSupporting personalized services and non-exposure of personal numbers for enterprise or A2P communications. (Examples include: Uber and AirBnb.)\"},{\"code\": \"CUSTOMER_CARE\",\"name\": \"Customer Care\",\"description\": \"All customer care messaging, including account management and support\"},{\"code\": \"DELIVERY_NOTIFICATION\",\"name\": \"Delivery Notification\",\"description\": \"Information about the status of the delivery of a product or service\"},{\"code\": \"EMERGENCY\",\"name\": \"Emergency\",\"description\": \"Notification services designed to support public safety / health during natural disasters, armed conflicts, pandemics and other national or regional emergencies\"},{\"code\": \"FRAUD_ALERT\",\"name\": \"Fraud Alert Messaging\",\"description\": \"Fraud alert notification\"},{\"code\": \"HIGHER_EDUCATION\",\"name\": \"Higher Education\",\"description\": \"For campaigns created on behalf of Colleges or Universities and will also include School Districts etc that fall outside of any \\\"free to the consumer\\\" messaging model\"},{\"code\": \"LOW_VOLUME\",\"name\": \"Low Volume Mixed\",\"description\": \"Low throughput, any combination of use-cases. Examples include:test, demo accounts\"},{\"code\": \"MARKETING\",\"name\": \"Marketing\",\"description\": \"Any communication with marketing and/or promotional content\"},{\"code\": \"MIXED\",\"name\": \"Mixed\",\"description\": \"Mixed messaging reserved for specific consumer service industry\"},{\"code\": \"POLLING_VOTING\",\"name\": \"Polling and voting\",\"description\": \"Polling and voting\"},{\"code\": \"PUBLIC_SERVICE_ANNOUNCEMENT\",\"name\": \"Public Service Announcement\",\"description\": \"An informational message that is meant to raise the audience awareness about an important issue\"},{\"code\": \"SECURITY_ALERT\",\"name\": \"Security Alert\",\"description\": \"A notification that the security of a system, either software or hardware, has been compromised in some way and there is an action you need to take\"},{\"code\": \"SOCIAL\",\"name\": \"Social\",\"description\": \"Communication within or between closed communities (For example: influencers alerts)\"},{\"code\": \"SWEEPSTAKE\",\"name\": \"Sweepstake\",\"description\": \"Sweepstake\"}]}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; diff --git a/src/test/java/com/twilio/rest/pricing/v2/CountryTest.java b/src/test/java/com/twilio/rest/pricing/v2/CountryTest.java index b3cb899f17..075048540e 100644 --- a/src/test/java/com/twilio/rest/pricing/v2/CountryTest.java +++ b/src/test/java/com/twilio/rest/pricing/v2/CountryTest.java @@ -104,7 +104,7 @@ public void testFetchRequest() { public void testFetchResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"country\": \"United States\",\"originating_call_prices\": [{\"base_price\": \"\",\"current_price\": \"0.0085\",\"number_type\": \"local\"},{\"base_price\": \"\",\"current_price\": \"0.022\",\"number_type\": \"toll free\"}],\"iso_country\": \"US\",\"terminating_prefix_prices\": [{\"base_price\": \"\",\"current_price\": \"0.090\",\"destination_prefixes\": [\"1907\"],\"friendly_name\": \"Outbound Trunking Minute - United States - Alaska\",\"origination_prefixes\": [\"ALL\"]},{\"base_price\": \"\",\"current_price\": \"0.013\",\"destination_prefixes\": [\"1808\"],\"friendly_name\": \"Outbound Trunking Minute - United States - Hawaii\",\"origination_prefixes\": [\"ALL\"]},{\"base_price\": \"\",\"current_price\": \"0.013\",\"destination_prefixes\": [\"1800\",\"1844\",\"1855\",\"1866\",\"1877\",\"1888\"],\"friendly_name\": \"Outbound Trunking Minute - United States & Canada - Toll Free\",\"origination_prefixes\": [\"ALL\"]},{\"base_price\": \"\",\"current_price\": \"0.013\",\"destination_prefixes\": [\"1\"],\"friendly_name\": \"Outbound Trunking Minute - United States & Canada\",\"origination_prefixes\": [\"ALL\"]}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v2/Trunking/Countries/US\"}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"country\": \"United States\",\"originating_call_prices\": [{\"base_price\": null,\"current_price\": \"0.0085\",\"number_type\": \"local\"},{\"base_price\": null,\"current_price\": \"0.022\",\"number_type\": \"toll free\"}],\"iso_country\": \"US\",\"terminating_prefix_prices\": [{\"base_price\": null,\"current_price\": \"0.090\",\"destination_prefixes\": [\"1907\"],\"friendly_name\": \"Outbound Trunking Minute - United States - Alaska\",\"origination_prefixes\": [\"ALL\"]},{\"base_price\": null,\"current_price\": \"0.013\",\"destination_prefixes\": [\"1808\"],\"friendly_name\": \"Outbound Trunking Minute - United States - Hawaii\",\"origination_prefixes\": [\"ALL\"]},{\"base_price\": null,\"current_price\": \"0.013\",\"destination_prefixes\": [\"1800\",\"1844\",\"1855\",\"1866\",\"1877\",\"1888\"],\"friendly_name\": \"Outbound Trunking Minute - United States & Canada - Toll Free\",\"origination_prefixes\": [\"ALL\"]},{\"base_price\": null,\"current_price\": \"0.013\",\"destination_prefixes\": [\"1\"],\"friendly_name\": \"Outbound Trunking Minute - United States & Canada\",\"origination_prefixes\": [\"ALL\"]}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v2/Trunking/Countries/US\"}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; diff --git a/src/test/java/com/twilio/rest/pricing/v2/NumberTest.java b/src/test/java/com/twilio/rest/pricing/v2/NumberTest.java index eaf9e8ab84..45bed5e262 100644 --- a/src/test/java/com/twilio/rest/pricing/v2/NumberTest.java +++ b/src/test/java/com/twilio/rest/pricing/v2/NumberTest.java @@ -60,7 +60,19 @@ public void testFetchRequest() { public void testFetchResponse() { new NonStrictExpectations() {{ twilioRestClient.request((Request) any); - result = new Response("{\"country\": \"United States\",\"destination_number\": \"+18001234567\",\"originating_call_price\": {\"base_price\": null,\"current_price\": null,\"number_type\": null},\"iso_country\": \"US\",\"origination_number\": \"+987654321\",\"terminating_prefix_prices\": [{\"base_price\": \"\",\"current_price\": \"0.013\",\"destination_prefixes\": [\"1800\"],\"friendly_name\": \"Trunking Outbound Minute - United States Zone 1b\",\"origination_prefixes\": [\"ALL\"]}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v2/Trunking/Numbers/+18001234567\"}", TwilioRestClient.HTTP_STATUS_CODE_OK); + result = new Response("{\"country\": \"United States\",\"destination_number\": \"+18001234567\",\"originating_call_price\": {\"base_price\": null,\"current_price\": null,\"number_type\": null},\"iso_country\": \"US\",\"origination_number\": null,\"terminating_prefix_prices\": [{\"base_price\": null,\"current_price\": \"0.013\",\"destination_prefixes\": [\"1800\"],\"friendly_name\": \"Trunking Outbound Minute - United States Zone 1b\",\"origination_prefixes\": [\"ALL\"]}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v2/Trunking/Numbers/+18001234567\"}", TwilioRestClient.HTTP_STATUS_CODE_OK); + twilioRestClient.getObjectMapper(); + result = new ObjectMapper(); + }}; + + assertNotNull(Number.fetcher(new com.twilio.type.PhoneNumber("+15017122661")).fetch()); + } + + @Test + public void testFetchWithOriginationResponse() { + new NonStrictExpectations() {{ + twilioRestClient.request((Request) any); + result = new Response("{\"country\": \"United States\",\"destination_number\": \"+18001234567\",\"originating_call_price\": {\"base_price\": null,\"current_price\": \"0.013\",\"number_type\": \"tollfree\"},\"iso_country\": \"US\",\"origination_number\": \"+15105556789\",\"terminating_prefix_prices\": [{\"base_price\": null,\"current_price\": \"0.001\",\"destination_prefixes\": [\"1800\"],\"friendly_name\": \"Trunking Outbound Minute - United States - Toll Free\",\"origination_prefixes\": [\"ALL\"]}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v2/Trunking/Numbers/+18001234567\"}", TwilioRestClient.HTTP_STATUS_CODE_OK); twilioRestClient.getObjectMapper(); result = new ObjectMapper(); }}; diff --git a/src/test/java/com/twilio/rest/verify/v2/VerificationTemplateTest.java b/src/test/java/com/twilio/rest/verify/v2/VerificationTemplateTest.java new file mode 100644 index 0000000000..2ad84f24e0 --- /dev/null +++ b/src/test/java/com/twilio/rest/verify/v2/VerificationTemplateTest.java @@ -0,0 +1,70 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +package com.twilio.rest.verify.v2; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.Twilio; +import com.twilio.converter.DateConverter; +import com.twilio.converter.Promoter; +import com.twilio.exception.TwilioException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; +import mockit.Mocked; +import mockit.NonStrictExpectations; +import org.junit.Before; +import org.junit.Test; + +import java.net.URI; + +import static com.twilio.TwilioTest.serialize; +import static org.junit.Assert.*; + +public class VerificationTemplateTest { + @Mocked + private TwilioRestClient twilioRestClient; + + @Before + public void setUp() throws Exception { + Twilio.init("AC123", "AUTH TOKEN"); + } + + @Test + public void testReadRequest() { + new NonStrictExpectations() {{ + Request request = new Request(HttpMethod.GET, + Domains.VERIFY.toString(), + "/v2/Templates"); + + twilioRestClient.request(request); + times = 1; + result = new Response("", 500); + twilioRestClient.getAccountSid(); + result = "AC123"; + }}; + + try { + VerificationTemplate.reader().read(); + fail("Expected TwilioException to be thrown for 500"); + } catch (TwilioException e) {} + } + + @Test + public void testListVerificationTemplatesResponse() { + new NonStrictExpectations() {{ + twilioRestClient.request((Request) any); + result = new Response("{\"templates\": [{\"sid\": \"HJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"friendly_name\": \"Friendly Template\",\"translations\": {\"en\": {\"text\": \"Hello, your code is {code}.\",\"locale\": \"es\",\"status\": \"approved\",\"date_created\": \"2021-07-26T22:30:13.003505841Z\",\"date_updated\": \"2021-07-26T22:31:08.750971289Z\"}}}],\"meta\": {\"key\": \"templates\",\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://verify.twilio.com/v2/Templates?PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://verify.twilio.com/v2/Templates?PageSize=50&Page=0\",\"next_page_url\": null}}", TwilioRestClient.HTTP_STATUS_CODE_OK); + twilioRestClient.getObjectMapper(); + result = new ObjectMapper(); + }}; + + assertNotNull(VerificationTemplate.reader().read()); + } +} \ No newline at end of file