diff --git a/CHANGES.md b/CHANGES.md index 298e3cbb24..9509353248 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,72 @@ twilio-java changelog ===================== +[2026-10-06] Version 13.0.3 +--------------------------- +**Audiences** +- ## 2026-10-02 +- **Added 1 new path(s)**: +- `/preview/Cohorts/{cohortId}/Operations` (AdminListCohortOperations) +- ## 2026-10-01 +- **Content updates**: +- Updated description for `AdminListSnapshotOperations` +- ## 2026-09-28 +- **Content updates**: +- Updated description for `AdminListCohortSnapshots` +- Updated description for `AdminFetchCohortSnapshot` +- Updated schema description for `Criteria` +- Added properties to `OperationPayload`: cohortId +- Removed properties from `OperationPayload`: audienceId +- Updated schema description for `OperationResult` +- Added properties to `OperationResult`: cohortId +- Removed properties from `OperationResult`: audienceId +- Updated schema description for `Record` +- Updated schema description for `Cohort` +- ...and 3 more changes +- ## 2026-10-01 +- Minor updates (formatting, metadata) +- ## 2026-09-28 +- **Content updates**: +- Updated schema description for `CohortOperationResult` +- Updated schema description for `PartitionCount` + +**Conversations** +- Add `traitExtractionStrategyIds` and `observationExtractionStrategyIds` to the Conversations v2 Admin Configuration schema. +- Align the Conversations v2 Capabilities list and create contracts with the backend `domainId` field. + +**Data-ingress** +- ## 2026-10-01 +- Minor updates (formatting, metadata) +- ## 2026-09-17 +- Add support for Hubspot connector +- ## 2026-10-01 +- Minor updates (formatting, metadata) +- ## 2026-09-17 +- Add support for Hubspot connector + +**Knowledge** +- ## 2026-09-24 +- **Routing updates**: +- Changed `downstreamServiceName` from `memora-domain` to `enterprise-knowledge-domain` for all operations + +**Memory** +- ## 2026-09-30 +- The `source` field on observations and conversation summaries, and the `source` filter +- on `ListProfileObservations`, now also accept forward slashes (`/`). The pattern is +- `^[a-zA-Z0-9 _./-]+$`. This is additive and backwards compatible: every previously +- valid value is still accepted. +- `UpdateStore`, `UpdateTraitGroup`, and `UpdateDataMapping` now require a body with at least one property. An empty `{}` gets a 400. + +**Messaging** +- Add opt-out configuration admin endpoints (`GET/PUT/DELETE /v1/Accounts/{AccountSid}/OptOuts/{OptOutSid}/...`) to the messaging admin-api (dev-us1 and stage-us1 only) +- Add create opt-out configuration endpoint (`POST /v1/Accounts/{AccountSid}/OptOuts`) to the messaging admin-api (dev-us1 and stage-us1 only) +- Add update messaging service endpoint (`PUT /v1/Accounts/{AccountSid}/Services/{MessagingServiceSid}`) to the messaging admin-api (dev-us1 and stage-us1 only) +- Add WhatsApp display name change support to Sender API: `pending_display_name`, `pending_display_name_status` and `pending_display_name_status_date` on fetch, and `display_name_status` on update and partial update + +**Routes** +- Set SDK and docs visibility of `GET`/`POST` `/v3/ShortCodes/{isoCountryCode}/{shortCode}` to `public`, maturity to `ga` + + [2026-09-28] Version 13.0.2 --------------------------- **Twiml** diff --git a/pom.xml b/pom.xml index 9bd12f660a..8b1087908a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ twilio jar twilio - 13.0.2 + 13.0.3 Twilio Java Helper Library https://www.twilio.com @@ -19,7 +19,7 @@ git@github.com:twilio/twilio-java.git scm:git:git@github.com:twilio/twilio-java.git scm:git:git@github.com:twilio/twilio-java.git - 13.0.2 + 13.0.3 diff --git a/src/main/java/com/twilio/Twilio.java b/src/main/java/com/twilio/Twilio.java index 01a2a33c68..30f1016add 100644 --- a/src/main/java/com/twilio/Twilio.java +++ b/src/main/java/com/twilio/Twilio.java @@ -41,7 +41,7 @@ */ public class Twilio { - public static final String VERSION = "13.0.2"; + public static final String VERSION = "13.0.3"; public static final String JAVA_VERSION = System.getProperty("java.version"); public static final String OS_NAME = System.getProperty("os.name"); public static final String OS_ARCH = System.getProperty("os.arch"); diff --git a/src/main/java/com/twilio/rest/conversations/v2/Action.java b/src/main/java/com/twilio/rest/conversations/v2/Action.java index 814c98f511..a2a0264fbc 100644 --- a/src/main/java/com/twilio/rest/conversations/v2/Action.java +++ b/src/main/java/com/twilio/rest/conversations/v2/Action.java @@ -60,6 +60,9 @@ public static class CreateActionResponse extends Resource { @Getter private final ZonedDateTime createdAt; + @Getter + private final String failureReason; + @Getter private final String id; @@ -80,6 +83,7 @@ private CreateActionResponse( @JsonProperty("completedAt") final ZonedDateTime completedAt, @JsonProperty("conversationId") final String conversationId, @JsonProperty("createdAt") final ZonedDateTime createdAt, + @JsonProperty("failureReason") final String failureReason, @JsonProperty("id") final String id, @JsonProperty("related") final Map related, @JsonProperty( @@ -91,6 +95,7 @@ private CreateActionResponse( this.completedAt = completedAt; this.conversationId = conversationId; this.createdAt = createdAt; + this.failureReason = failureReason; this.id = id; this.related = related; this.status = status; @@ -126,6 +131,7 @@ public boolean equals(final Object o) { Objects.equals(completedAt, other.completedAt) && Objects.equals(conversationId, other.conversationId) && Objects.equals(createdAt, other.createdAt) && + Objects.equals(failureReason, other.failureReason) && Objects.equals(id, other.id) && Objects.equals(related, other.related) && Objects.equals(status, other.status) && @@ -140,6 +146,7 @@ public int hashCode() { completedAt, conversationId, createdAt, + failureReason, id, related, status, @@ -317,6 +324,9 @@ public static class FetchActionResponse extends Resource { @Getter private final ZonedDateTime createdAt; + @Getter + private final String failureReason; + @Getter private final String id; @@ -337,6 +347,7 @@ private FetchActionResponse( @JsonProperty("completedAt") final ZonedDateTime completedAt, @JsonProperty("conversationId") final String conversationId, @JsonProperty("createdAt") final ZonedDateTime createdAt, + @JsonProperty("failureReason") final String failureReason, @JsonProperty("id") final String id, @JsonProperty("related") final Map related, @JsonProperty( @@ -348,6 +359,7 @@ private FetchActionResponse( this.completedAt = completedAt; this.conversationId = conversationId; this.createdAt = createdAt; + this.failureReason = failureReason; this.id = id; this.related = related; this.status = status; @@ -383,6 +395,7 @@ public boolean equals(final Object o) { Objects.equals(completedAt, other.completedAt) && Objects.equals(conversationId, other.conversationId) && Objects.equals(createdAt, other.createdAt) && + Objects.equals(failureReason, other.failureReason) && Objects.equals(id, other.id) && Objects.equals(related, other.related) && Objects.equals(status, other.status) && @@ -397,6 +410,7 @@ public int hashCode() { completedAt, conversationId, createdAt, + failureReason, id, related, status, diff --git a/src/main/java/com/twilio/rest/conversations/v2/Communication.java b/src/main/java/com/twilio/rest/conversations/v2/Communication.java index b6d3de7b07..25bdadf5d5 100644 --- a/src/main/java/com/twilio/rest/conversations/v2/Communication.java +++ b/src/main/java/com/twilio/rest/conversations/v2/Communication.java @@ -1457,6 +1457,11 @@ public static class CreateCommunicationInConversationRequest { @Getter private final String channelId; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("resourceId") + @Getter + private final String resourceId; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonProperty("recipients") @Getter @@ -1475,6 +1480,7 @@ private CreateCommunicationInConversationRequest(Builder builder) { this.author = builder.author; this.content = builder.content; this.channelId = builder.channelId; + this.resourceId = builder.resourceId; this.recipients = builder.recipients; this.occurredAt = builder.occurredAt; } @@ -1512,6 +1518,9 @@ public static class Builder { @JsonProperty("channelId") private String channelId; + @JsonProperty("resourceId") + private String resourceId; + @JsonProperty("recipients") private List< CreateCommunicationInConversationRequestRecipients @@ -1548,6 +1557,13 @@ public Builder channelId(String channelId) { return this; } + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("resourceId") + public Builder resourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + @JsonDeserialize( using = com.twilio.converter.ISO8601Deserializer.class ) @@ -1580,6 +1596,7 @@ public boolean equals(final Object o) { Objects.equals(author, other.author) && Objects.equals(content, other.content) && Objects.equals(channelId, other.channelId) && + Objects.equals(resourceId, other.resourceId) && Objects.equals(recipients, other.recipients) && Objects.equals(occurredAt, other.occurredAt) ); @@ -1591,6 +1608,7 @@ public int hashCode() { author, content, channelId, + resourceId, recipients, occurredAt ); diff --git a/src/main/java/com/twilio/rest/conversations/v2/Configuration.java b/src/main/java/com/twilio/rest/conversations/v2/Configuration.java index 68fe403e71..a782e9a5e2 100644 --- a/src/main/java/com/twilio/rest/conversations/v2/Configuration.java +++ b/src/main/java/com/twilio/rest/conversations/v2/Configuration.java @@ -256,9 +256,15 @@ public static class ListConfigurationResponse extends Resource { @Getter private final String memoryStoreId; + @Getter + private final List observationExtractionStrategyIds; + @Getter private final List statusCallbacks; + @Getter + private final List traitExtractionStrategyIds; + @Getter private final ZonedDateTime updatedAt; @@ -288,9 +294,15 @@ private ListConfigurationResponse( "memoryExtractionEnabled" ) final Boolean memoryExtractionEnabled, @JsonProperty("memoryStoreId") final String memoryStoreId, + @JsonProperty("observationExtractionStrategyIds") final List< + String + > observationExtractionStrategyIds, @JsonProperty("statusCallbacks") final List< ConversationsV2StatusCallbackConfig > statusCallbacks, + @JsonProperty("traitExtractionStrategyIds") final List< + String + > traitExtractionStrategyIds, @JsonProperty("updatedAt") final ZonedDateTime updatedAt, @JsonProperty("version") final Long version ) { @@ -304,7 +316,10 @@ private ListConfigurationResponse( this.intelligenceConfigurationIds = intelligenceConfigurationIds; this.memoryExtractionEnabled = memoryExtractionEnabled; this.memoryStoreId = memoryStoreId; + this.observationExtractionStrategyIds = + observationExtractionStrategyIds; this.statusCallbacks = statusCallbacks; + this.traitExtractionStrategyIds = traitExtractionStrategyIds; this.updatedAt = updatedAt; this.version = version; } @@ -359,7 +374,15 @@ public boolean equals(final Object o) { other.memoryExtractionEnabled ) && Objects.equals(memoryStoreId, other.memoryStoreId) && + Objects.equals( + observationExtractionStrategyIds, + other.observationExtractionStrategyIds + ) && Objects.equals(statusCallbacks, other.statusCallbacks) && + Objects.equals( + traitExtractionStrategyIds, + other.traitExtractionStrategyIds + ) && Objects.equals(updatedAt, other.updatedAt) && Objects.equals(version, other.version) ); @@ -378,7 +401,9 @@ public int hashCode() { intelligenceConfigurationIds, memoryExtractionEnabled, memoryStoreId, + observationExtractionStrategyIds, statusCallbacks, + traitExtractionStrategyIds, updatedAt, version ); @@ -478,9 +503,15 @@ public static class FetchConfigurationResponse extends Resource { @Getter private final String memoryStoreId; + @Getter + private final List observationExtractionStrategyIds; + @Getter private final List statusCallbacks; + @Getter + private final List traitExtractionStrategyIds; + @Getter private final ZonedDateTime updatedAt; @@ -510,9 +541,15 @@ private FetchConfigurationResponse( "memoryExtractionEnabled" ) final Boolean memoryExtractionEnabled, @JsonProperty("memoryStoreId") final String memoryStoreId, + @JsonProperty("observationExtractionStrategyIds") final List< + String + > observationExtractionStrategyIds, @JsonProperty("statusCallbacks") final List< ConversationsV2StatusCallbackConfig > statusCallbacks, + @JsonProperty("traitExtractionStrategyIds") final List< + String + > traitExtractionStrategyIds, @JsonProperty("updatedAt") final ZonedDateTime updatedAt, @JsonProperty("version") final Long version ) { @@ -526,7 +563,10 @@ private FetchConfigurationResponse( this.intelligenceConfigurationIds = intelligenceConfigurationIds; this.memoryExtractionEnabled = memoryExtractionEnabled; this.memoryStoreId = memoryStoreId; + this.observationExtractionStrategyIds = + observationExtractionStrategyIds; this.statusCallbacks = statusCallbacks; + this.traitExtractionStrategyIds = traitExtractionStrategyIds; this.updatedAt = updatedAt; this.version = version; } @@ -581,7 +621,15 @@ public boolean equals(final Object o) { other.memoryExtractionEnabled ) && Objects.equals(memoryStoreId, other.memoryStoreId) && + Objects.equals( + observationExtractionStrategyIds, + other.observationExtractionStrategyIds + ) && Objects.equals(statusCallbacks, other.statusCallbacks) && + Objects.equals( + traitExtractionStrategyIds, + other.traitExtractionStrategyIds + ) && Objects.equals(updatedAt, other.updatedAt) && Objects.equals(version, other.version) ); @@ -600,7 +648,9 @@ public int hashCode() { intelligenceConfigurationIds, memoryExtractionEnabled, memoryStoreId, + observationExtractionStrategyIds, statusCallbacks, + traitExtractionStrategyIds, updatedAt, version ); @@ -2901,6 +2951,16 @@ public static class ListConfiguration200ResponseConfigurations { @Getter private final List intelligenceConfigurationIds; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("traitExtractionStrategyIds") + @Getter + private final List traitExtractionStrategyIds; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("observationExtractionStrategyIds") + @Getter + private final List observationExtractionStrategyIds; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonProperty("memoryExtractionEnabled") @Getter @@ -2940,6 +3000,10 @@ private ListConfiguration200ResponseConfigurations(Builder builder) { this.statusCallbacks = builder.statusCallbacks; this.intelligenceConfigurationIds = builder.intelligenceConfigurationIds; + this.traitExtractionStrategyIds = + builder.traitExtractionStrategyIds; + this.observationExtractionStrategyIds = + builder.observationExtractionStrategyIds; this.memoryExtractionEnabled = builder.memoryExtractionEnabled; this.conversationsV1Bridge = builder.conversationsV1Bridge; this.createdAt = builder.createdAt; @@ -3001,6 +3065,12 @@ public static class Builder { @JsonProperty("intelligenceConfigurationIds") private List intelligenceConfigurationIds; + @JsonProperty("traitExtractionStrategyIds") + private List traitExtractionStrategyIds; + + @JsonProperty("observationExtractionStrategyIds") + private List observationExtractionStrategyIds; + @JsonProperty("memoryExtractionEnabled") private Boolean memoryExtractionEnabled; @@ -3069,6 +3139,25 @@ public Builder intelligenceConfigurationIds( return this; } + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("traitExtractionStrategyIds") + public Builder traitExtractionStrategyIds( + List traitExtractionStrategyIds + ) { + this.traitExtractionStrategyIds = traitExtractionStrategyIds; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("observationExtractionStrategyIds") + public Builder observationExtractionStrategyIds( + List observationExtractionStrategyIds + ) { + this.observationExtractionStrategyIds = + observationExtractionStrategyIds; + return this; + } + @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonProperty("memoryExtractionEnabled") public Builder memoryExtractionEnabled( @@ -3148,6 +3237,14 @@ public boolean equals(final Object o) { intelligenceConfigurationIds, other.intelligenceConfigurationIds ) && + Objects.equals( + traitExtractionStrategyIds, + other.traitExtractionStrategyIds + ) && + Objects.equals( + observationExtractionStrategyIds, + other.observationExtractionStrategyIds + ) && Objects.equals( memoryExtractionEnabled, other.memoryExtractionEnabled @@ -3173,6 +3270,8 @@ public int hashCode() { channelSettings, statusCallbacks, intelligenceConfigurationIds, + traitExtractionStrategyIds, + observationExtractionStrategyIds, memoryExtractionEnabled, conversationsV1Bridge, createdAt, diff --git a/src/main/java/com/twilio/rest/conversations/v2/Conversation.java b/src/main/java/com/twilio/rest/conversations/v2/Conversation.java index 2f95235a8b..2b1fb1c50e 100644 --- a/src/main/java/com/twilio/rest/conversations/v2/Conversation.java +++ b/src/main/java/com/twilio/rest/conversations/v2/Conversation.java @@ -1086,6 +1086,16 @@ public static class ListConversationByAccount200ResponseConversationsConfigurati @Getter private final List intelligenceConfigurationIds; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("traitExtractionStrategyIds") + @Getter + private final List traitExtractionStrategyIds; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("observationExtractionStrategyIds") + @Getter + private final List observationExtractionStrategyIds; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonProperty("memoryExtractionEnabled") @Getter @@ -1107,6 +1117,10 @@ private ListConversationByAccount200ResponseConversationsConfiguration( this.statusCallbacks = builder.statusCallbacks; this.intelligenceConfigurationIds = builder.intelligenceConfigurationIds; + this.traitExtractionStrategyIds = + builder.traitExtractionStrategyIds; + this.observationExtractionStrategyIds = + builder.observationExtractionStrategyIds; this.memoryExtractionEnabled = builder.memoryExtractionEnabled; this.conversationsV1Bridge = builder.conversationsV1Bridge; } @@ -1150,6 +1164,12 @@ public static class Builder { @JsonProperty("intelligenceConfigurationIds") private List intelligenceConfigurationIds; + @JsonProperty("traitExtractionStrategyIds") + private List traitExtractionStrategyIds; + + @JsonProperty("observationExtractionStrategyIds") + private List observationExtractionStrategyIds; + @JsonProperty("memoryExtractionEnabled") private Boolean memoryExtractionEnabled; @@ -1214,6 +1234,25 @@ public Builder intelligenceConfigurationIds( return this; } + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("traitExtractionStrategyIds") + public Builder traitExtractionStrategyIds( + List traitExtractionStrategyIds + ) { + this.traitExtractionStrategyIds = traitExtractionStrategyIds; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("observationExtractionStrategyIds") + public Builder observationExtractionStrategyIds( + List observationExtractionStrategyIds + ) { + this.observationExtractionStrategyIds = + observationExtractionStrategyIds; + return this; + } + @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonProperty("memoryExtractionEnabled") public Builder memoryExtractionEnabled( @@ -1265,6 +1304,14 @@ public boolean equals(final Object o) { intelligenceConfigurationIds, other.intelligenceConfigurationIds ) && + Objects.equals( + traitExtractionStrategyIds, + other.traitExtractionStrategyIds + ) && + Objects.equals( + observationExtractionStrategyIds, + other.observationExtractionStrategyIds + ) && Objects.equals( memoryExtractionEnabled, other.memoryExtractionEnabled @@ -1286,6 +1333,8 @@ public int hashCode() { channelSettings, statusCallbacks, intelligenceConfigurationIds, + traitExtractionStrategyIds, + observationExtractionStrategyIds, memoryExtractionEnabled, conversationsV1Bridge ); @@ -1687,6 +1736,16 @@ public static class CreateConversationWithConfigRequestConfiguration { @Getter private final List intelligenceConfigurationIds; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("traitExtractionStrategyIds") + @Getter + private final List traitExtractionStrategyIds; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("observationExtractionStrategyIds") + @Getter + private final List observationExtractionStrategyIds; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonProperty("workflows") @Getter @@ -1697,6 +1756,10 @@ private CreateConversationWithConfigRequestConfiguration( ) { this.intelligenceConfigurationIds = builder.intelligenceConfigurationIds; + this.traitExtractionStrategyIds = + builder.traitExtractionStrategyIds; + this.observationExtractionStrategyIds = + builder.observationExtractionStrategyIds; this.workflows = builder.workflows; } @@ -1721,6 +1784,12 @@ public static class Builder { @JsonProperty("intelligenceConfigurationIds") private List intelligenceConfigurationIds; + @JsonProperty("traitExtractionStrategyIds") + private List traitExtractionStrategyIds; + + @JsonProperty("observationExtractionStrategyIds") + private List observationExtractionStrategyIds; + @JsonProperty("workflows") private List workflows; @@ -1734,6 +1803,25 @@ public Builder intelligenceConfigurationIds( return this; } + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("traitExtractionStrategyIds") + public Builder traitExtractionStrategyIds( + List traitExtractionStrategyIds + ) { + this.traitExtractionStrategyIds = traitExtractionStrategyIds; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("observationExtractionStrategyIds") + public Builder observationExtractionStrategyIds( + List observationExtractionStrategyIds + ) { + this.observationExtractionStrategyIds = + observationExtractionStrategyIds; + return this; + } + @JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonProperty("workflows") public Builder workflows(List workflows) { @@ -1765,13 +1853,26 @@ public boolean equals(final Object o) { intelligenceConfigurationIds, other.intelligenceConfigurationIds ) && + Objects.equals( + traitExtractionStrategyIds, + other.traitExtractionStrategyIds + ) && + Objects.equals( + observationExtractionStrategyIds, + other.observationExtractionStrategyIds + ) && Objects.equals(workflows, other.workflows) ); } @Override public int hashCode() { - return Objects.hash(intelligenceConfigurationIds, workflows); + return Objects.hash( + intelligenceConfigurationIds, + traitExtractionStrategyIds, + observationExtractionStrategyIds, + workflows + ); } } diff --git a/src/main/java/com/twilio/rest/knowledge/v2/Operation.java b/src/main/java/com/twilio/rest/knowledge/v2/Operation.java index 335713b43f..45d1bced39 100644 --- a/src/main/java/com/twilio/rest/knowledge/v2/Operation.java +++ b/src/main/java/com/twilio/rest/knowledge/v2/Operation.java @@ -413,25 +413,25 @@ public static Type forValue(final String value) { public static class OperationResultResourceId { @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("type") + @JsonProperty("id") @Getter - private final Operation.Type type; + private final String id; @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("id") + @JsonProperty("type") @Getter - private final String id; + private final Operation.Type type; private OperationResultResourceId(Builder builder) { - this.type = builder.type; this.id = builder.id; + this.type = builder.type; } public static Builder builder( - final Operation.Type type, - final String id + final String id, + final Operation.Type type ) { - return new Builder(type, id); + return new Builder(id, type); } public static OperationResultResourceId fromJson( @@ -448,19 +448,19 @@ public static OperationResultResourceId fromJson( @JsonPOJOBuilder(withPrefix = "") public static class Builder { - @JsonProperty("type") - private Operation.Type type; - @JsonProperty("id") private String id; + @JsonProperty("type") + private Operation.Type type; + @JsonCreator public Builder( - @JsonProperty("type") final Operation.Type type, - @JsonProperty("id") final String id + @JsonProperty("id") final String id, + @JsonProperty("type") final Operation.Type type ) { - this.type = type; this.id = id; + this.type = type; } public OperationResultResourceId build() { @@ -480,13 +480,13 @@ public boolean equals(final Object o) { OperationResultResourceId other = (OperationResultResourceId) o; return ( - Objects.equals(type, other.type) && Objects.equals(id, other.id) + Objects.equals(id, other.id) && Objects.equals(type, other.type) ); } @Override public int hashCode() { - return Objects.hash(type, id); + return Objects.hash(id, type); } } diff --git a/src/main/java/com/twilio/rest/messaging/v2/ChannelsSender.java b/src/main/java/com/twilio/rest/messaging/v2/ChannelsSender.java index 5621537ae9..37b3095e0a 100644 --- a/src/main/java/com/twilio/rest/messaging/v2/ChannelsSender.java +++ b/src/main/java/com/twilio/rest/messaging/v2/ChannelsSender.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.twilio.base.Resource; import com.twilio.base.Resource; import com.twilio.converter.Promoter; @@ -36,6 +37,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.time.ZonedDateTime; import java.util.List; import java.util.Objects; import lombok.Builder; @@ -119,6 +121,35 @@ public static CallbackMethod forValue(final String value) { } } + public enum PendingDisplayNameStatus { + PENDING_REVIEW("PENDING_REVIEW"), + APPROVED("APPROVED"), + DECLINED("DECLINED"), + PIN_MISMATCH("PIN_MISMATCH"), + REGISTRATION_FAILED("REGISTRATION_FAILED"), + EXPIRED("EXPIRED"), + COMPLETED("COMPLETED"); + + private final String value; + + private PendingDisplayNameStatus(final String value) { + this.value = value; + } + + @JsonValue + public String toString() { + return value; + } + + @JsonCreator + public static PendingDisplayNameStatus forValue(final String value) { + return Promoter.enumFromString( + value, + PendingDisplayNameStatus.values() + ); + } + } + public enum MessagingV2RcsCarrierStatus { UNKNOWN("UNKNOWN"), UNLAUNCHED("UNLAUNCHED"), @@ -212,6 +243,29 @@ public static AccountType forValue(final String value) { } } + public enum DisplayNameStatus { + UPDATING("updating"), + NO_CHANGE("no_change"), + PENDING_REVIEW("pending_review"), + ERROR("error"); + + private final String value; + + private DisplayNameStatus(final String value) { + this.value = value; + } + + @JsonValue + public String toString() { + return value; + } + + @JsonCreator + public static DisplayNameStatus forValue(final String value) { + return Promoter.enumFromString(value, DisplayNameStatus.values()); + } + } + public enum FallbackMethod { POST("POST"), PUT("PUT"); @@ -2335,6 +2389,9 @@ public static String toJson(Object object, ObjectMapper mapper) { @Getter private final MessagingV2ChannelsSenderConfiguration configuration; + @Getter + private final ChannelsSender.DisplayNameStatus displayNameStatus; + @Getter private final String friendlyName; @@ -2343,6 +2400,16 @@ public static String toJson(Object object, ObjectMapper mapper) { MessagingV2ChannelsSenderOfflineReasonsItems > offlineReasons; + @Getter + private final String pendingDisplayName; + + @Getter + private final ChannelsSender.PendingDisplayNameStatus pendingDisplayNameStatus; + + @JsonSerialize(using = com.twilio.converter.ISO8601Serializer.class) + @Getter + private final ZonedDateTime pendingDisplayNameStatusDate; + @Getter private final MessagingV2ChannelsSenderProfileGenericResponse profile; @@ -2372,10 +2439,22 @@ private ChannelsSender( @JsonProperty( "configuration" ) final MessagingV2ChannelsSenderConfiguration configuration, + @JsonProperty( + "display_name_status" + ) final ChannelsSender.DisplayNameStatus displayNameStatus, @JsonProperty("friendly_name") final String friendlyName, @JsonProperty("offline_reasons") final List< MessagingV2ChannelsSenderOfflineReasonsItems > offlineReasons, + @JsonProperty("pending_display_name") final String pendingDisplayName, + @JsonProperty( + "pending_display_name_status" + ) final ChannelsSender.PendingDisplayNameStatus pendingDisplayNameStatus, + @JsonProperty("pending_display_name_status_date") @JsonDeserialize( + using = com.twilio.converter.ISO8601Deserializer.class + ) @JsonSerialize( + using = com.twilio.converter.ISO8601Serializer.class + ) final ZonedDateTime pendingDisplayNameStatusDate, @JsonProperty( "profile" ) final MessagingV2ChannelsSenderProfileGenericResponse profile, @@ -2390,8 +2469,12 @@ private ChannelsSender( ) { this.compliance = compliance; this.configuration = configuration; + this.displayNameStatus = displayNameStatus; this.friendlyName = friendlyName; this.offlineReasons = offlineReasons; + this.pendingDisplayName = pendingDisplayName; + this.pendingDisplayNameStatus = pendingDisplayNameStatus; + this.pendingDisplayNameStatusDate = pendingDisplayNameStatusDate; this.profile = profile; this.properties = properties; this.senderId = senderId; @@ -2415,8 +2498,18 @@ public boolean equals(final Object o) { return ( Objects.equals(compliance, other.compliance) && Objects.equals(configuration, other.configuration) && + Objects.equals(displayNameStatus, other.displayNameStatus) && Objects.equals(friendlyName, other.friendlyName) && Objects.equals(offlineReasons, other.offlineReasons) && + Objects.equals(pendingDisplayName, other.pendingDisplayName) && + Objects.equals( + pendingDisplayNameStatus, + other.pendingDisplayNameStatus + ) && + Objects.equals( + pendingDisplayNameStatusDate, + other.pendingDisplayNameStatusDate + ) && Objects.equals(profile, other.profile) && Objects.equals(properties, other.properties) && Objects.equals(senderId, other.senderId) && @@ -2432,8 +2525,12 @@ public int hashCode() { return Objects.hash( compliance, configuration, + displayNameStatus, friendlyName, offlineReasons, + pendingDisplayName, + pendingDisplayNameStatus, + pendingDisplayNameStatusDate, profile, properties, senderId, diff --git a/src/main/java/com/twilio/rest/numbers/v1/SmsVerification.java b/src/main/java/com/twilio/rest/numbers/v1/SmsVerification.java index 45dc277bf3..c2e7db26fd 100644 --- a/src/main/java/com/twilio/rest/numbers/v1/SmsVerification.java +++ b/src/main/java/com/twilio/rest/numbers/v1/SmsVerification.java @@ -43,8 +43,113 @@ @ToString public class SmsVerification extends Resource { - public static SmsVerificationCreator creator() { - return new SmsVerificationCreator(); + public static SmsVerificationCreator creator( + final SmsVerification.NumbersV1SmsVerificationRequest numbersV1SmsVerificationRequest + ) { + return new SmsVerificationCreator(numbersV1SmsVerificationRequest); + } + + @JsonDeserialize(builder = NumbersV1SmsVerificationRequest.Builder.class) + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @ToString + public static class NumbersV1SmsVerificationRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("to") + @Getter + private final String to; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("locale") + @Getter + private final String locale; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("friendly_name") + @Getter + private final String friendlyName; + + private NumbersV1SmsVerificationRequest(Builder builder) { + this.to = builder.to; + this.locale = builder.locale; + this.friendlyName = builder.friendlyName; + } + + public static Builder builder(final String to) { + return new Builder(to); + } + + public static NumbersV1SmsVerificationRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + NumbersV1SmsVerificationRequest.class + ); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonPOJOBuilder(withPrefix = "") + public static class Builder { + + @JsonProperty("to") + private String to; + + @JsonProperty("locale") + private String locale; + + @JsonProperty("friendly_name") + private String friendlyName; + + @JsonCreator + public Builder(@JsonProperty("to") final String to) { + this.to = to; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("locale") + public Builder locale(String locale) { + this.locale = locale; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("friendly_name") + public Builder friendlyName(String friendlyName) { + this.friendlyName = friendlyName; + return this; + } + + public NumbersV1SmsVerificationRequest build() { + return new NumbersV1SmsVerificationRequest(this); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + NumbersV1SmsVerificationRequest other = + (NumbersV1SmsVerificationRequest) o; + return ( + Objects.equals(to, other.to) && + Objects.equals(locale, other.locale) && + Objects.equals(friendlyName, other.friendlyName) + ); + } + + @Override + public int hashCode() { + return Objects.hash(to, locale, friendlyName); + } } @JsonDeserialize( diff --git a/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheck.java b/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheck.java index 661e0f5967..c975c3313b 100644 --- a/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheck.java +++ b/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheck.java @@ -16,12 +16,15 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.twilio.base.Resource; import com.twilio.base.Resource; import com.twilio.exception.ApiConnectionException; @@ -31,6 +34,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Objects; +import lombok.Builder; import lombok.Getter; import lombok.ToString; @@ -38,8 +42,117 @@ @ToString public class SmsVerificationCheck extends Resource { - public static SmsVerificationCheckCreator creator() { - return new SmsVerificationCheckCreator(); + public static SmsVerificationCheckCreator creator( + final SmsVerificationCheck.NumbersV1SmsVerificationCheckRequest numbersV1SmsVerificationCheckRequest + ) { + return new SmsVerificationCheckCreator( + numbersV1SmsVerificationCheckRequest + ); + } + + @JsonDeserialize( + builder = NumbersV1SmsVerificationCheckRequest.Builder.class + ) + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @ToString + public static class NumbersV1SmsVerificationCheckRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("to") + @Getter + private final String to; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("verification_code") + @Getter + private final String verificationCode; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("friendly_name") + @Getter + private final String friendlyName; + + private NumbersV1SmsVerificationCheckRequest(Builder builder) { + this.to = builder.to; + this.verificationCode = builder.verificationCode; + this.friendlyName = builder.friendlyName; + } + + public static Builder builder( + final String to, + final String verificationCode + ) { + return new Builder(to, verificationCode); + } + + public static NumbersV1SmsVerificationCheckRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + NumbersV1SmsVerificationCheckRequest.class + ); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonPOJOBuilder(withPrefix = "") + public static class Builder { + + @JsonProperty("to") + private String to; + + @JsonProperty("verification_code") + private String verificationCode; + + @JsonProperty("friendly_name") + private String friendlyName; + + @JsonCreator + public Builder( + @JsonProperty("to") final String to, + @JsonProperty("verification_code") final String verificationCode + ) { + this.to = to; + this.verificationCode = verificationCode; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("friendly_name") + public Builder friendlyName(String friendlyName) { + this.friendlyName = friendlyName; + return this; + } + + public NumbersV1SmsVerificationCheckRequest build() { + return new NumbersV1SmsVerificationCheckRequest(this); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + NumbersV1SmsVerificationCheckRequest other = + (NumbersV1SmsVerificationCheckRequest) o; + return ( + Objects.equals(to, other.to) && + Objects.equals(verificationCode, other.verificationCode) && + Objects.equals(friendlyName, other.friendlyName) + ); + } + + @Override + public int hashCode() { + return Objects.hash(to, verificationCode, friendlyName); + } } /** diff --git a/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheckCreator.java b/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheckCreator.java index fcae1f207c..474f227a2f 100644 --- a/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheckCreator.java +++ b/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCheckCreator.java @@ -14,8 +14,10 @@ package com.twilio.rest.numbers.v1; +import com.fasterxml.jackson.databind.ObjectMapper; import com.twilio.base.Creator; import com.twilio.base.TwilioResponse; +import com.twilio.constant.EnumConstants; import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; @@ -29,7 +31,22 @@ public class SmsVerificationCheckCreator extends Creator { - public SmsVerificationCheckCreator() {} + private SmsVerificationCheck.NumbersV1SmsVerificationCheckRequest numbersV1SmsVerificationCheckRequest; + + public SmsVerificationCheckCreator( + final SmsVerificationCheck.NumbersV1SmsVerificationCheckRequest numbersV1SmsVerificationCheckRequest + ) { + this.numbersV1SmsVerificationCheckRequest = + numbersV1SmsVerificationCheckRequest; + } + + public SmsVerificationCheckCreator setNumbersV1SmsVerificationCheckRequest( + final SmsVerificationCheck.NumbersV1SmsVerificationCheckRequest numbersV1SmsVerificationCheckRequest + ) { + this.numbersV1SmsVerificationCheckRequest = + numbersV1SmsVerificationCheckRequest; + return this; + } private Response makeRequest(final TwilioRestClient client) { String path = "/v1/CallerIds/SmsVerificationChecks"; @@ -39,6 +56,8 @@ private Response makeRequest(final TwilioRestClient client) { Domains.NUMBERS.toString(), path ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); Response response = client.request(request); @@ -87,4 +106,16 @@ public TwilioResponse createWithResponse( response.getHeaders() ); } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (numbersV1SmsVerificationCheckRequest != null) { + request.setBody( + SmsVerificationCheck.toJson( + numbersV1SmsVerificationCheckRequest, + objectMapper + ) + ); + } + } } diff --git a/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCreator.java b/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCreator.java index 5cf07d8b74..24731d3fa8 100644 --- a/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCreator.java +++ b/src/main/java/com/twilio/rest/numbers/v1/SmsVerificationCreator.java @@ -14,8 +14,10 @@ package com.twilio.rest.numbers.v1; +import com.fasterxml.jackson.databind.ObjectMapper; import com.twilio.base.Creator; import com.twilio.base.TwilioResponse; +import com.twilio.constant.EnumConstants; import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; @@ -29,7 +31,20 @@ public class SmsVerificationCreator extends Creator { - public SmsVerificationCreator() {} + private SmsVerification.NumbersV1SmsVerificationRequest numbersV1SmsVerificationRequest; + + public SmsVerificationCreator( + final SmsVerification.NumbersV1SmsVerificationRequest numbersV1SmsVerificationRequest + ) { + this.numbersV1SmsVerificationRequest = numbersV1SmsVerificationRequest; + } + + public SmsVerificationCreator setNumbersV1SmsVerificationRequest( + final SmsVerification.NumbersV1SmsVerificationRequest numbersV1SmsVerificationRequest + ) { + this.numbersV1SmsVerificationRequest = numbersV1SmsVerificationRequest; + return this; + } private Response makeRequest(final TwilioRestClient client) { String path = "/v1/CallerIds/SmsVerifications"; @@ -39,6 +54,8 @@ private Response makeRequest(final TwilioRestClient client) { Domains.NUMBERS.toString(), path ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); Response response = client.request(request); @@ -87,4 +104,16 @@ public TwilioResponse createWithResponse( response.getHeaders() ); } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (numbersV1SmsVerificationRequest != null) { + request.setBody( + SmsVerification.toJson( + numbersV1SmsVerificationRequest, + objectMapper + ) + ); + } + } } diff --git a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerification.java b/src/main/java/com/twilio/rest/numbers/v1/VoiceVerification.java index d825facc66..36ccaf544e 100644 --- a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerification.java +++ b/src/main/java/com/twilio/rest/numbers/v1/VoiceVerification.java @@ -16,21 +16,28 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.twilio.base.Resource; import com.twilio.base.Resource; +import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.type.*; import java.io.IOException; import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.util.Objects; +import lombok.Builder; import lombok.Getter; import lombok.ToString; @@ -38,8 +45,242 @@ @ToString public class VoiceVerification extends Resource { - public static VoiceVerificationCreator creator() { - return new VoiceVerificationCreator(); + public static VoiceVerificationCreator creator( + final VoiceVerification.NumbersV1VoiceVerificationRequest numbersV1VoiceVerificationRequest + ) { + return new VoiceVerificationCreator(numbersV1VoiceVerificationRequest); + } + + public enum StatusCallbackMethod { + HEAD("HEAD"), + GET("GET"), + POST("POST"), + PATCH("PATCH"), + PUT("PUT"), + DELETE("DELETE"); + + private final String value; + + private StatusCallbackMethod(final String value) { + this.value = value; + } + + @JsonValue + public String toString() { + return value; + } + + @JsonCreator + public static StatusCallbackMethod forValue(final String value) { + return Promoter.enumFromString( + value, + StatusCallbackMethod.values() + ); + } + } + + @JsonDeserialize(builder = NumbersV1VoiceVerificationRequest.Builder.class) + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @ToString + public static class NumbersV1VoiceVerificationRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("phone_number") + @Getter + private final String phoneNumber; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("friendly_name") + @Getter + private final String friendlyName; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("custom_code") + @Getter + private final String customCode; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("call_delay") + @Getter + private final String callDelay; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("status_callback") + @Getter + private final URI statusCallback; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("status_callback_method") + @Getter + private final VoiceVerification.StatusCallbackMethod statusCallbackMethod; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("extension") + @Getter + private final String extension; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("custom_success_message") + @Getter + private final String customSuccessMessage; + + private NumbersV1VoiceVerificationRequest(Builder builder) { + this.phoneNumber = builder.phoneNumber; + this.friendlyName = builder.friendlyName; + this.customCode = builder.customCode; + this.callDelay = builder.callDelay; + this.statusCallback = builder.statusCallback; + this.statusCallbackMethod = builder.statusCallbackMethod; + this.extension = builder.extension; + this.customSuccessMessage = builder.customSuccessMessage; + } + + public static Builder builder(final String phoneNumber) { + return new Builder(phoneNumber); + } + + public static NumbersV1VoiceVerificationRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + NumbersV1VoiceVerificationRequest.class + ); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonPOJOBuilder(withPrefix = "") + public static class Builder { + + @JsonProperty("phone_number") + private String phoneNumber; + + @JsonProperty("friendly_name") + private String friendlyName; + + @JsonProperty("custom_code") + private String customCode; + + @JsonProperty("call_delay") + private String callDelay; + + @JsonProperty("status_callback") + private URI statusCallback; + + @JsonProperty("status_callback_method") + private VoiceVerification.StatusCallbackMethod statusCallbackMethod; + + @JsonProperty("extension") + private String extension; + + @JsonProperty("custom_success_message") + private String customSuccessMessage; + + @JsonCreator + public Builder( + @JsonProperty("phone_number") final String phoneNumber + ) { + this.phoneNumber = phoneNumber; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("friendly_name") + public Builder friendlyName(String friendlyName) { + this.friendlyName = friendlyName; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("custom_code") + public Builder customCode(String customCode) { + this.customCode = customCode; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("call_delay") + public Builder callDelay(String callDelay) { + this.callDelay = callDelay; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("status_callback") + public Builder statusCallback(URI statusCallback) { + this.statusCallback = statusCallback; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("status_callback_method") + public Builder statusCallbackMethod( + VoiceVerification.StatusCallbackMethod statusCallbackMethod + ) { + this.statusCallbackMethod = statusCallbackMethod; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("extension") + public Builder extension(String extension) { + this.extension = extension; + return this; + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("custom_success_message") + public Builder customSuccessMessage(String customSuccessMessage) { + this.customSuccessMessage = customSuccessMessage; + return this; + } + + public NumbersV1VoiceVerificationRequest build() { + return new NumbersV1VoiceVerificationRequest(this); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + NumbersV1VoiceVerificationRequest other = + (NumbersV1VoiceVerificationRequest) o; + return ( + Objects.equals(phoneNumber, other.phoneNumber) && + Objects.equals(friendlyName, other.friendlyName) && + Objects.equals(customCode, other.customCode) && + Objects.equals(callDelay, other.callDelay) && + Objects.equals(statusCallback, other.statusCallback) && + Objects.equals( + statusCallbackMethod, + other.statusCallbackMethod + ) && + Objects.equals(extension, other.extension) && + Objects.equals(customSuccessMessage, other.customSuccessMessage) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + phoneNumber, + friendlyName, + customCode, + callDelay, + statusCallback, + statusCallbackMethod, + extension, + customSuccessMessage + ); + } } /** diff --git a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCheck.java b/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCheck.java deleted file mode 100644 index 3b46aacc60..0000000000 --- a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCheck.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Numbers - * This is the public Twilio REST API. - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.twilio.rest.numbers.v1; - -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.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.twilio.base.Resource; -import com.twilio.base.Resource; -import com.twilio.exception.ApiConnectionException; -import com.twilio.exception.ApiException; -import com.twilio.type.*; -import java.io.IOException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Objects; -import lombok.Getter; -import lombok.ToString; - -@JsonIgnoreProperties(ignoreUnknown = true) -@ToString -public class VoiceVerificationCheck extends Resource { - - public static VoiceVerificationCheckCreator creator() { - return new VoiceVerificationCheckCreator(); - } - - /** - * Converts a JSON String into a VoiceVerificationCheck object using the provided ObjectMapper. - * - * @param json Raw JSON String - * @param objectMapper Jackson ObjectMapper - * @return VoiceVerificationCheck object represented by the provided JSON - */ - public static VoiceVerificationCheck fromJson( - final String json, - final ObjectMapper objectMapper - ) { - // Convert all checked exceptions to Runtime - try { - return objectMapper.readValue(json, VoiceVerificationCheck.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 VoiceVerificationCheck object using the provided - * ObjectMapper. - * - * @param json Raw JSON InputStream - * @param objectMapper Jackson ObjectMapper - * @return VoiceVerificationCheck object represented by the provided JSON - */ - public static VoiceVerificationCheck fromJson( - final InputStream json, - final ObjectMapper objectMapper - ) { - // Convert all checked exceptions to Runtime - try { - return objectMapper.readValue(json, VoiceVerificationCheck.class); - } catch (final JsonMappingException | JsonParseException e) { - throw new ApiException(e.getMessage(), e); - } catch (final IOException e) { - throw new ApiConnectionException(e.getMessage(), e); - } - } - - public static String toJson(Object object, ObjectMapper mapper) { - try { - return mapper.writeValueAsString(object); - } catch (final JsonMappingException e) { - throw new ApiException(e.getMessage(), e); - } catch (JsonProcessingException e) { - throw new ApiException(e.getMessage(), e); - } catch (final IOException e) { - throw new ApiConnectionException(e.getMessage(), e); - } - } - - @Getter - private final String callerIdSid; - - @Getter - private final String to; - - @JsonCreator - private VoiceVerificationCheck( - @JsonProperty("callerIdSid") final String callerIdSid, - @JsonProperty("to") final String to - ) { - this.callerIdSid = callerIdSid; - this.to = to; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - VoiceVerificationCheck other = (VoiceVerificationCheck) o; - return ( - Objects.equals(callerIdSid, other.callerIdSid) && - Objects.equals(to, other.to) - ); - } - - @Override - public int hashCode() { - return Objects.hash(callerIdSid, to); - } -} diff --git a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCreator.java b/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCreator.java index eee57ca8b4..00f15b4832 100644 --- a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCreator.java +++ b/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCreator.java @@ -14,8 +14,10 @@ package com.twilio.rest.numbers.v1; +import com.fasterxml.jackson.databind.ObjectMapper; import com.twilio.base.Creator; import com.twilio.base.TwilioResponse; +import com.twilio.constant.EnumConstants; import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; import com.twilio.exception.RestException; @@ -29,7 +31,22 @@ public class VoiceVerificationCreator extends Creator { - public VoiceVerificationCreator() {} + private VoiceVerification.NumbersV1VoiceVerificationRequest numbersV1VoiceVerificationRequest; + + public VoiceVerificationCreator( + final VoiceVerification.NumbersV1VoiceVerificationRequest numbersV1VoiceVerificationRequest + ) { + this.numbersV1VoiceVerificationRequest = + numbersV1VoiceVerificationRequest; + } + + public VoiceVerificationCreator setNumbersV1VoiceVerificationRequest( + final VoiceVerification.NumbersV1VoiceVerificationRequest numbersV1VoiceVerificationRequest + ) { + this.numbersV1VoiceVerificationRequest = + numbersV1VoiceVerificationRequest; + return this; + } private Response makeRequest(final TwilioRestClient client) { String path = "/v1/CallerIds/VoiceVerifications"; @@ -39,6 +56,8 @@ private Response makeRequest(final TwilioRestClient client) { Domains.NUMBERS.toString(), path ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); Response response = client.request(request); @@ -87,4 +106,16 @@ public TwilioResponse createWithResponse( response.getHeaders() ); } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (numbersV1VoiceVerificationRequest != null) { + request.setBody( + VoiceVerification.toJson( + numbersV1VoiceVerificationRequest, + objectMapper + ) + ); + } + } } diff --git a/src/main/java/com/twilio/rest/preview/hostedNumbers/AuthorizationDocument.java b/src/main/java/com/twilio/rest/preview/hostedNumbers/AuthorizationDocument.java index 37eb18f2dc..1a8f6419c0 100644 --- a/src/main/java/com/twilio/rest/preview/hostedNumbers/AuthorizationDocument.java +++ b/src/main/java/com/twilio/rest/preview/hostedNumbers/AuthorizationDocument.java @@ -62,6 +62,10 @@ public static AuthorizationDocumentCreator creator( ); } + public static AuthorizationDocumentDeleter deleter(final String pathSid) { + return new AuthorizationDocumentDeleter(pathSid); + } + public static AuthorizationDocumentFetcher fetcher(final String pathSid) { return new AuthorizationDocumentFetcher(pathSid); } diff --git a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCheckCreator.java b/src/main/java/com/twilio/rest/preview/hostedNumbers/AuthorizationDocumentDeleter.java similarity index 63% rename from src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCheckCreator.java rename to src/main/java/com/twilio/rest/preview/hostedNumbers/AuthorizationDocumentDeleter.java index c8ddbc1a42..5971d49814 100644 --- a/src/main/java/com/twilio/rest/numbers/v1/VoiceVerificationCheckCreator.java +++ b/src/main/java/com/twilio/rest/preview/hostedNumbers/AuthorizationDocumentDeleter.java @@ -4,7 +4,7 @@ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ * - * Twilio - Numbers + * Twilio - Preview * This is the public Twilio REST API. * * NOTE: This class is auto generated by OpenAPI Generator. @@ -12,9 +12,9 @@ * Do not edit the class manually. */ -package com.twilio.rest.numbers.v1; +package com.twilio.rest.preview.hostedNumbers; -import com.twilio.base.Creator; +import com.twilio.base.Deleter; import com.twilio.base.TwilioResponse; import com.twilio.exception.ApiConnectionException; import com.twilio.exception.ApiException; @@ -26,18 +26,27 @@ import com.twilio.rest.Domains; import com.twilio.type.*; import java.io.InputStream; +import java.util.function.Predicate; -public class VoiceVerificationCheckCreator - extends Creator { +public class AuthorizationDocumentDeleter + extends Deleter { - public VoiceVerificationCheckCreator() {} + private String pathSid; + + public AuthorizationDocumentDeleter(final String pathSid) { + this.pathSid = pathSid; + } private Response makeRequest(final TwilioRestClient client) { - String path = "/v1/CallerIds/VoiceVerificationChecks"; + String path = "/HostedNumbers/AuthorizationDocuments/{Sid}"; + + path = path.replace("{" + "Sid" + "}", this.pathSid.toString()); + Predicate deleteStatuses = i -> + i != null && i >= 200 && i < 300; Request request = new Request( - HttpMethod.POST, - Domains.NUMBERS.toString(), + HttpMethod.DELETE, + Domains.PREVIEW.toString(), path ); @@ -45,7 +54,7 @@ private Response makeRequest(final TwilioRestClient client) { if (response == null) { throw new ApiConnectionException( - "VoiceVerificationCheck creation failed: Unable to connect to server" + "AuthorizationDocument delete failed: Unable to connect to server" ); } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { InputStream inputStream = response.getStream(); @@ -65,25 +74,23 @@ private Response makeRequest(final TwilioRestClient client) { } @Override - public VoiceVerificationCheck create(final TwilioRestClient client) { + public boolean delete(final TwilioRestClient client) { Response response = makeRequest(client); - return VoiceVerificationCheck.fromJson( - response.getStream(), - client.getObjectMapper() - ); + Predicate deleteStatuses = i -> + i != null && i >= 200 && i < 300; + return deleteStatuses.test(response.getStatusCode()); } @Override - public TwilioResponse createWithResponse( + public TwilioResponse deleteWithResponse( final TwilioRestClient client ) { Response response = makeRequest(client); - VoiceVerificationCheck content = VoiceVerificationCheck.fromJson( - response.getStream(), - client.getObjectMapper() - ); + Predicate deleteStatuses = i -> + i != null && i >= 200 && i < 300; + Boolean deleted = deleteStatuses.test(response.getStatusCode()); return new TwilioResponse<>( - content, + deleted, response.getStatusCode(), response.getHeaders() ); diff --git a/src/main/java/com/twilio/rest/routes/v3/IsoCountryCode.java b/src/main/java/com/twilio/rest/routes/v3/IsoCountryCode.java new file mode 100644 index 0000000000..326cf6b71c --- /dev/null +++ b/src/main/java/com/twilio/rest/routes/v3/IsoCountryCode.java @@ -0,0 +1,499 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Routes + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.routes.v3; + +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.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.base.Resource; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.type.*; +import java.io.IOException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.time.ZonedDateTime; +import java.util.Objects; +import lombok.Getter; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class IsoCountryCode extends Resource { + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class CreateIsoCountryCodeResponse extends Resource { + + @JsonCreator + private CreateIsoCountryCodeResponse() {} + + public static CreateIsoCountryCodeResponse fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue( + json, + CreateIsoCountryCodeResponse.class + ); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateIsoCountryCodeResponse other = + (CreateIsoCountryCodeResponse) o; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class UpdateIsoCountryCodeResponse extends Resource { + + @Getter + private final String accountSid; + + @Getter + private final ZonedDateTime dateCreated; + + @Getter + private final ZonedDateTime dateUpdated; + + @Getter + private final String friendlyName; + + @Getter + private final String isoCountryCode; + + @Getter + private final String messagingRegion; + + @Getter + private final String shortCode; + + @Getter + private final URI url; + + @JsonCreator + private UpdateIsoCountryCodeResponse( + @JsonProperty("accountSid") final String accountSid, + @JsonProperty("dateCreated") final ZonedDateTime dateCreated, + @JsonProperty("dateUpdated") final ZonedDateTime dateUpdated, + @JsonProperty("friendlyName") final String friendlyName, + @JsonProperty("isoCountryCode") final String isoCountryCode, + @JsonProperty("messagingRegion") final String messagingRegion, + @JsonProperty("shortCode") final String shortCode, + @JsonProperty("url") final URI url + ) { + this.accountSid = accountSid; + this.dateCreated = dateCreated; + this.dateUpdated = dateUpdated; + this.friendlyName = friendlyName; + this.isoCountryCode = isoCountryCode; + this.messagingRegion = messagingRegion; + this.shortCode = shortCode; + this.url = url; + } + + public static UpdateIsoCountryCodeResponse fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue( + json, + UpdateIsoCountryCodeResponse.class + ); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateIsoCountryCodeResponse other = + (UpdateIsoCountryCodeResponse) o; + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) && + Objects.equals(friendlyName, other.friendlyName) && + Objects.equals(isoCountryCode, other.isoCountryCode) && + Objects.equals(messagingRegion, other.messagingRegion) && + Objects.equals(shortCode, other.shortCode) && + Objects.equals(url, other.url) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + accountSid, + dateCreated, + dateUpdated, + friendlyName, + isoCountryCode, + messagingRegion, + shortCode, + url + ); + } + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class DeleteIsoCountryCodeResponse extends Resource { + + @JsonCreator + private DeleteIsoCountryCodeResponse() {} + + public static DeleteIsoCountryCodeResponse fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue( + json, + DeleteIsoCountryCodeResponse.class + ); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteIsoCountryCodeResponse other = + (DeleteIsoCountryCodeResponse) o; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class ListIsoCountryCodeResponse extends Resource { + + @JsonCreator + private ListIsoCountryCodeResponse() {} + + public static ListIsoCountryCodeResponse fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue( + json, + ListIsoCountryCodeResponse.class + ); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + ListIsoCountryCodeResponse other = (ListIsoCountryCodeResponse) o; + return (true); + } + + @Override + public int hashCode() { + return Objects.hash(); + } + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class PatchIsoCountryCodeResponse extends Resource { + + @JsonCreator + private PatchIsoCountryCodeResponse() {} + + public static PatchIsoCountryCodeResponse fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue( + json, + PatchIsoCountryCodeResponse.class + ); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + PatchIsoCountryCodeResponse other = (PatchIsoCountryCodeResponse) o; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class FetchIsoCountryCodeResponse extends Resource { + + @Getter + private final String accountSid; + + @Getter + private final ZonedDateTime dateCreated; + + @Getter + private final ZonedDateTime dateUpdated; + + @Getter + private final String friendlyName; + + @Getter + private final String isoCountryCode; + + @Getter + private final String messagingRegion; + + @Getter + private final String shortCode; + + @Getter + private final URI url; + + @JsonCreator + private FetchIsoCountryCodeResponse( + @JsonProperty("accountSid") final String accountSid, + @JsonProperty("dateCreated") final ZonedDateTime dateCreated, + @JsonProperty("dateUpdated") final ZonedDateTime dateUpdated, + @JsonProperty("friendlyName") final String friendlyName, + @JsonProperty("isoCountryCode") final String isoCountryCode, + @JsonProperty("messagingRegion") final String messagingRegion, + @JsonProperty("shortCode") final String shortCode, + @JsonProperty("url") final URI url + ) { + this.accountSid = accountSid; + this.dateCreated = dateCreated; + this.dateUpdated = dateUpdated; + this.friendlyName = friendlyName; + this.isoCountryCode = isoCountryCode; + this.messagingRegion = messagingRegion; + this.shortCode = shortCode; + this.url = url; + } + + public static FetchIsoCountryCodeResponse fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue( + json, + FetchIsoCountryCodeResponse.class + ); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + FetchIsoCountryCodeResponse other = (FetchIsoCountryCodeResponse) o; + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) && + Objects.equals(friendlyName, other.friendlyName) && + Objects.equals(isoCountryCode, other.isoCountryCode) && + Objects.equals(messagingRegion, other.messagingRegion) && + Objects.equals(shortCode, other.shortCode) && + Objects.equals(url, other.url) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + accountSid, + dateCreated, + dateUpdated, + friendlyName, + isoCountryCode, + messagingRegion, + shortCode, + url + ); + } + } + + public static IsoCountryCodeFetcher fetcher( + final String pathIsoCountryCode, + final String pathShortCode + ) { + return new IsoCountryCodeFetcher(pathIsoCountryCode, pathShortCode); + } + + public static IsoCountryCodeUpdater updater( + final String pathIsoCountryCode, + final String pathShortCode + ) { + return new IsoCountryCodeUpdater(pathIsoCountryCode, pathShortCode); + } + + /** + * Converts a JSON String into a IsoCountryCode object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return IsoCountryCode object represented by the provided JSON + */ + public static IsoCountryCode fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, IsoCountryCode.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 IsoCountryCode object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return IsoCountryCode object represented by the provided JSON + */ + public static IsoCountryCode fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, IsoCountryCode.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + @JsonCreator + private IsoCountryCode() {} + + @Override + public boolean equals(Object obj) { + return obj != null && obj.getClass() == this.getClass(); + } + + @Override + public int hashCode() { + return 1; + } +} diff --git a/src/main/java/com/twilio/rest/routes/v3/IsoCountryCodeFetcher.java b/src/main/java/com/twilio/rest/routes/v3/IsoCountryCodeFetcher.java new file mode 100644 index 0000000000..2139a05713 --- /dev/null +++ b/src/main/java/com/twilio/rest/routes/v3/IsoCountryCodeFetcher.java @@ -0,0 +1,114 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Routes + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.routes.v3; + +import com.twilio.base.Fetcher; +import com.twilio.base.TwilioResponse; +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 com.twilio.type.*; +import java.io.InputStream; + +public class IsoCountryCodeFetcher + extends Fetcher { + + private String pathIsoCountryCode; + private String pathShortCode; + + public IsoCountryCodeFetcher( + final String pathIsoCountryCode, + final String pathShortCode + ) { + this.pathIsoCountryCode = pathIsoCountryCode; + this.pathShortCode = pathShortCode; + } + + private Response makeRequest(final TwilioRestClient client) { + String path = "/v3/ShortCodes/{isoCountryCode}/{shortCode}"; + + path = + path.replace( + "{" + "isoCountryCode" + "}", + this.pathIsoCountryCode.toString() + ); + path = + path.replace( + "{" + "shortCode" + "}", + this.pathShortCode.toString() + ); + + Request request = new Request( + HttpMethod.GET, + Domains.ROUTES.toString(), + path + ); + + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "IsoCountryCode fetch failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + InputStream inputStream = response.getStream(); + RestException restException = RestException.fromJson( + inputStream, + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + return response; + } + + @Override + public IsoCountryCode.FetchIsoCountryCodeResponse fetch( + final TwilioRestClient client + ) { + Response response = makeRequest(client); + return IsoCountryCode.FetchIsoCountryCodeResponse.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } + + @Override + public TwilioResponse< + IsoCountryCode.FetchIsoCountryCodeResponse + > fetchWithResponse(final TwilioRestClient client) { + Response response = makeRequest(client); + IsoCountryCode.FetchIsoCountryCodeResponse content = + IsoCountryCode.FetchIsoCountryCodeResponse.fromJson( + response.getStream(), + client.getObjectMapper() + ); + return new TwilioResponse<>( + content, + response.getStatusCode(), + response.getHeaders() + ); + } +} diff --git a/src/main/java/com/twilio/rest/routes/v3/IsoCountryCodeUpdater.java b/src/main/java/com/twilio/rest/routes/v3/IsoCountryCodeUpdater.java new file mode 100644 index 0000000000..1632238d52 --- /dev/null +++ b/src/main/java/com/twilio/rest/routes/v3/IsoCountryCodeUpdater.java @@ -0,0 +1,153 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Routes + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.routes.v3; + +import com.twilio.base.TwilioResponse; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.constant.EnumConstants.ParameterType; +import com.twilio.converter.Serializer; +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 com.twilio.type.*; +import java.io.InputStream; + +public class IsoCountryCodeUpdater + extends Updater { + + private String pathIsoCountryCode; + private String pathShortCode; + private String messagingRegion; + private String friendlyName; + + public IsoCountryCodeUpdater( + final String pathIsoCountryCode, + final String pathShortCode + ) { + this.pathIsoCountryCode = pathIsoCountryCode; + this.pathShortCode = pathShortCode; + } + + public IsoCountryCodeUpdater setMessagingRegion( + final String messagingRegion + ) { + this.messagingRegion = messagingRegion; + return this; + } + + public IsoCountryCodeUpdater setFriendlyName(final String friendlyName) { + this.friendlyName = friendlyName; + return this; + } + + private Response makeRequest(final TwilioRestClient client) { + String path = "/v3/ShortCodes/{isoCountryCode}/{shortCode}"; + + path = + path.replace( + "{" + "isoCountryCode" + "}", + this.pathIsoCountryCode.toString() + ); + path = + path.replace( + "{" + "shortCode" + "}", + this.pathShortCode.toString() + ); + + Request request = new Request( + HttpMethod.POST, + Domains.ROUTES.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + addPostParams(request); + + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "IsoCountryCode update failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + InputStream inputStream = response.getStream(); + RestException restException = RestException.fromJson( + inputStream, + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + return response; + } + + @Override + public IsoCountryCode.UpdateIsoCountryCodeResponse update( + final TwilioRestClient client + ) { + Response response = makeRequest(client); + return IsoCountryCode.UpdateIsoCountryCodeResponse.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } + + @Override + public TwilioResponse< + IsoCountryCode.UpdateIsoCountryCodeResponse + > updateWithResponse(final TwilioRestClient client) { + Response response = makeRequest(client); + IsoCountryCode.UpdateIsoCountryCodeResponse content = + IsoCountryCode.UpdateIsoCountryCodeResponse.fromJson( + response.getStream(), + client.getObjectMapper() + ); + return new TwilioResponse<>( + content, + response.getStatusCode(), + response.getHeaders() + ); + } + + private void addPostParams(final Request request) { + if (messagingRegion != null) { + Serializer.toString( + request, + "messagingRegion", + messagingRegion, + ParameterType.URLENCODED + ); + } + + if (friendlyName != null) { + Serializer.toString( + request, + "friendlyName", + friendlyName, + ParameterType.URLENCODED + ); + } + } +}