From 5bda9563ade98794029975c58d5da8d8f6da2d93 Mon Sep 17 00:00:00 2001 From: Twilio Date: Thu, 17 Oct 2024 14:06:38 +0000 Subject: [PATCH] [Librarian] Regenerated @ d97b0740a0c7cf86beebd56c6973927b07719cde 1fc3bb6195ebcbd02451fb8fc9080c695b075d4f --- CHANGES.md | 9 + .../rest/messaging/v1/RequestManagedCert.java | 198 ++++++++++++++++++ .../v1/RequestManagedCertUpdater.java | 77 +++++++ 3 files changed, 284 insertions(+) create mode 100644 src/main/java/com/twilio/rest/messaging/v1/RequestManagedCert.java create mode 100644 src/main/java/com/twilio/rest/messaging/v1/RequestManagedCertUpdater.java diff --git a/CHANGES.md b/CHANGES.md index b7ae3e5f8..0f10dcaf6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,15 @@ twilio-java changelog ===================== +[2024-10-17] Version 10.6.1 +--------------------------- +**Api** +- Add response key `country` to fetch AvailablePhoneNumber resource by specific country. + +**Messaging** +- Make library and doc public for requestManagedCert Endpoint + + [2024-10-03] Version 10.6.0 --------------------------- **Library - Chore** diff --git a/src/main/java/com/twilio/rest/messaging/v1/RequestManagedCert.java b/src/main/java/com/twilio/rest/messaging/v1/RequestManagedCert.java new file mode 100644 index 000000000..1f3075e35 --- /dev/null +++ b/src/main/java/com/twilio/rest/messaging/v1/RequestManagedCert.java @@ -0,0 +1,198 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Messaging + * 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.messaging.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.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.time.ZonedDateTime; +import java.util.Objects; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class RequestManagedCert extends Resource { + + private static final long serialVersionUID = 86009690306630L; + + public static RequestManagedCertUpdater updater( + final String pathDomainSid + ) { + return new RequestManagedCertUpdater(pathDomainSid); + } + + /** + * Converts a JSON String into a RequestManagedCert object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return RequestManagedCert object represented by the provided JSON + */ + public static RequestManagedCert fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, RequestManagedCert.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 RequestManagedCert object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return RequestManagedCert object represented by the provided JSON + */ + public static RequestManagedCert fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, RequestManagedCert.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 domainSid; + private final ZonedDateTime dateUpdated; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateExpires; + private final URI domainName; + private final String certificateSid; + private final URI url; + private final Boolean managed; + private final Boolean requesting; + + @JsonCreator + private RequestManagedCert( + @JsonProperty("domain_sid") final String domainSid, + @JsonProperty("date_updated") final String dateUpdated, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_expires") final String dateExpires, + @JsonProperty("domain_name") final URI domainName, + @JsonProperty("certificate_sid") final String certificateSid, + @JsonProperty("url") final URI url, + @JsonProperty("managed") final Boolean managed, + @JsonProperty("requesting") final Boolean requesting + ) { + this.domainSid = domainSid; + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateExpires = DateConverter.iso8601DateTimeFromString(dateExpires); + this.domainName = domainName; + this.certificateSid = certificateSid; + this.url = url; + this.managed = managed; + this.requesting = requesting; + } + + public final String getDomainSid() { + return this.domainSid; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateExpires() { + return this.dateExpires; + } + + public final URI getDomainName() { + return this.domainName; + } + + public final String getCertificateSid() { + return this.certificateSid; + } + + public final URI getUrl() { + return this.url; + } + + public final Boolean getManaged() { + return this.managed; + } + + public final Boolean getRequesting() { + return this.requesting; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + RequestManagedCert other = (RequestManagedCert) o; + + return ( + Objects.equals(domainSid, other.domainSid) && + Objects.equals(dateUpdated, other.dateUpdated) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateExpires, other.dateExpires) && + Objects.equals(domainName, other.domainName) && + Objects.equals(certificateSid, other.certificateSid) && + Objects.equals(url, other.url) && + Objects.equals(managed, other.managed) && + Objects.equals(requesting, other.requesting) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + domainSid, + dateUpdated, + dateCreated, + dateExpires, + domainName, + certificateSid, + url, + managed, + requesting + ); + } +} diff --git a/src/main/java/com/twilio/rest/messaging/v1/RequestManagedCertUpdater.java b/src/main/java/com/twilio/rest/messaging/v1/RequestManagedCertUpdater.java new file mode 100644 index 000000000..6f6208624 --- /dev/null +++ b/src/main/java/com/twilio/rest/messaging/v1/RequestManagedCertUpdater.java @@ -0,0 +1,77 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Messaging + * 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.messaging.v1; + +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +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 RequestManagedCertUpdater extends Updater { + + private String pathDomainSid; + + public RequestManagedCertUpdater(final String pathDomainSid) { + this.pathDomainSid = pathDomainSid; + } + + @Override + public RequestManagedCert update(final TwilioRestClient client) { + String path = + "/v1/LinkShortening/Domains/{DomainSid}/RequestManagedCert"; + + path = + path.replace( + "{" + "DomainSid" + "}", + this.pathDomainSid.toString() + ); + + Request request = new Request( + HttpMethod.POST, + Domains.MESSAGING.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "RequestManagedCert update 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", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return RequestManagedCert.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } +}