diff --git a/CHANGES.md b/CHANGES.md
index 8b45cb4a75..b921698312 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,16 @@
twilio-java changelog
=====================
+[2023-06-15] Version 9.7.0
+--------------------------
+**Api**
+- Added `content_sid` as conditional parameter
+- Removed `content_sid` as optional field **(breaking change)**
+
+**Insights**
+- Added `annotation` to list summary output
+
+
[2023-06-01] Version 9.6.2
--------------------------
**Api**
diff --git a/README.md b/README.md
index e06383635d..a239798cb0 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ Use the following dependency in your project to grab via Maven:
com.twilio.sdk
twilio
- 9.X.X
+ 10.X.X
compile
```
@@ -49,7 +49,7 @@ Use the following dependency in your project to grab via Maven:
or Gradle:
```groovy
-implementation "com.twilio.sdk:twilio:9.X.X"
+implementation "com.twilio.sdk:twilio:10.X.X"
```
If you want to compile it yourself, here's how:
diff --git a/UPGRADE.md b/UPGRADE.md
index a0f93b2554..8e7fe12cfb 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -2,6 +2,14 @@
_`MAJOR` version bumps will have upgrade notes posted here._
+[2024-02-08] 9.x.x to 10.x.x
+### Overview
+
+##### Twilio Java Helper Library’s major version 10.0.0 is now available. We ensured that you can upgrade to Java helper Library 10.0.0 version without any breaking changes of existing apis
+
+Behind the scenes Java Helper is now auto-generated via OpenAPI with this release. This enables us to rapidly add new features and enhance consistency across versions and languages.
+We're pleased to inform you that version 10.0.0 adds support for the application/json content type in the request body.
+
[2022-09-21] 8.x.x to 9.x.x
-----------------------------
### Overview
diff --git a/pom.xml b/pom.xml
index de880bc0ef..7d542e9218 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
twilio
jar
twilio
- 9.6.2
+ 10.0.0-rc.6
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
- 9.6.2
+ 10.0.0-rc.6
@@ -323,8 +323,8 @@
maven-compiler-plugin
3.8.1
-
- 8
+
+ 9
true
diff --git a/src/main/java/com/twilio/Domains.java b/src/main/java/com/twilio/Domains.java
index 035f623ce3..32da7bc0aa 100644
--- a/src/main/java/com/twilio/Domains.java
+++ b/src/main/java/com/twilio/Domains.java
@@ -26,6 +26,7 @@ public enum Domains {
IPMESSAGING("ip-messaging"),
LOOKUPS("lookups"),
MEDIA("media"),
+ PREVIEWMESSAGING("preview.messaging"),
MESSAGING("messaging"),
MICROVISOR("microvisor"),
MONITOR("monitor"),
diff --git a/src/main/java/com/twilio/Twilio.java b/src/main/java/com/twilio/Twilio.java
index 16244bd769..1d5d99fa56 100644
--- a/src/main/java/com/twilio/Twilio.java
+++ b/src/main/java/com/twilio/Twilio.java
@@ -21,7 +21,7 @@
*/
public class Twilio {
- public static final String VERSION = "9.6.2";
+ public static final String VERSION = "10.0.0-rc.6";
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");
@@ -241,7 +241,7 @@ public static void setExecutorService(final ExecutorService executorService) {
}
/**
- * Validate that we can connect to the new SSL certificate posted on api.twilio.com.
+ * Validate that we can connect to the new SSL certificate posted on tls-test.twilio.com
*
* @throws CertificateValidationException if the connection fails
*/
@@ -252,7 +252,7 @@ public static void validateSslCertificate() {
public static void validateSslCertificate(NetworkHttpClient client) {
- final Request request = new Request(HttpMethod.GET, "https://api.twilio.com:8443");
+ final Request request = new Request(HttpMethod.GET, "https://tls-test.twilio.com:443");
try {
final Response response = client.makeRequest(request);
diff --git a/src/main/java/com/twilio/constant/EnumConstants.java b/src/main/java/com/twilio/constant/EnumConstants.java
new file mode 100644
index 0000000000..7d2f70b590
--- /dev/null
+++ b/src/main/java/com/twilio/constant/EnumConstants.java
@@ -0,0 +1,16 @@
+package com.twilio.constant;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+public class EnumConstants {
+
+ @Getter
+ @RequiredArgsConstructor
+ public enum ContentType {
+ JSON("application/json"),
+ FORM_URLENCODED("application/x-www-form-urlencoded");
+
+ private final String value;
+ }
+}
diff --git a/src/main/java/com/twilio/converter/Converter.java b/src/main/java/com/twilio/converter/Converter.java
index 1cb6e8bfc8..9ee29e0e3d 100644
--- a/src/main/java/com/twilio/converter/Converter.java
+++ b/src/main/java/com/twilio/converter/Converter.java
@@ -18,7 +18,7 @@ public class Converter {
* @param map map to convert
* @return converted JSON string
*/
- public static String mapToJson(final Map map) {
+ public static String mapToJson(final Map map) {
try {
return MAPPER.writeValueAsString(map);
} catch (JsonProcessingException e) {
diff --git a/src/main/java/com/twilio/exception/ApiException.java b/src/main/java/com/twilio/exception/ApiException.java
index 7950db2abb..6b73fcaccf 100644
--- a/src/main/java/com/twilio/exception/ApiException.java
+++ b/src/main/java/com/twilio/exception/ApiException.java
@@ -30,6 +30,16 @@ public ApiException(final String message, final Throwable cause) {
this(message, null, null, null, cause);
}
+ /**
+ * Create a new API Exception.
+ *
+ * @param message exception message
+ * @param status status code
+ */
+ public ApiException(final String message, final Integer status) {
+ this(message, null, null, status, null);
+ }
+
/**
* Create a new API Exception.
*
diff --git a/src/main/java/com/twilio/http/NetworkHttpClient.java b/src/main/java/com/twilio/http/NetworkHttpClient.java
index ce0241b2da..8a2fac3da0 100644
--- a/src/main/java/com/twilio/http/NetworkHttpClient.java
+++ b/src/main/java/com/twilio/http/NetworkHttpClient.java
@@ -1,6 +1,7 @@
package com.twilio.http;
import com.twilio.Twilio;
+import com.twilio.constant.EnumConstants;
import com.twilio.exception.ApiException;
import java.io.IOException;
@@ -19,6 +20,8 @@
import org.apache.http.client.utils.HttpClientUtils;
import org.apache.http.config.SocketConfig;
import org.apache.http.entity.BufferedHttpEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicHeader;
@@ -123,13 +126,23 @@ public Response makeRequest(final Request request) {
}
if (method == HttpMethod.POST) {
- builder.addHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
-
- for (Map.Entry> entry : request.getPostParams().entrySet()) {
- for (String value : entry.getValue()) {
- builder.addParameter(entry.getKey(), value);
+ // TODO: It will be removed after one RC Release.
+ if (request.getContentType() == null) request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
+ if (EnumConstants.ContentType.JSON.getValue().equals(request.getContentType().getValue())) {
+ HttpEntity entity = new StringEntity(request.getBody(), ContentType.APPLICATION_JSON);
+ builder.setEntity(entity);
+ builder.addHeader(
+ HttpHeaders.CONTENT_TYPE, EnumConstants.ContentType.JSON.getValue());
+ } else {
+ builder.addHeader(
+ HttpHeaders.CONTENT_TYPE, EnumConstants.ContentType.FORM_URLENCODED.getValue());
+ for (Map.Entry> entry : request.getPostParams().entrySet()) {
+ for (String value : entry.getValue()) {
+ builder.addParameter(entry.getKey(), value);
+ }
}
}
+
}
builder.addHeader(HttpHeaders.USER_AGENT, HttpUtility.getUserAgentString(request.getUserAgentExtensions(), isCustomClient));
diff --git a/src/main/java/com/twilio/http/Request.java b/src/main/java/com/twilio/http/Request.java
index 8e187f22b4..12ecbaa15f 100644
--- a/src/main/java/com/twilio/http/Request.java
+++ b/src/main/java/com/twilio/http/Request.java
@@ -1,13 +1,9 @@
package com.twilio.http;
+import com.twilio.constant.EnumConstants;
import com.twilio.exception.ApiException;
import com.twilio.exception.InvalidRequestException;
-import java.time.ZonedDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.time.LocalDate;
-
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
@@ -15,6 +11,10 @@
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.*;
public class Request {
@@ -37,6 +37,10 @@ public class Request {
private List userAgentExtensions;
+ private EnumConstants.ContentType contentType;
+
+ private String body;
+
/**
* Create a new API request.
*
@@ -113,6 +117,22 @@ public List getUserAgentExtensions() {
return this.userAgentExtensions;
}
+ public EnumConstants.ContentType getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(EnumConstants.ContentType contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
/**
* Create auth string from username and password.
*
diff --git a/src/main/java/com/twilio/http/ValidationClient.java b/src/main/java/com/twilio/http/ValidationClient.java
index 521983787e..a1f760a970 100644
--- a/src/main/java/com/twilio/http/ValidationClient.java
+++ b/src/main/java/com/twilio/http/ValidationClient.java
@@ -1,13 +1,17 @@
package com.twilio.http;
import com.twilio.Twilio;
+import com.twilio.constant.EnumConstants;
import com.twilio.exception.ApiException;
+import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.config.SocketConfig;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicHeader;
@@ -104,11 +108,20 @@ public Response makeRequest(Request request) {
HttpMethod method = request.getMethod();
if (method == HttpMethod.POST) {
- builder.addHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
-
- for (Map.Entry> entry : request.getPostParams().entrySet()) {
- for (String value : entry.getValue()) {
- builder.addParameter(entry.getKey(), value);
+ // TODO: It will be removed after one RC Release.
+ if (request.getContentType() == null) request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
+ if (EnumConstants.ContentType.JSON.getValue().equals(request.getContentType().getValue())) {
+ HttpEntity entity = new StringEntity(request.getBody(), ContentType.APPLICATION_JSON);
+ builder.setEntity(entity);
+ builder.addHeader(
+ HttpHeaders.CONTENT_TYPE, EnumConstants.ContentType.JSON.getValue());
+ } else {
+ builder.addHeader(
+ HttpHeaders.CONTENT_TYPE, EnumConstants.ContentType.FORM_URLENCODED.getValue());
+ for (Map.Entry> entry : request.getPostParams().entrySet()) {
+ for (String value : entry.getValue()) {
+ builder.addParameter(entry.getKey(), value);
+ }
}
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotion.java b/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotion.java
index a9af0bb82d..b351cf2f6c 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotion.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotion.java
@@ -23,37 +23,36 @@
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
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 AuthTokenPromotion extends Resource {
+
private static final long serialVersionUID = 77507843877589L;
- public static AuthTokenPromotionUpdater updater(){
+ public static AuthTokenPromotionUpdater updater() {
return new AuthTokenPromotionUpdater();
}
/**
- * Converts a JSON String into a AuthTokenPromotion object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return AuthTokenPromotion object represented by the provided JSON
- */
- public static AuthTokenPromotion fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a AuthTokenPromotion object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return AuthTokenPromotion object represented by the provided JSON
+ */
+ public static AuthTokenPromotion fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, AuthTokenPromotion.class);
@@ -65,14 +64,17 @@ public static AuthTokenPromotion fromJson(final String json, final ObjectMapper
}
/**
- * Converts a JSON InputStream into a AuthTokenPromotion object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return AuthTokenPromotion object represented by the provided JSON
- */
- public static AuthTokenPromotion fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a AuthTokenPromotion object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return AuthTokenPromotion object represented by the provided JSON
+ */
+ public static AuthTokenPromotion fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, AuthTokenPromotion.class);
@@ -91,20 +93,11 @@ public static AuthTokenPromotion fromJson(final InputStream json, final ObjectMa
@JsonCreator
private AuthTokenPromotion(
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("auth_token")
- final String authToken,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("url")
- final URI url
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("auth_token") final String authToken,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("url") final URI url
) {
this.accountSid = accountSid;
this.authToken = authToken;
@@ -113,25 +106,29 @@ private AuthTokenPromotion(
this.url = url;
}
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getAuthToken() {
- return this.authToken;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final URI getUrl() {
- return this.url;
- }
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getAuthToken() {
+ return this.authToken;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final URI getUrl() {
+ return this.url;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -141,13 +138,23 @@ public boolean equals(final Object o) {
AuthTokenPromotion other = (AuthTokenPromotion) o;
- return Objects.equals(accountSid, other.accountSid) && Objects.equals(authToken, other.authToken) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(url, other.url) ;
+ return (
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(authToken, other.authToken) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(url, other.url)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(accountSid, authToken, dateCreated, dateUpdated, url);
+ return Objects.hash(
+ accountSid,
+ authToken,
+ dateCreated,
+ dateUpdated,
+ url
+ );
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotionUpdater.java b/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotionUpdater.java
index ae06380f76..6df4d8353e 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotionUpdater.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotionUpdater.java
@@ -24,20 +24,14 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AuthTokenPromotionUpdater extends Updater {
-
-
-public class AuthTokenPromotionUpdater extends Updater{
-
- public AuthTokenPromotionUpdater(){
- }
-
+ public AuthTokenPromotionUpdater() {}
@Override
- public AuthTokenPromotion update(final TwilioRestClient client){
+ public AuthTokenPromotion update(final TwilioRestClient client) {
String path = "/v1/AuthTokens/Promote";
-
Request request = new Request(
HttpMethod.POST,
Domains.ACCOUNTS.toString(),
@@ -45,15 +39,26 @@ public AuthTokenPromotion update(final TwilioRestClient client){
);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("AuthTokenPromotion update failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "AuthTokenPromotion update failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return AuthTokenPromotion.fromJson(response.getStream(), client.getObjectMapper());
+ return AuthTokenPromotion.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/Safelist.java b/src/main/java/com/twilio/rest/accounts/v1/Safelist.java
new file mode 100644
index 0000000000..8eb668198c
--- /dev/null
+++ b/src/main/java/com/twilio/rest/accounts/v1/Safelist.java
@@ -0,0 +1,135 @@
+/*
+ * This code was generated by
+ * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
+ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
+ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
+ *
+ * Twilio - Accounts
+ * 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.accounts.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.exception.ApiConnectionException;
+import com.twilio.exception.ApiException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Objects;
+import lombok.ToString;
+import lombok.ToString;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@ToString
+public class Safelist extends Resource {
+
+ private static final long serialVersionUID = 179274993739L;
+
+ public static SafelistCreator creator(final String phoneNumber) {
+ return new SafelistCreator(phoneNumber);
+ }
+
+ public static SafelistDeleter deleter() {
+ return new SafelistDeleter();
+ }
+
+ public static SafelistFetcher fetcher() {
+ return new SafelistFetcher();
+ }
+
+ /**
+ * Converts a JSON String into a Safelist object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Safelist object represented by the provided JSON
+ */
+ public static Safelist fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
+ // Convert all checked exceptions to Runtime
+ try {
+ return objectMapper.readValue(json, Safelist.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 Safelist object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Safelist object represented by the provided JSON
+ */
+ public static Safelist fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
+ // Convert all checked exceptions to Runtime
+ try {
+ return objectMapper.readValue(json, Safelist.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 phoneNumber;
+
+ @JsonCreator
+ private Safelist(
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("phone_number") final String phoneNumber
+ ) {
+ this.sid = sid;
+ this.phoneNumber = phoneNumber;
+ }
+
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final String getPhoneNumber() {
+ return this.phoneNumber;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Safelist other = (Safelist) o;
+
+ return (
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(phoneNumber, other.phoneNumber)
+ );
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(sid, phoneNumber);
+ }
+}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/SafelistCreator.java b/src/main/java/com/twilio/rest/accounts/v1/SafelistCreator.java
new file mode 100644
index 0000000000..83dfbcb4fe
--- /dev/null
+++ b/src/main/java/com/twilio/rest/accounts/v1/SafelistCreator.java
@@ -0,0 +1,88 @@
+/*
+ * This code was generated by
+ * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
+ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
+ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
+ *
+ * Twilio - Accounts
+ * 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.accounts.v1;
+
+import com.twilio.base.Creator;
+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 SafelistCreator extends Creator {
+
+ private String phoneNumber;
+
+ public SafelistCreator(final String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ public SafelistCreator setPhoneNumber(final String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ return this;
+ }
+
+ @Override
+ public Safelist create(final TwilioRestClient client) {
+ String path = "/v1/SafeList/Numbers";
+
+ path =
+ path.replace(
+ "{" + "PhoneNumber" + "}",
+ this.phoneNumber.toString()
+ );
+
+ Request request = new Request(
+ HttpMethod.POST,
+ Domains.ACCOUNTS.toString(),
+ path
+ );
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
+ addPostParams(request);
+ Response response = client.request(request);
+ if (response == null) {
+ throw new ApiConnectionException(
+ "Safelist creation 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 Safelist.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
+ }
+
+ private void addPostParams(final Request request) {
+ if (phoneNumber != null) {
+ request.addPostParam("PhoneNumber", phoneNumber);
+ }
+ }
+}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/SafelistDeleter.java b/src/main/java/com/twilio/rest/accounts/v1/SafelistDeleter.java
new file mode 100644
index 0000000000..885547a0d0
--- /dev/null
+++ b/src/main/java/com/twilio/rest/accounts/v1/SafelistDeleter.java
@@ -0,0 +1,75 @@
+/*
+ * This code was generated by
+ * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
+ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
+ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
+ *
+ * Twilio - Accounts
+ * 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.accounts.v1;
+
+import com.twilio.base.Deleter;
+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 SafelistDeleter extends Deleter {
+
+ private String phoneNumber;
+
+ public SafelistDeleter() {}
+
+ public SafelistDeleter setPhoneNumber(final String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ return this;
+ }
+
+ @Override
+ public boolean delete(final TwilioRestClient client) {
+ String path = "/v1/SafeList/Numbers";
+
+ Request request = new Request(
+ HttpMethod.DELETE,
+ Domains.ACCOUNTS.toString(),
+ path
+ );
+ addQueryParams(request);
+ Response response = client.request(request);
+
+ if (response == null) {
+ throw new ApiConnectionException(
+ "Safelist delete 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 response.getStatusCode() == 204;
+ }
+
+ private void addQueryParams(final Request request) {
+ if (phoneNumber != null) {
+ request.addQueryParam("PhoneNumber", phoneNumber);
+ }
+ }
+}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/SafelistFetcher.java b/src/main/java/com/twilio/rest/accounts/v1/SafelistFetcher.java
new file mode 100644
index 0000000000..8e5991de19
--- /dev/null
+++ b/src/main/java/com/twilio/rest/accounts/v1/SafelistFetcher.java
@@ -0,0 +1,79 @@
+/*
+ * This code was generated by
+ * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
+ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
+ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
+ *
+ * Twilio - Accounts
+ * 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.accounts.v1;
+
+import com.twilio.base.Fetcher;
+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 SafelistFetcher extends Fetcher {
+
+ private String phoneNumber;
+
+ public SafelistFetcher() {}
+
+ public SafelistFetcher setPhoneNumber(final String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ return this;
+ }
+
+ @Override
+ public Safelist fetch(final TwilioRestClient client) {
+ String path = "/v1/SafeList/Numbers";
+
+ Request request = new Request(
+ HttpMethod.GET,
+ Domains.ACCOUNTS.toString(),
+ path
+ );
+ addQueryParams(request);
+ Response response = client.request(request);
+
+ if (response == null) {
+ throw new ApiConnectionException(
+ "Safelist fetch 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 Safelist.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
+ }
+
+ private void addQueryParams(final Request request) {
+ if (phoneNumber != null) {
+ request.addQueryParam("PhoneNumber", phoneNumber);
+ }
+ }
+}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthToken.java b/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthToken.java
index b8df84c8db..0d6a66035f 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthToken.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthToken.java
@@ -23,41 +23,40 @@
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
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 SecondaryAuthToken extends Resource {
+
private static final long serialVersionUID = 191219471550314L;
- public static SecondaryAuthTokenCreator creator(){
+ public static SecondaryAuthTokenCreator creator() {
return new SecondaryAuthTokenCreator();
}
- public static SecondaryAuthTokenDeleter deleter(){
+ public static SecondaryAuthTokenDeleter deleter() {
return new SecondaryAuthTokenDeleter();
}
/**
- * Converts a JSON String into a SecondaryAuthToken object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return SecondaryAuthToken object represented by the provided JSON
- */
- public static SecondaryAuthToken fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a SecondaryAuthToken object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return SecondaryAuthToken object represented by the provided JSON
+ */
+ public static SecondaryAuthToken fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, SecondaryAuthToken.class);
@@ -69,14 +68,17 @@ public static SecondaryAuthToken fromJson(final String json, final ObjectMapper
}
/**
- * Converts a JSON InputStream into a SecondaryAuthToken object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return SecondaryAuthToken object represented by the provided JSON
- */
- public static SecondaryAuthToken fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a SecondaryAuthToken object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return SecondaryAuthToken object represented by the provided JSON
+ */
+ public static SecondaryAuthToken fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, SecondaryAuthToken.class);
@@ -95,20 +97,11 @@ public static SecondaryAuthToken fromJson(final InputStream json, final ObjectMa
@JsonCreator
private SecondaryAuthToken(
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("secondary_auth_token")
- final String secondaryAuthToken,
-
- @JsonProperty("url")
- final URI url
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("secondary_auth_token") final String secondaryAuthToken,
+ @JsonProperty("url") final URI url
) {
this.accountSid = accountSid;
this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated);
@@ -117,25 +110,29 @@ private SecondaryAuthToken(
this.url = url;
}
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final String getSecondaryAuthToken() {
- return this.secondaryAuthToken;
- }
- public final URI getUrl() {
- return this.url;
- }
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final String getSecondaryAuthToken() {
+ return this.secondaryAuthToken;
+ }
+
+ public final URI getUrl() {
+ return this.url;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -145,13 +142,23 @@ public boolean equals(final Object o) {
SecondaryAuthToken other = (SecondaryAuthToken) o;
- return Objects.equals(accountSid, other.accountSid) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(secondaryAuthToken, other.secondaryAuthToken) && Objects.equals(url, other.url) ;
+ return (
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(secondaryAuthToken, other.secondaryAuthToken) &&
+ Objects.equals(url, other.url)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(accountSid, dateCreated, dateUpdated, secondaryAuthToken, url);
+ return Objects.hash(
+ accountSid,
+ dateCreated,
+ dateUpdated,
+ secondaryAuthToken,
+ url
+ );
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenCreator.java b/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenCreator.java
index aff21d5f0c..b1f63c4a6d 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenCreator.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenCreator.java
@@ -24,20 +24,14 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class SecondaryAuthTokenCreator extends Creator {
-
-
-public class SecondaryAuthTokenCreator extends Creator{
-
- public SecondaryAuthTokenCreator() {
- }
-
+ public SecondaryAuthTokenCreator() {}
@Override
- public SecondaryAuthToken create(final TwilioRestClient client){
+ public SecondaryAuthToken create(final TwilioRestClient client) {
String path = "/v1/AuthTokens/Secondary";
-
Request request = new Request(
HttpMethod.POST,
Domains.ACCOUNTS.toString(),
@@ -45,15 +39,26 @@ public SecondaryAuthToken create(final TwilioRestClient client){
);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("SecondaryAuthToken creation failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "SecondaryAuthToken creation failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return SecondaryAuthToken.fromJson(response.getStream(), client.getObjectMapper());
+ return SecondaryAuthToken.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenDeleter.java b/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenDeleter.java
index d32ab49b3a..edce3765d7 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenDeleter.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/SecondaryAuthTokenDeleter.java
@@ -24,19 +24,14 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
public class SecondaryAuthTokenDeleter extends Deleter {
- public SecondaryAuthTokenDeleter(){
- }
-
+ public SecondaryAuthTokenDeleter() {}
@Override
public boolean delete(final TwilioRestClient client) {
String path = "/v1/AuthTokens/Secondary";
-
Request request = new Request(
HttpMethod.DELETE,
Domains.ACCOUNTS.toString(),
@@ -45,11 +40,19 @@ public boolean delete(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("SecondaryAuthToken delete failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "SecondaryAuthToken delete failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/Aws.java b/src/main/java/com/twilio/rest/accounts/v1/credential/Aws.java
index 726ede3466..7f6af0e434 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/Aws.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/Aws.java
@@ -23,53 +23,52 @@
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
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 Aws extends Resource {
+
private static final long serialVersionUID = 255841368009036L;
- public static AwsCreator creator(final String credentials){
+ public static AwsCreator creator(final String credentials) {
return new AwsCreator(credentials);
}
- public static AwsDeleter deleter(final String pathSid){
+ public static AwsDeleter deleter(final String pathSid) {
return new AwsDeleter(pathSid);
}
- public static AwsFetcher fetcher(final String pathSid){
+ public static AwsFetcher fetcher(final String pathSid) {
return new AwsFetcher(pathSid);
}
- public static AwsReader reader(){
+ public static AwsReader reader() {
return new AwsReader();
}
- public static AwsUpdater updater(final String pathSid){
+ public static AwsUpdater updater(final String pathSid) {
return new AwsUpdater(pathSid);
}
/**
- * Converts a JSON String into a Aws object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return Aws object represented by the provided JSON
- */
- public static Aws fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a Aws object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Aws object represented by the provided JSON
+ */
+ public static Aws fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Aws.class);
@@ -81,14 +80,17 @@ public static Aws fromJson(final String json, final ObjectMapper objectMapper) {
}
/**
- * Converts a JSON InputStream into a Aws object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return Aws object represented by the provided JSON
- */
- public static Aws fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a Aws object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Aws object represented by the provided JSON
+ */
+ public static Aws fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Aws.class);
@@ -108,23 +110,12 @@ public static Aws fromJson(final InputStream json, final ObjectMapper objectMapp
@JsonCreator
private Aws(
- @JsonProperty("sid")
- final String sid,
-
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("friendly_name")
- final String friendlyName,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("url")
- final URI url
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("friendly_name") final String friendlyName,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("url") final URI url
) {
this.sid = sid;
this.accountSid = accountSid;
@@ -134,28 +125,33 @@ private Aws(
this.url = url;
}
- public final String getSid() {
- return this.sid;
- }
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getFriendlyName() {
- return this.friendlyName;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final URI getUrl() {
- return this.url;
- }
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getFriendlyName() {
+ return this.friendlyName;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final URI getUrl() {
+ return this.url;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -165,13 +161,25 @@ public boolean equals(final Object o) {
Aws other = (Aws) o;
- return Objects.equals(sid, other.sid) && Objects.equals(accountSid, other.accountSid) && Objects.equals(friendlyName, other.friendlyName) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(url, other.url) ;
+ return (
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(friendlyName, other.friendlyName) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(url, other.url)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(sid, accountSid, friendlyName, dateCreated, dateUpdated, url);
+ return Objects.hash(
+ sid,
+ accountSid,
+ friendlyName,
+ dateCreated,
+ dateUpdated,
+ url
+ );
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsCreator.java b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsCreator.java
index 8a8c4ddcff..cb16ac166d 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsCreator.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsCreator.java
@@ -15,6 +15,7 @@
package com.twilio.rest.accounts.v1.credential;
import com.twilio.base.Creator;
+import com.twilio.constant.EnumConstants;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
@@ -24,10 +25,8 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AwsCreator extends Creator {
-
-
-public class AwsCreator extends Creator{
private String credentials;
private String friendlyName;
private String accountSid;
@@ -36,56 +35,69 @@ public AwsCreator(final String credentials) {
this.credentials = credentials;
}
- public AwsCreator setCredentials(final String credentials){
+ public AwsCreator setCredentials(final String credentials) {
this.credentials = credentials;
return this;
}
- public AwsCreator setFriendlyName(final String friendlyName){
+
+ public AwsCreator setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public AwsCreator setAccountSid(final String accountSid){
+
+ public AwsCreator setAccountSid(final String accountSid) {
this.accountSid = accountSid;
return this;
}
@Override
- public Aws create(final TwilioRestClient client){
+ public Aws create(final TwilioRestClient client) {
String path = "/v1/Credentials/AWS";
- path = path.replace("{"+"Credentials"+"}", this.credentials.toString());
+ path =
+ path.replace(
+ "{" + "Credentials" + "}",
+ this.credentials.toString()
+ );
Request request = new Request(
HttpMethod.POST,
Domains.ACCOUNTS.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Aws creation failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Aws creation failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Aws.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (credentials != null) {
request.addPostParam("Credentials", credentials);
-
}
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
if (accountSid != null) {
request.addPostParam("AccountSid", accountSid);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsDeleter.java b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsDeleter.java
index a60ea69a34..1750666945 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsDeleter.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsDeleter.java
@@ -24,21 +24,19 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
public class AwsDeleter extends Deleter {
+
private String pathSid;
- public AwsDeleter(final String pathSid){
+ public AwsDeleter(final String pathSid) {
this.pathSid = pathSid;
}
-
@Override
public boolean delete(final TwilioRestClient client) {
String path = "/v1/Credentials/AWS/{Sid}";
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.DELETE,
@@ -48,11 +46,19 @@ public boolean delete(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Aws delete failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Aws delete failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsFetcher.java b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsFetcher.java
index ffbf475303..195ce6ba08 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsFetcher.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsFetcher.java
@@ -24,22 +24,19 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class AwsFetcher extends Fetcher {
+
private String pathSid;
- public AwsFetcher(final String pathSid){
+ public AwsFetcher(final String pathSid) {
this.pathSid = pathSid;
}
-
@Override
public Aws fetch(final TwilioRestClient client) {
String path = "/v1/Credentials/AWS/{Sid}";
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.GET,
@@ -49,11 +46,19 @@ public Aws fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Aws fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Aws fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsReader.java b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsReader.java
index 668713da21..db5a42b656 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsReader.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.accounts.v1.credential;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.exception.ApiConnectionException;
@@ -24,17 +25,14 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
-
-
public class AwsReader extends Reader {
+
private Integer pageSize;
- public AwsReader(){
- }
+ public AwsReader() {}
- public AwsReader setPageSize(final Integer pageSize){
+ public AwsReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -57,15 +55,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Aws read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Aws read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -79,7 +88,10 @@ private Page pageForRequest(final TwilioRestClient client, final Request re
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.ACCOUNTS.toString())
@@ -87,9 +99,11 @@ public Page previousPage(final Page page, final TwilioRestClient clien
return pageForRequest(client, request);
}
-
@Override
- public Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.ACCOUNTS.toString())
@@ -98,21 +112,21 @@ public Page nextPage(final Page page, final TwilioRestClient client) {
}
@Override
- public Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsUpdater.java b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsUpdater.java
index 24bd7d340f..73a98ba85a 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/AwsUpdater.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/AwsUpdater.java
@@ -15,6 +15,7 @@
package com.twilio.rest.accounts.v1.credential;
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;
@@ -24,51 +25,58 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AwsUpdater extends Updater {
-
-
-public class AwsUpdater extends Updater{
private String pathSid;
private String friendlyName;
- public AwsUpdater(final String pathSid){
+ public AwsUpdater(final String pathSid) {
this.pathSid = pathSid;
}
- public AwsUpdater setFriendlyName(final String friendlyName){
+ public AwsUpdater setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
@Override
- public Aws update(final TwilioRestClient client){
+ public Aws update(final TwilioRestClient client) {
String path = "/v1/Credentials/AWS/{Sid}";
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.POST,
Domains.ACCOUNTS.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Aws update failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Aws update failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Aws.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKey.java b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKey.java
index 906893efa5..f77b6851d1 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKey.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKey.java
@@ -23,53 +23,52 @@
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
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 PublicKey extends Resource {
+
private static final long serialVersionUID = 255841368009036L;
- public static PublicKeyCreator creator(final String publicKey){
+ public static PublicKeyCreator creator(final String publicKey) {
return new PublicKeyCreator(publicKey);
}
- public static PublicKeyDeleter deleter(final String pathSid){
+ public static PublicKeyDeleter deleter(final String pathSid) {
return new PublicKeyDeleter(pathSid);
}
- public static PublicKeyFetcher fetcher(final String pathSid){
+ public static PublicKeyFetcher fetcher(final String pathSid) {
return new PublicKeyFetcher(pathSid);
}
- public static PublicKeyReader reader(){
+ public static PublicKeyReader reader() {
return new PublicKeyReader();
}
- public static PublicKeyUpdater updater(final String pathSid){
+ public static PublicKeyUpdater updater(final String pathSid) {
return new PublicKeyUpdater(pathSid);
}
/**
- * Converts a JSON String into a PublicKey object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return PublicKey object represented by the provided JSON
- */
- public static PublicKey fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a PublicKey object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return PublicKey object represented by the provided JSON
+ */
+ public static PublicKey fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, PublicKey.class);
@@ -81,14 +80,17 @@ public static PublicKey fromJson(final String json, final ObjectMapper objectMap
}
/**
- * Converts a JSON InputStream into a PublicKey object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return PublicKey object represented by the provided JSON
- */
- public static PublicKey fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a PublicKey object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return PublicKey object represented by the provided JSON
+ */
+ public static PublicKey fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, PublicKey.class);
@@ -108,23 +110,12 @@ public static PublicKey fromJson(final InputStream json, final ObjectMapper obje
@JsonCreator
private PublicKey(
- @JsonProperty("sid")
- final String sid,
-
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("friendly_name")
- final String friendlyName,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("url")
- final URI url
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("friendly_name") final String friendlyName,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("url") final URI url
) {
this.sid = sid;
this.accountSid = accountSid;
@@ -134,28 +125,33 @@ private PublicKey(
this.url = url;
}
- public final String getSid() {
- return this.sid;
- }
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getFriendlyName() {
- return this.friendlyName;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final URI getUrl() {
- return this.url;
- }
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getFriendlyName() {
+ return this.friendlyName;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final URI getUrl() {
+ return this.url;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -165,13 +161,25 @@ public boolean equals(final Object o) {
PublicKey other = (PublicKey) o;
- return Objects.equals(sid, other.sid) && Objects.equals(accountSid, other.accountSid) && Objects.equals(friendlyName, other.friendlyName) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(url, other.url) ;
+ return (
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(friendlyName, other.friendlyName) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(url, other.url)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(sid, accountSid, friendlyName, dateCreated, dateUpdated, url);
+ return Objects.hash(
+ sid,
+ accountSid,
+ friendlyName,
+ dateCreated,
+ dateUpdated,
+ url
+ );
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyCreator.java b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyCreator.java
index 0797698fcd..faded3ed3e 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyCreator.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyCreator.java
@@ -15,6 +15,7 @@
package com.twilio.rest.accounts.v1.credential;
import com.twilio.base.Creator;
+import com.twilio.constant.EnumConstants;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
@@ -24,10 +25,8 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class PublicKeyCreator extends Creator {
-
-
-public class PublicKeyCreator extends Creator{
private String publicKey;
private String friendlyName;
private String accountSid;
@@ -36,56 +35,68 @@ public PublicKeyCreator(final String publicKey) {
this.publicKey = publicKey;
}
- public PublicKeyCreator setPublicKey(final String publicKey){
+ public PublicKeyCreator setPublicKey(final String publicKey) {
this.publicKey = publicKey;
return this;
}
- public PublicKeyCreator setFriendlyName(final String friendlyName){
+
+ public PublicKeyCreator setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public PublicKeyCreator setAccountSid(final String accountSid){
+
+ public PublicKeyCreator setAccountSid(final String accountSid) {
this.accountSid = accountSid;
return this;
}
@Override
- public PublicKey create(final TwilioRestClient client){
+ public PublicKey create(final TwilioRestClient client) {
String path = "/v1/Credentials/PublicKeys";
- path = path.replace("{"+"PublicKey"+"}", this.publicKey.toString());
+ path = path.replace("{" + "PublicKey" + "}", this.publicKey.toString());
Request request = new Request(
HttpMethod.POST,
Domains.ACCOUNTS.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("PublicKey creation failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "PublicKey creation failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return PublicKey.fromJson(response.getStream(), client.getObjectMapper());
+ return PublicKey.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
+
private void addPostParams(final Request request) {
if (publicKey != null) {
request.addPostParam("PublicKey", publicKey);
-
}
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
if (accountSid != null) {
request.addPostParam("AccountSid", accountSid);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyDeleter.java b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyDeleter.java
index c09237ae3e..4fc9aea983 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyDeleter.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyDeleter.java
@@ -24,21 +24,19 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
public class PublicKeyDeleter extends Deleter {
+
private String pathSid;
- public PublicKeyDeleter(final String pathSid){
+ public PublicKeyDeleter(final String pathSid) {
this.pathSid = pathSid;
}
-
@Override
public boolean delete(final TwilioRestClient client) {
String path = "/v1/Credentials/PublicKeys/{Sid}";
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.DELETE,
@@ -48,11 +46,19 @@ public boolean delete(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("PublicKey delete failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "PublicKey delete failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyFetcher.java b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyFetcher.java
index 0e0e05526f..9367463fac 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyFetcher.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyFetcher.java
@@ -24,22 +24,19 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class PublicKeyFetcher extends Fetcher {
+
private String pathSid;
- public PublicKeyFetcher(final String pathSid){
+ public PublicKeyFetcher(final String pathSid) {
this.pathSid = pathSid;
}
-
@Override
public PublicKey fetch(final TwilioRestClient client) {
String path = "/v1/Credentials/PublicKeys/{Sid}";
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.GET,
@@ -49,15 +46,26 @@ public PublicKey fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("PublicKey fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "PublicKey fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return PublicKey.fromJson(response.getStream(), client.getObjectMapper());
+ return PublicKey.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyReader.java b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyReader.java
index 9f0da2bc2d..b933bacc2e 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyReader.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.accounts.v1.credential;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.exception.ApiConnectionException;
@@ -24,17 +25,14 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
-
-
public class PublicKeyReader extends Reader {
+
private Integer pageSize;
- public PublicKeyReader(){
- }
+ public PublicKeyReader() {}
- public PublicKeyReader setPageSize(final Integer pageSize){
+ public PublicKeyReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -57,15 +55,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("PublicKey read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "PublicKey read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -79,7 +88,10 @@ private Page pageForRequest(final TwilioRestClient client, final Requ
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.ACCOUNTS.toString())
@@ -87,9 +99,11 @@ public Page previousPage(final Page page, final TwilioRest
return pageForRequest(client, request);
}
-
@Override
- public Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.ACCOUNTS.toString())
@@ -98,21 +112,21 @@ public Page nextPage(final Page page, final TwilioRestClie
}
@Override
- public Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyUpdater.java b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyUpdater.java
index 14488f8bcf..4a49e782d3 100644
--- a/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyUpdater.java
+++ b/src/main/java/com/twilio/rest/accounts/v1/credential/PublicKeyUpdater.java
@@ -15,6 +15,7 @@
package com.twilio.rest.accounts.v1.credential;
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;
@@ -24,51 +25,61 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class PublicKeyUpdater extends Updater {
-
-
-public class PublicKeyUpdater extends Updater{
private String pathSid;
private String friendlyName;
- public PublicKeyUpdater(final String pathSid){
+ public PublicKeyUpdater(final String pathSid) {
this.pathSid = pathSid;
}
- public PublicKeyUpdater setFriendlyName(final String friendlyName){
+ public PublicKeyUpdater setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
@Override
- public PublicKey update(final TwilioRestClient client){
+ public PublicKey update(final TwilioRestClient client) {
String path = "/v1/Credentials/PublicKeys/{Sid}";
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.POST,
Domains.ACCOUNTS.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("PublicKey update failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "PublicKey update failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return PublicKey.fromJson(response.getStream(), client.getObjectMapper());
+ return PublicKey.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
+
private void addPostParams(final Request request) {
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/Account.java b/src/main/java/com/twilio/rest/api/v2010/Account.java
index 0a09d41889..7ab47a5b18 100644
--- a/src/main/java/com/twilio/rest/api/v2010/Account.java
+++ b/src/main/java/com/twilio/rest/api/v2010/Account.java
@@ -24,56 +24,57 @@
import com.twilio.converter.DateConverter;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
import java.io.IOException;
import java.io.InputStream;
import java.time.ZonedDateTime;
-
import java.util.Map;
-import java.util.Objects;
-
-
import java.util.Map;
+import java.util.Objects;
+import lombok.ToString;
+import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class Account extends Resource {
+
private static final long serialVersionUID = 224328589339754L;
- public static AccountCreator creator(){
+ public static AccountCreator creator() {
return new AccountCreator();
}
- public static AccountFetcher fetcher(){
+ public static AccountFetcher fetcher() {
return new AccountFetcher();
}
- public static AccountFetcher fetcher(final String pathSid){
+
+ public static AccountFetcher fetcher(final String pathSid) {
return new AccountFetcher(pathSid);
}
- public static AccountReader reader(){
+ public static AccountReader reader() {
return new AccountReader();
}
- public static AccountUpdater updater(){
+ public static AccountUpdater updater() {
return new AccountUpdater();
}
- public static AccountUpdater updater(final String pathSid){
+
+ public static AccountUpdater updater(final String pathSid) {
return new AccountUpdater(pathSid);
}
/**
- * Converts a JSON String into a Account object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return Account object represented by the provided JSON
- */
- public static Account fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a Account object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Account object represented by the provided JSON
+ */
+ public static Account fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Account.class);
@@ -85,14 +86,17 @@ public static Account fromJson(final String json, final ObjectMapper objectMappe
}
/**
- * Converts a JSON InputStream into a Account object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return Account object represented by the provided JSON
- */
- public static Account fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a Account object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Account object represented by the provided JSON
+ */
+ public static Account fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Account.class);
@@ -102,45 +106,6 @@ public static Account fromJson(final InputStream json, final ObjectMapper object
throw new ApiConnectionException(e.getMessage(), e);
}
}
- public enum Status {
- ACTIVE("active"),
- SUSPENDED("suspended"),
- CLOSED("closed");
-
- private final String value;
-
- private Status(final String value) {
- this.value = value;
- }
-
- public String toString() {
- return value;
- }
-
- @JsonCreator
- public static Status forValue(final String value) {
- return Promoter.enumFromString(value, Status.values());
- }
- }
- public enum Type {
- TRIAL("Trial"),
- FULL("Full");
-
- private final String value;
-
- private Type(final String value) {
- this.value = value;
- }
-
- public String toString() {
- return value;
- }
-
- @JsonCreator
- public static Type forValue(final String value) {
- return Promoter.enumFromString(value, Type.values());
- }
- }
private final String authToken;
private final ZonedDateTime dateCreated;
@@ -155,35 +120,19 @@ public static Type forValue(final String value) {
@JsonCreator
private Account(
- @JsonProperty("auth_token")
- final String authToken,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("friendly_name")
- final String friendlyName,
-
- @JsonProperty("owner_account_sid")
- final String ownerAccountSid,
-
- @JsonProperty("sid")
- final String sid,
-
- @JsonProperty("status")
- final Account.Status status,
-
- @JsonProperty("subresource_uris")
- final Map subresourceUris,
-
- @JsonProperty("type")
- final Account.Type type,
-
- @JsonProperty("uri")
- final String uri
+ @JsonProperty("auth_token") final String authToken,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("friendly_name") final String friendlyName,
+ @JsonProperty("owner_account_sid") final String ownerAccountSid,
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("status") final Account.Status status,
+ @JsonProperty("subresource_uris") final Map<
+ String,
+ String
+ > subresourceUris,
+ @JsonProperty("type") final Account.Type type,
+ @JsonProperty("uri") final String uri
) {
this.authToken = authToken;
this.dateCreated = DateConverter.rfc2822DateTimeFromString(dateCreated);
@@ -197,40 +146,49 @@ private Account(
this.uri = uri;
}
- public final String getAuthToken() {
- return this.authToken;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final String getFriendlyName() {
- return this.friendlyName;
- }
- public final String getOwnerAccountSid() {
- return this.ownerAccountSid;
- }
- public final String getSid() {
- return this.sid;
- }
- public final Account.Status getStatus() {
- return this.status;
- }
- public final Map getSubresourceUris() {
- return this.subresourceUris;
- }
- public final Account.Type getType() {
- return this.type;
- }
- public final String getUri() {
- return this.uri;
- }
+ public final String getAuthToken() {
+ return this.authToken;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final String getFriendlyName() {
+ return this.friendlyName;
+ }
+
+ public final String getOwnerAccountSid() {
+ return this.ownerAccountSid;
+ }
+
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final Account.Status getStatus() {
+ return this.status;
+ }
+
+ public final Map getSubresourceUris() {
+ return this.subresourceUris;
+ }
+
+ public final Account.Type getType() {
+ return this.type;
+ }
+
+ public final String getUri() {
+ return this.uri;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -240,13 +198,74 @@ public boolean equals(final Object o) {
Account other = (Account) o;
- return Objects.equals(authToken, other.authToken) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(friendlyName, other.friendlyName) && Objects.equals(ownerAccountSid, other.ownerAccountSid) && Objects.equals(sid, other.sid) && Objects.equals(status, other.status) && Objects.equals(subresourceUris, other.subresourceUris) && Objects.equals(type, other.type) && Objects.equals(uri, other.uri) ;
+ return (
+ Objects.equals(authToken, other.authToken) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(friendlyName, other.friendlyName) &&
+ Objects.equals(ownerAccountSid, other.ownerAccountSid) &&
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(status, other.status) &&
+ Objects.equals(subresourceUris, other.subresourceUris) &&
+ Objects.equals(type, other.type) &&
+ Objects.equals(uri, other.uri)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(authToken, dateCreated, dateUpdated, friendlyName, ownerAccountSid, sid, status, subresourceUris, type, uri);
+ return Objects.hash(
+ authToken,
+ dateCreated,
+ dateUpdated,
+ friendlyName,
+ ownerAccountSid,
+ sid,
+ status,
+ subresourceUris,
+ type,
+ uri
+ );
}
-}
+ public enum Status {
+ ACTIVE("active"),
+ SUSPENDED("suspended"),
+ CLOSED("closed");
+
+ private final String value;
+ private Status(final String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return value;
+ }
+
+ @JsonCreator
+ public static Status forValue(final String value) {
+ return Promoter.enumFromString(value, Status.values());
+ }
+ }
+
+ public enum Type {
+ TRIAL("Trial"),
+ FULL("Full");
+
+ private final String value;
+
+ private Type(final String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return value;
+ }
+
+ @JsonCreator
+ public static Type forValue(final String value) {
+ return Promoter.enumFromString(value, Type.values());
+ }
+ }
+}
diff --git a/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java b/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java
index 9b04a4c318..d98a43a6c5 100644
--- a/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java
+++ b/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010;
import com.twilio.base.Creator;
+import com.twilio.constant.EnumConstants;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
@@ -24,48 +25,53 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AccountCreator extends Creator {
-
-
-public class AccountCreator extends Creator{
private String friendlyName;
- public AccountCreator() {
- }
+ public AccountCreator() {}
- public AccountCreator setFriendlyName(final String friendlyName){
+ public AccountCreator setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
@Override
- public Account create(final TwilioRestClient client){
+ public Account create(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts.json";
-
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Account creation failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Account creation failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Account.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java b/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java
index 87013b2c18..265990bd28 100644
--- a/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java
@@ -24,25 +24,23 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class AccountFetcher extends Fetcher {
+
private String pathSid;
- public AccountFetcher(){
- }
- public AccountFetcher(final String pathSid){
+ public AccountFetcher() {}
+
+ public AccountFetcher(final String pathSid) {
this.pathSid = pathSid;
}
-
@Override
public Account fetch(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{Sid}.json";
- this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid;
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathSid =
+ this.pathSid == null ? client.getAccountSid() : this.pathSid;
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.GET,
@@ -52,11 +50,19 @@ public Account fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Account fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Account fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/AccountReader.java b/src/main/java/com/twilio/rest/api/v2010/AccountReader.java
index 4577d0a338..becb950d19 100644
--- a/src/main/java/com/twilio/rest/api/v2010/AccountReader.java
+++ b/src/main/java/com/twilio/rest/api/v2010/AccountReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.api.v2010;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.exception.ApiConnectionException;
@@ -24,27 +25,26 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
-
-
public class AccountReader extends Reader {
+
private String friendlyName;
private Account.Status status;
private Integer pageSize;
- public AccountReader(){
- }
+ public AccountReader() {}
- public AccountReader setFriendlyName(final String friendlyName){
+ public AccountReader setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public AccountReader setStatus(final Account.Status status){
+
+ public AccountReader setStatus(final Account.Status status) {
this.status = status;
return this;
}
- public AccountReader setPageSize(final Integer pageSize){
+
+ public AccountReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -67,15 +67,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Account read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Account read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -89,7 +100,10 @@ private Page pageForRequest(final TwilioRestClient client, final Reques
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.API.toString())
@@ -97,9 +111,11 @@ public Page previousPage(final Page page, final TwilioRestClie
return pageForRequest(client, request);
}
-
@Override
- public Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.API.toString())
@@ -108,29 +124,27 @@ public Page nextPage(final Page page, final TwilioRestClient c
}
@Override
- public Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (friendlyName != null) {
-
request.addQueryParam("FriendlyName", friendlyName);
}
if (status != null) {
-
request.addQueryParam("Status", status.toString());
}
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java b/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java
index 339b08b1f0..838f34b793 100644
--- a/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java
+++ b/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010;
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;
@@ -24,63 +25,71 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AccountUpdater extends Updater {
-
-
-public class AccountUpdater extends Updater{
private String pathSid;
private String friendlyName;
private Account.Status status;
- public AccountUpdater(){
- }
- public AccountUpdater(final String pathSid){
+ public AccountUpdater() {}
+
+ public AccountUpdater(final String pathSid) {
this.pathSid = pathSid;
}
- public AccountUpdater setFriendlyName(final String friendlyName){
+ public AccountUpdater setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public AccountUpdater setStatus(final Account.Status status){
+
+ public AccountUpdater setStatus(final Account.Status status) {
this.status = status;
return this;
}
@Override
- public Account update(final TwilioRestClient client){
+ public Account update(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{Sid}.json";
- this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid;
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathSid =
+ this.pathSid == null ? client.getAccountSid() : this.pathSid;
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Account update failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Account update failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Account.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
if (status != null) {
request.addPostParam("Status", status.toString());
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/Address.java b/src/main/java/com/twilio/rest/api/v2010/account/Address.java
index b8dc4312c0..8a53321f3c 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/Address.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/Address.java
@@ -23,67 +23,110 @@
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
import java.io.IOException;
import java.io.InputStream;
import java.time.ZonedDateTime;
-
import java.util.Objects;
-
-
+import lombok.ToString;
+import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class Address extends Resource {
+
private static final long serialVersionUID = 73808189531379L;
- public static AddressCreator creator(final String customerName, final String street, final String city, final String region, final String postalCode, final String isoCountry){
- return new AddressCreator(customerName, street, city, region, postalCode, isoCountry);
+ public static AddressCreator creator(
+ final String customerName,
+ final String street,
+ final String city,
+ final String region,
+ final String postalCode,
+ final String isoCountry
+ ) {
+ return new AddressCreator(
+ customerName,
+ street,
+ city,
+ region,
+ postalCode,
+ isoCountry
+ );
}
- public static AddressCreator creator(final String pathAccountSid, final String customerName, final String street, final String city, final String region, final String postalCode, final String isoCountry){
- return new AddressCreator(pathAccountSid, customerName, street, city, region, postalCode, isoCountry);
+
+ public static AddressCreator creator(
+ final String pathAccountSid,
+ final String customerName,
+ final String street,
+ final String city,
+ final String region,
+ final String postalCode,
+ final String isoCountry
+ ) {
+ return new AddressCreator(
+ pathAccountSid,
+ customerName,
+ street,
+ city,
+ region,
+ postalCode,
+ isoCountry
+ );
}
- public static AddressDeleter deleter(final String pathSid){
+ public static AddressDeleter deleter(final String pathSid) {
return new AddressDeleter(pathSid);
}
- public static AddressDeleter deleter(final String pathAccountSid, final String pathSid){
+
+ public static AddressDeleter deleter(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new AddressDeleter(pathAccountSid, pathSid);
}
- public static AddressFetcher fetcher(final String pathSid){
+ public static AddressFetcher fetcher(final String pathSid) {
return new AddressFetcher(pathSid);
}
- public static AddressFetcher fetcher(final String pathAccountSid, final String pathSid){
+
+ public static AddressFetcher fetcher(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new AddressFetcher(pathAccountSid, pathSid);
}
- public static AddressReader reader(){
+ public static AddressReader reader() {
return new AddressReader();
}
- public static AddressReader reader(final String pathAccountSid){
+
+ public static AddressReader reader(final String pathAccountSid) {
return new AddressReader(pathAccountSid);
}
- public static AddressUpdater updater(final String pathSid){
+ public static AddressUpdater updater(final String pathSid) {
return new AddressUpdater(pathSid);
}
- public static AddressUpdater updater(final String pathAccountSid, final String pathSid){
+
+ public static AddressUpdater updater(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new AddressUpdater(pathAccountSid, pathSid);
}
/**
- * Converts a JSON String into a Address object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return Address object represented by the provided JSON
- */
- public static Address fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a Address object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Address object represented by the provided JSON
+ */
+ public static Address fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Address.class);
@@ -95,14 +138,17 @@ public static Address fromJson(final String json, final ObjectMapper objectMappe
}
/**
- * Converts a JSON InputStream into a Address object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return Address object represented by the provided JSON
- */
- public static Address fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a Address object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Address object represented by the provided JSON
+ */
+ public static Address fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Address.class);
@@ -132,53 +178,22 @@ public static Address fromJson(final InputStream json, final ObjectMapper object
@JsonCreator
private Address(
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("city")
- final String city,
-
- @JsonProperty("customer_name")
- final String customerName,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("friendly_name")
- final String friendlyName,
-
- @JsonProperty("iso_country")
- final String isoCountry,
-
- @JsonProperty("postal_code")
- final String postalCode,
-
- @JsonProperty("region")
- final String region,
-
- @JsonProperty("sid")
- final String sid,
-
- @JsonProperty("street")
- final String street,
-
- @JsonProperty("uri")
- final String uri,
-
- @JsonProperty("emergency_enabled")
- final Boolean emergencyEnabled,
-
- @JsonProperty("validated")
- final Boolean validated,
-
- @JsonProperty("verified")
- final Boolean verified,
-
- @JsonProperty("street_secondary")
- final String streetSecondary
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("city") final String city,
+ @JsonProperty("customer_name") final String customerName,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("friendly_name") final String friendlyName,
+ @JsonProperty("iso_country") final String isoCountry,
+ @JsonProperty("postal_code") final String postalCode,
+ @JsonProperty("region") final String region,
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("street") final String street,
+ @JsonProperty("uri") final String uri,
+ @JsonProperty("emergency_enabled") final Boolean emergencyEnabled,
+ @JsonProperty("validated") final Boolean validated,
+ @JsonProperty("verified") final Boolean verified,
+ @JsonProperty("street_secondary") final String streetSecondary
) {
this.accountSid = accountSid;
this.city = city;
@@ -198,58 +213,73 @@ private Address(
this.streetSecondary = streetSecondary;
}
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getCity() {
- return this.city;
- }
- public final String getCustomerName() {
- return this.customerName;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final String getFriendlyName() {
- return this.friendlyName;
- }
- public final String getIsoCountry() {
- return this.isoCountry;
- }
- public final String getPostalCode() {
- return this.postalCode;
- }
- public final String getRegion() {
- return this.region;
- }
- public final String getSid() {
- return this.sid;
- }
- public final String getStreet() {
- return this.street;
- }
- public final String getUri() {
- return this.uri;
- }
- public final Boolean getEmergencyEnabled() {
- return this.emergencyEnabled;
- }
- public final Boolean getValidated() {
- return this.validated;
- }
- public final Boolean getVerified() {
- return this.verified;
- }
- public final String getStreetSecondary() {
- return this.streetSecondary;
- }
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getCity() {
+ return this.city;
+ }
+
+ public final String getCustomerName() {
+ return this.customerName;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final String getFriendlyName() {
+ return this.friendlyName;
+ }
+
+ public final String getIsoCountry() {
+ return this.isoCountry;
+ }
+
+ public final String getPostalCode() {
+ return this.postalCode;
+ }
+
+ public final String getRegion() {
+ return this.region;
+ }
+
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final String getStreet() {
+ return this.street;
+ }
+
+ public final String getUri() {
+ return this.uri;
+ }
+
+ public final Boolean getEmergencyEnabled() {
+ return this.emergencyEnabled;
+ }
+
+ public final Boolean getValidated() {
+ return this.validated;
+ }
+
+ public final Boolean getVerified() {
+ return this.verified;
+ }
+
+ public final String getStreetSecondary() {
+ return this.streetSecondary;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -259,13 +289,45 @@ public boolean equals(final Object o) {
Address other = (Address) o;
- return Objects.equals(accountSid, other.accountSid) && Objects.equals(city, other.city) && Objects.equals(customerName, other.customerName) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(friendlyName, other.friendlyName) && Objects.equals(isoCountry, other.isoCountry) && Objects.equals(postalCode, other.postalCode) && Objects.equals(region, other.region) && Objects.equals(sid, other.sid) && Objects.equals(street, other.street) && Objects.equals(uri, other.uri) && Objects.equals(emergencyEnabled, other.emergencyEnabled) && Objects.equals(validated, other.validated) && Objects.equals(verified, other.verified) && Objects.equals(streetSecondary, other.streetSecondary) ;
+ return (
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(city, other.city) &&
+ Objects.equals(customerName, other.customerName) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(friendlyName, other.friendlyName) &&
+ Objects.equals(isoCountry, other.isoCountry) &&
+ Objects.equals(postalCode, other.postalCode) &&
+ Objects.equals(region, other.region) &&
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(street, other.street) &&
+ Objects.equals(uri, other.uri) &&
+ Objects.equals(emergencyEnabled, other.emergencyEnabled) &&
+ Objects.equals(validated, other.validated) &&
+ Objects.equals(verified, other.verified) &&
+ Objects.equals(streetSecondary, other.streetSecondary)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(accountSid, city, customerName, dateCreated, dateUpdated, friendlyName, isoCountry, postalCode, region, sid, street, uri, emergencyEnabled, validated, verified, streetSecondary);
+ return Objects.hash(
+ accountSid,
+ city,
+ customerName,
+ dateCreated,
+ dateUpdated,
+ friendlyName,
+ isoCountry,
+ postalCode,
+ region,
+ sid,
+ street,
+ uri,
+ emergencyEnabled,
+ validated,
+ verified,
+ streetSecondary
+ );
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AddressCreator.java b/src/main/java/com/twilio/rest/api/v2010/account/AddressCreator.java
index c2cbfd9164..682ce3e562 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AddressCreator.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AddressCreator.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010.account;
import com.twilio.base.Creator;
+import com.twilio.constant.EnumConstants;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
@@ -24,10 +25,8 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AddressCreator extends Creator {
-
-
-public class AddressCreator extends Creator{
private String customerName;
private String street;
private String city;
@@ -40,7 +39,14 @@ public class AddressCreator extends Creator{
private Boolean autoCorrectAddress;
private String streetSecondary;
- public AddressCreator(final String customerName, final String street, final String city, final String region, final String postalCode, final String isoCountry) {
+ public AddressCreator(
+ final String customerName,
+ final String street,
+ final String city,
+ final String region,
+ final String postalCode,
+ final String isoCountry
+ ) {
this.customerName = customerName;
this.street = street;
this.city = city;
@@ -48,7 +54,16 @@ public AddressCreator(final String customerName, final String street, final Stri
this.postalCode = postalCode;
this.isoCountry = isoCountry;
}
- public AddressCreator(final String pathAccountSid, final String customerName, final String street, final String city, final String region, final String postalCode, final String isoCountry) {
+
+ public AddressCreator(
+ final String pathAccountSid,
+ final String customerName,
+ final String street,
+ final String city,
+ final String region,
+ final String postalCode,
+ final String isoCountry
+ ) {
this.pathAccountSid = pathAccountSid;
this.customerName = customerName;
this.street = street;
@@ -58,119 +73,149 @@ public AddressCreator(final String pathAccountSid, final String customerName, fi
this.isoCountry = isoCountry;
}
- public AddressCreator setCustomerName(final String customerName){
+ public AddressCreator setCustomerName(final String customerName) {
this.customerName = customerName;
return this;
}
- public AddressCreator setStreet(final String street){
+
+ public AddressCreator setStreet(final String street) {
this.street = street;
return this;
}
- public AddressCreator setCity(final String city){
+
+ public AddressCreator setCity(final String city) {
this.city = city;
return this;
}
- public AddressCreator setRegion(final String region){
+
+ public AddressCreator setRegion(final String region) {
this.region = region;
return this;
}
- public AddressCreator setPostalCode(final String postalCode){
+
+ public AddressCreator setPostalCode(final String postalCode) {
this.postalCode = postalCode;
return this;
}
- public AddressCreator setIsoCountry(final String isoCountry){
+
+ public AddressCreator setIsoCountry(final String isoCountry) {
this.isoCountry = isoCountry;
return this;
}
- public AddressCreator setFriendlyName(final String friendlyName){
+
+ public AddressCreator setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public AddressCreator setEmergencyEnabled(final Boolean emergencyEnabled){
+
+ public AddressCreator setEmergencyEnabled(final Boolean emergencyEnabled) {
this.emergencyEnabled = emergencyEnabled;
return this;
}
- public AddressCreator setAutoCorrectAddress(final Boolean autoCorrectAddress){
+
+ public AddressCreator setAutoCorrectAddress(
+ final Boolean autoCorrectAddress
+ ) {
this.autoCorrectAddress = autoCorrectAddress;
return this;
}
- public AddressCreator setStreetSecondary(final String streetSecondary){
+
+ public AddressCreator setStreetSecondary(final String streetSecondary) {
this.streetSecondary = streetSecondary;
return this;
}
@Override
- public Address create(final TwilioRestClient client){
+ public Address create(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Addresses.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"CustomerName"+"}", this.customerName.toString());
- path = path.replace("{"+"Street"+"}", this.street.toString());
- path = path.replace("{"+"City"+"}", this.city.toString());
- path = path.replace("{"+"Region"+"}", this.region.toString());
- path = path.replace("{"+"PostalCode"+"}", this.postalCode.toString());
- path = path.replace("{"+"IsoCountry"+"}", this.isoCountry.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path =
+ path.replace(
+ "{" + "CustomerName" + "}",
+ this.customerName.toString()
+ );
+ path = path.replace("{" + "Street" + "}", this.street.toString());
+ path = path.replace("{" + "City" + "}", this.city.toString());
+ path = path.replace("{" + "Region" + "}", this.region.toString());
+ path =
+ path.replace("{" + "PostalCode" + "}", this.postalCode.toString());
+ path =
+ path.replace("{" + "IsoCountry" + "}", this.isoCountry.toString());
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Address creation failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Address creation failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Address.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (customerName != null) {
request.addPostParam("CustomerName", customerName);
-
}
if (street != null) {
request.addPostParam("Street", street);
-
}
if (city != null) {
request.addPostParam("City", city);
-
}
if (region != null) {
request.addPostParam("Region", region);
-
}
if (postalCode != null) {
request.addPostParam("PostalCode", postalCode);
-
}
if (isoCountry != null) {
request.addPostParam("IsoCountry", isoCountry);
-
}
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
if (emergencyEnabled != null) {
- request.addPostParam("EmergencyEnabled", emergencyEnabled.toString());
-
+ request.addPostParam(
+ "EmergencyEnabled",
+ emergencyEnabled.toString()
+ );
}
if (autoCorrectAddress != null) {
- request.addPostParam("AutoCorrectAddress", autoCorrectAddress.toString());
-
+ request.addPostParam(
+ "AutoCorrectAddress",
+ autoCorrectAddress.toString()
+ );
}
if (streetSecondary != null) {
request.addPostParam("StreetSecondary", streetSecondary);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AddressDeleter.java b/src/main/java/com/twilio/rest/api/v2010/account/AddressDeleter.java
index beb1c93f8f..c55cc9b7d1 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AddressDeleter.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AddressDeleter.java
@@ -24,28 +24,34 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
public class AddressDeleter extends Deleter {
+
private String pathSid;
private String pathAccountSid;
- public AddressDeleter(final String pathSid){
+ public AddressDeleter(final String pathSid) {
this.pathSid = pathSid;
}
- public AddressDeleter(final String pathAccountSid, final String pathSid){
+
+ public AddressDeleter(final String pathAccountSid, final String pathSid) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
-
@Override
public boolean delete(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.DELETE,
@@ -55,11 +61,19 @@ public boolean delete(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Address delete failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Address delete failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AddressFetcher.java b/src/main/java/com/twilio/rest/api/v2010/account/AddressFetcher.java
index 419a8a19b1..262251a7ad 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AddressFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AddressFetcher.java
@@ -24,29 +24,34 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class AddressFetcher extends Fetcher {
+
private String pathSid;
private String pathAccountSid;
- public AddressFetcher(final String pathSid){
+ public AddressFetcher(final String pathSid) {
this.pathSid = pathSid;
}
- public AddressFetcher(final String pathAccountSid, final String pathSid){
+
+ public AddressFetcher(final String pathAccountSid, final String pathSid) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
-
@Override
public Address fetch(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.GET,
@@ -56,11 +61,19 @@ public Address fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Address fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Address fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AddressReader.java b/src/main/java/com/twilio/rest/api/v2010/account/AddressReader.java
index 2887a4f06f..505466f0ee 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AddressReader.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AddressReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.api.v2010.account;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.exception.ApiConnectionException;
@@ -24,36 +25,37 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
-
-
public class AddressReader extends Reader {
+
private String pathAccountSid;
private String customerName;
private String friendlyName;
private String isoCountry;
private Integer pageSize;
- public AddressReader(){
- }
- public AddressReader(final String pathAccountSid){
+ public AddressReader() {}
+
+ public AddressReader(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
- public AddressReader setCustomerName(final String customerName){
+ public AddressReader setCustomerName(final String customerName) {
this.customerName = customerName;
return this;
}
- public AddressReader setFriendlyName(final String friendlyName){
+
+ public AddressReader setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public AddressReader setIsoCountry(final String isoCountry){
+
+ public AddressReader setIsoCountry(final String isoCountry) {
this.isoCountry = isoCountry;
return this;
}
- public AddressReader setPageSize(final Integer pageSize){
+
+ public AddressReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -65,8 +67,15 @@ public ResourceSet read(final TwilioRestClient client) {
public Page firstPage(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Addresses.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -78,15 +87,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Address read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Address read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -100,7 +120,10 @@ private Page pageForRequest(final TwilioRestClient client, final Reques
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.API.toString())
@@ -108,9 +131,11 @@ public Page previousPage(final Page page, final TwilioRestClie
return pageForRequest(client, request);
}
-
@Override
- public Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.API.toString())
@@ -119,33 +144,30 @@ public Page nextPage(final Page page, final TwilioRestClient c
}
@Override
- public Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (customerName != null) {
-
request.addQueryParam("CustomerName", customerName);
}
if (friendlyName != null) {
-
request.addQueryParam("FriendlyName", friendlyName);
}
if (isoCountry != null) {
-
request.addQueryParam("IsoCountry", isoCountry);
}
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AddressUpdater.java b/src/main/java/com/twilio/rest/api/v2010/account/AddressUpdater.java
index e1dec4191f..87bca4bc48 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AddressUpdater.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AddressUpdater.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010.account;
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;
@@ -24,10 +25,8 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AddressUpdater extends Updater {
-
-
-public class AddressUpdater extends Updater{
private String pathSid;
private String pathAccountSid;
private String friendlyName;
@@ -40,114 +39,139 @@ public class AddressUpdater extends Updater{
private Boolean autoCorrectAddress;
private String streetSecondary;
- public AddressUpdater(final String pathSid){
+ public AddressUpdater(final String pathSid) {
this.pathSid = pathSid;
}
- public AddressUpdater(final String pathAccountSid, final String pathSid){
+
+ public AddressUpdater(final String pathAccountSid, final String pathSid) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
- public AddressUpdater setFriendlyName(final String friendlyName){
+ public AddressUpdater setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public AddressUpdater setCustomerName(final String customerName){
+
+ public AddressUpdater setCustomerName(final String customerName) {
this.customerName = customerName;
return this;
}
- public AddressUpdater setStreet(final String street){
+
+ public AddressUpdater setStreet(final String street) {
this.street = street;
return this;
}
- public AddressUpdater setCity(final String city){
+
+ public AddressUpdater setCity(final String city) {
this.city = city;
return this;
}
- public AddressUpdater setRegion(final String region){
+
+ public AddressUpdater setRegion(final String region) {
this.region = region;
return this;
}
- public AddressUpdater setPostalCode(final String postalCode){
+
+ public AddressUpdater setPostalCode(final String postalCode) {
this.postalCode = postalCode;
return this;
}
- public AddressUpdater setEmergencyEnabled(final Boolean emergencyEnabled){
+
+ public AddressUpdater setEmergencyEnabled(final Boolean emergencyEnabled) {
this.emergencyEnabled = emergencyEnabled;
return this;
}
- public AddressUpdater setAutoCorrectAddress(final Boolean autoCorrectAddress){
+
+ public AddressUpdater setAutoCorrectAddress(
+ final Boolean autoCorrectAddress
+ ) {
this.autoCorrectAddress = autoCorrectAddress;
return this;
}
- public AddressUpdater setStreetSecondary(final String streetSecondary){
+
+ public AddressUpdater setStreetSecondary(final String streetSecondary) {
this.streetSecondary = streetSecondary;
return this;
}
@Override
- public Address update(final TwilioRestClient client){
+ public Address update(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Address update failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Address update failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Address.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
if (customerName != null) {
request.addPostParam("CustomerName", customerName);
-
}
if (street != null) {
request.addPostParam("Street", street);
-
}
if (city != null) {
request.addPostParam("City", city);
-
}
if (region != null) {
request.addPostParam("Region", region);
-
}
if (postalCode != null) {
request.addPostParam("PostalCode", postalCode);
-
}
if (emergencyEnabled != null) {
- request.addPostParam("EmergencyEnabled", emergencyEnabled.toString());
-
+ request.addPostParam(
+ "EmergencyEnabled",
+ emergencyEnabled.toString()
+ );
}
if (autoCorrectAddress != null) {
- request.addPostParam("AutoCorrectAddress", autoCorrectAddress.toString());
-
+ request.addPostParam(
+ "AutoCorrectAddress",
+ autoCorrectAddress.toString()
+ );
}
if (streetSecondary != null) {
request.addPostParam("StreetSecondary", streetSecondary);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/Application.java b/src/main/java/com/twilio/rest/api/v2010/account/Application.java
index 208f8be8c6..d9e76250e5 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/Application.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/Application.java
@@ -23,69 +23,82 @@
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
import com.twilio.http.HttpMethod;
-
-import lombok.ToString;
-
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 Application extends Resource {
+
private static final long serialVersionUID = 38146741905668L;
- public static ApplicationCreator creator(){
+ public static ApplicationCreator creator() {
return new ApplicationCreator();
}
- public static ApplicationCreator creator(final String pathAccountSid){
+
+ public static ApplicationCreator creator(final String pathAccountSid) {
return new ApplicationCreator(pathAccountSid);
}
- public static ApplicationDeleter deleter(final String pathSid){
+ public static ApplicationDeleter deleter(final String pathSid) {
return new ApplicationDeleter(pathSid);
}
- public static ApplicationDeleter deleter(final String pathAccountSid, final String pathSid){
+
+ public static ApplicationDeleter deleter(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new ApplicationDeleter(pathAccountSid, pathSid);
}
- public static ApplicationFetcher fetcher(final String pathSid){
+ public static ApplicationFetcher fetcher(final String pathSid) {
return new ApplicationFetcher(pathSid);
}
- public static ApplicationFetcher fetcher(final String pathAccountSid, final String pathSid){
+
+ public static ApplicationFetcher fetcher(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new ApplicationFetcher(pathAccountSid, pathSid);
}
- public static ApplicationReader reader(){
+ public static ApplicationReader reader() {
return new ApplicationReader();
}
- public static ApplicationReader reader(final String pathAccountSid){
+
+ public static ApplicationReader reader(final String pathAccountSid) {
return new ApplicationReader(pathAccountSid);
}
- public static ApplicationUpdater updater(final String pathSid){
+ public static ApplicationUpdater updater(final String pathSid) {
return new ApplicationUpdater(pathSid);
}
- public static ApplicationUpdater updater(final String pathAccountSid, final String pathSid){
+
+ public static ApplicationUpdater updater(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new ApplicationUpdater(pathAccountSid, pathSid);
}
/**
- * Converts a JSON String into a Application object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return Application object represented by the provided JSON
- */
- public static Application fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a Application object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Application object represented by the provided JSON
+ */
+ public static Application fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Application.class);
@@ -97,14 +110,17 @@ public static Application fromJson(final String json, final ObjectMapper objectM
}
/**
- * Converts a JSON InputStream into a Application object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return Application object represented by the provided JSON
- */
- public static Application fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a Application object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Application object represented by the provided JSON
+ */
+ public static Application fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Application.class);
@@ -139,68 +155,37 @@ public static Application fromJson(final InputStream json, final ObjectMapper ob
@JsonCreator
private Application(
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("api_version")
- final String apiVersion,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("friendly_name")
- final String friendlyName,
-
- @JsonProperty("message_status_callback")
- final URI messageStatusCallback,
-
- @JsonProperty("sid")
- final String sid,
-
- @JsonProperty("sms_fallback_method")
- final HttpMethod smsFallbackMethod,
-
- @JsonProperty("sms_fallback_url")
- final URI smsFallbackUrl,
-
- @JsonProperty("sms_method")
- final HttpMethod smsMethod,
-
- @JsonProperty("sms_status_callback")
- final URI smsStatusCallback,
-
- @JsonProperty("sms_url")
- final URI smsUrl,
-
- @JsonProperty("status_callback")
- final URI statusCallback,
-
- @JsonProperty("status_callback_method")
- final HttpMethod statusCallbackMethod,
-
- @JsonProperty("uri")
- final String uri,
-
- @JsonProperty("voice_caller_id_lookup")
- final Boolean voiceCallerIdLookup,
-
- @JsonProperty("voice_fallback_method")
- final HttpMethod voiceFallbackMethod,
-
- @JsonProperty("voice_fallback_url")
- final URI voiceFallbackUrl,
-
- @JsonProperty("voice_method")
- final HttpMethod voiceMethod,
-
- @JsonProperty("voice_url")
- final URI voiceUrl,
-
- @JsonProperty("public_application_connect_enabled")
- final Boolean publicApplicationConnectEnabled
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("api_version") final String apiVersion,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("friendly_name") final String friendlyName,
+ @JsonProperty(
+ "message_status_callback"
+ ) final URI messageStatusCallback,
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("sms_fallback_method") final HttpMethod smsFallbackMethod,
+ @JsonProperty("sms_fallback_url") final URI smsFallbackUrl,
+ @JsonProperty("sms_method") final HttpMethod smsMethod,
+ @JsonProperty("sms_status_callback") final URI smsStatusCallback,
+ @JsonProperty("sms_url") final URI smsUrl,
+ @JsonProperty("status_callback") final URI statusCallback,
+ @JsonProperty(
+ "status_callback_method"
+ ) final HttpMethod statusCallbackMethod,
+ @JsonProperty("uri") final String uri,
+ @JsonProperty(
+ "voice_caller_id_lookup"
+ ) final Boolean voiceCallerIdLookup,
+ @JsonProperty(
+ "voice_fallback_method"
+ ) final HttpMethod voiceFallbackMethod,
+ @JsonProperty("voice_fallback_url") final URI voiceFallbackUrl,
+ @JsonProperty("voice_method") final HttpMethod voiceMethod,
+ @JsonProperty("voice_url") final URI voiceUrl,
+ @JsonProperty(
+ "public_application_connect_enabled"
+ ) final Boolean publicApplicationConnectEnabled
) {
this.accountSid = accountSid;
this.apiVersion = apiVersion;
@@ -225,73 +210,93 @@ private Application(
this.publicApplicationConnectEnabled = publicApplicationConnectEnabled;
}
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getApiVersion() {
- return this.apiVersion;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final String getFriendlyName() {
- return this.friendlyName;
- }
- public final URI getMessageStatusCallback() {
- return this.messageStatusCallback;
- }
- public final String getSid() {
- return this.sid;
- }
- public final HttpMethod getSmsFallbackMethod() {
- return this.smsFallbackMethod;
- }
- public final URI getSmsFallbackUrl() {
- return this.smsFallbackUrl;
- }
- public final HttpMethod getSmsMethod() {
- return this.smsMethod;
- }
- public final URI getSmsStatusCallback() {
- return this.smsStatusCallback;
- }
- public final URI getSmsUrl() {
- return this.smsUrl;
- }
- public final URI getStatusCallback() {
- return this.statusCallback;
- }
- public final HttpMethod getStatusCallbackMethod() {
- return this.statusCallbackMethod;
- }
- public final String getUri() {
- return this.uri;
- }
- public final Boolean getVoiceCallerIdLookup() {
- return this.voiceCallerIdLookup;
- }
- public final HttpMethod getVoiceFallbackMethod() {
- return this.voiceFallbackMethod;
- }
- public final URI getVoiceFallbackUrl() {
- return this.voiceFallbackUrl;
- }
- public final HttpMethod getVoiceMethod() {
- return this.voiceMethod;
- }
- public final URI getVoiceUrl() {
- return this.voiceUrl;
- }
- public final Boolean getPublicApplicationConnectEnabled() {
- return this.publicApplicationConnectEnabled;
- }
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getApiVersion() {
+ return this.apiVersion;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final String getFriendlyName() {
+ return this.friendlyName;
+ }
+
+ public final URI getMessageStatusCallback() {
+ return this.messageStatusCallback;
+ }
+
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final HttpMethod getSmsFallbackMethod() {
+ return this.smsFallbackMethod;
+ }
+
+ public final URI getSmsFallbackUrl() {
+ return this.smsFallbackUrl;
+ }
+
+ public final HttpMethod getSmsMethod() {
+ return this.smsMethod;
+ }
+
+ public final URI getSmsStatusCallback() {
+ return this.smsStatusCallback;
+ }
+
+ public final URI getSmsUrl() {
+ return this.smsUrl;
+ }
+
+ public final URI getStatusCallback() {
+ return this.statusCallback;
+ }
+
+ public final HttpMethod getStatusCallbackMethod() {
+ return this.statusCallbackMethod;
+ }
+
+ public final String getUri() {
+ return this.uri;
+ }
+
+ public final Boolean getVoiceCallerIdLookup() {
+ return this.voiceCallerIdLookup;
+ }
+
+ public final HttpMethod getVoiceFallbackMethod() {
+ return this.voiceFallbackMethod;
+ }
+
+ public final URI getVoiceFallbackUrl() {
+ return this.voiceFallbackUrl;
+ }
+
+ public final HttpMethod getVoiceMethod() {
+ return this.voiceMethod;
+ }
+
+ public final URI getVoiceUrl() {
+ return this.voiceUrl;
+ }
+
+ public final Boolean getPublicApplicationConnectEnabled() {
+ return this.publicApplicationConnectEnabled;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -301,13 +306,61 @@ public boolean equals(final Object o) {
Application other = (Application) o;
- return Objects.equals(accountSid, other.accountSid) && Objects.equals(apiVersion, other.apiVersion) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(friendlyName, other.friendlyName) && Objects.equals(messageStatusCallback, other.messageStatusCallback) && Objects.equals(sid, other.sid) && Objects.equals(smsFallbackMethod, other.smsFallbackMethod) && Objects.equals(smsFallbackUrl, other.smsFallbackUrl) && Objects.equals(smsMethod, other.smsMethod) && Objects.equals(smsStatusCallback, other.smsStatusCallback) && Objects.equals(smsUrl, other.smsUrl) && Objects.equals(statusCallback, other.statusCallback) && Objects.equals(statusCallbackMethod, other.statusCallbackMethod) && Objects.equals(uri, other.uri) && Objects.equals(voiceCallerIdLookup, other.voiceCallerIdLookup) && Objects.equals(voiceFallbackMethod, other.voiceFallbackMethod) && Objects.equals(voiceFallbackUrl, other.voiceFallbackUrl) && Objects.equals(voiceMethod, other.voiceMethod) && Objects.equals(voiceUrl, other.voiceUrl) && Objects.equals(publicApplicationConnectEnabled, other.publicApplicationConnectEnabled) ;
+ return (
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(apiVersion, other.apiVersion) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(friendlyName, other.friendlyName) &&
+ Objects.equals(
+ messageStatusCallback,
+ other.messageStatusCallback
+ ) &&
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(smsFallbackMethod, other.smsFallbackMethod) &&
+ Objects.equals(smsFallbackUrl, other.smsFallbackUrl) &&
+ Objects.equals(smsMethod, other.smsMethod) &&
+ Objects.equals(smsStatusCallback, other.smsStatusCallback) &&
+ Objects.equals(smsUrl, other.smsUrl) &&
+ Objects.equals(statusCallback, other.statusCallback) &&
+ Objects.equals(statusCallbackMethod, other.statusCallbackMethod) &&
+ Objects.equals(uri, other.uri) &&
+ Objects.equals(voiceCallerIdLookup, other.voiceCallerIdLookup) &&
+ Objects.equals(voiceFallbackMethod, other.voiceFallbackMethod) &&
+ Objects.equals(voiceFallbackUrl, other.voiceFallbackUrl) &&
+ Objects.equals(voiceMethod, other.voiceMethod) &&
+ Objects.equals(voiceUrl, other.voiceUrl) &&
+ Objects.equals(
+ publicApplicationConnectEnabled,
+ other.publicApplicationConnectEnabled
+ )
+ );
}
@Override
public int hashCode() {
- return Objects.hash(accountSid, apiVersion, dateCreated, dateUpdated, friendlyName, messageStatusCallback, sid, smsFallbackMethod, smsFallbackUrl, smsMethod, smsStatusCallback, smsUrl, statusCallback, statusCallbackMethod, uri, voiceCallerIdLookup, voiceFallbackMethod, voiceFallbackUrl, voiceMethod, voiceUrl, publicApplicationConnectEnabled);
+ return Objects.hash(
+ accountSid,
+ apiVersion,
+ dateCreated,
+ dateUpdated,
+ friendlyName,
+ messageStatusCallback,
+ sid,
+ smsFallbackMethod,
+ smsFallbackUrl,
+ smsMethod,
+ smsStatusCallback,
+ smsUrl,
+ statusCallback,
+ statusCallbackMethod,
+ uri,
+ voiceCallerIdLookup,
+ voiceFallbackMethod,
+ voiceFallbackUrl,
+ voiceMethod,
+ voiceUrl,
+ publicApplicationConnectEnabled
+ );
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationCreator.java b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationCreator.java
index f0ddfeaccf..7fae4fc326 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationCreator.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationCreator.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010.account;
import com.twilio.base.Creator;
+import com.twilio.constant.EnumConstants;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
@@ -25,12 +26,10 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
import java.net.URI;
-
-
-
import java.net.URI;
-public class ApplicationCreator extends Creator{
+public class ApplicationCreator extends Creator {
+
private String pathAccountSid;
private String apiVersion;
private URI voiceUrl;
@@ -49,195 +48,260 @@ public class ApplicationCreator extends Creator{
private String friendlyName;
private Boolean publicApplicationConnectEnabled;
- public ApplicationCreator() {
- }
+ public ApplicationCreator() {}
+
public ApplicationCreator(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
- public ApplicationCreator setApiVersion(final String apiVersion){
+ public ApplicationCreator setApiVersion(final String apiVersion) {
this.apiVersion = apiVersion;
return this;
}
- public ApplicationCreator setVoiceUrl(final URI voiceUrl){
+
+ public ApplicationCreator setVoiceUrl(final URI voiceUrl) {
this.voiceUrl = voiceUrl;
return this;
}
- public ApplicationCreator setVoiceUrl(final String voiceUrl){
+ public ApplicationCreator setVoiceUrl(final String voiceUrl) {
return setVoiceUrl(Promoter.uriFromString(voiceUrl));
}
- public ApplicationCreator setVoiceMethod(final HttpMethod voiceMethod){
+
+ public ApplicationCreator setVoiceMethod(final HttpMethod voiceMethod) {
this.voiceMethod = voiceMethod;
return this;
}
- public ApplicationCreator setVoiceFallbackUrl(final URI voiceFallbackUrl){
+
+ public ApplicationCreator setVoiceFallbackUrl(final URI voiceFallbackUrl) {
this.voiceFallbackUrl = voiceFallbackUrl;
return this;
}
- public ApplicationCreator setVoiceFallbackUrl(final String voiceFallbackUrl){
+ public ApplicationCreator setVoiceFallbackUrl(
+ final String voiceFallbackUrl
+ ) {
return setVoiceFallbackUrl(Promoter.uriFromString(voiceFallbackUrl));
}
- public ApplicationCreator setVoiceFallbackMethod(final HttpMethod voiceFallbackMethod){
+
+ public ApplicationCreator setVoiceFallbackMethod(
+ final HttpMethod voiceFallbackMethod
+ ) {
this.voiceFallbackMethod = voiceFallbackMethod;
return this;
}
- public ApplicationCreator setStatusCallback(final URI statusCallback){
+
+ public ApplicationCreator setStatusCallback(final URI statusCallback) {
this.statusCallback = statusCallback;
return this;
}
- public ApplicationCreator setStatusCallback(final String statusCallback){
+ public ApplicationCreator setStatusCallback(final String statusCallback) {
return setStatusCallback(Promoter.uriFromString(statusCallback));
}
- public ApplicationCreator setStatusCallbackMethod(final HttpMethod statusCallbackMethod){
+
+ public ApplicationCreator setStatusCallbackMethod(
+ final HttpMethod statusCallbackMethod
+ ) {
this.statusCallbackMethod = statusCallbackMethod;
return this;
}
- public ApplicationCreator setVoiceCallerIdLookup(final Boolean voiceCallerIdLookup){
+
+ public ApplicationCreator setVoiceCallerIdLookup(
+ final Boolean voiceCallerIdLookup
+ ) {
this.voiceCallerIdLookup = voiceCallerIdLookup;
return this;
}
- public ApplicationCreator setSmsUrl(final URI smsUrl){
+
+ public ApplicationCreator setSmsUrl(final URI smsUrl) {
this.smsUrl = smsUrl;
return this;
}
- public ApplicationCreator setSmsUrl(final String smsUrl){
+ public ApplicationCreator setSmsUrl(final String smsUrl) {
return setSmsUrl(Promoter.uriFromString(smsUrl));
}
- public ApplicationCreator setSmsMethod(final HttpMethod smsMethod){
+
+ public ApplicationCreator setSmsMethod(final HttpMethod smsMethod) {
this.smsMethod = smsMethod;
return this;
}
- public ApplicationCreator setSmsFallbackUrl(final URI smsFallbackUrl){
+
+ public ApplicationCreator setSmsFallbackUrl(final URI smsFallbackUrl) {
this.smsFallbackUrl = smsFallbackUrl;
return this;
}
- public ApplicationCreator setSmsFallbackUrl(final String smsFallbackUrl){
+ public ApplicationCreator setSmsFallbackUrl(final String smsFallbackUrl) {
return setSmsFallbackUrl(Promoter.uriFromString(smsFallbackUrl));
}
- public ApplicationCreator setSmsFallbackMethod(final HttpMethod smsFallbackMethod){
+
+ public ApplicationCreator setSmsFallbackMethod(
+ final HttpMethod smsFallbackMethod
+ ) {
this.smsFallbackMethod = smsFallbackMethod;
return this;
}
- public ApplicationCreator setSmsStatusCallback(final URI smsStatusCallback){
+
+ public ApplicationCreator setSmsStatusCallback(
+ final URI smsStatusCallback
+ ) {
this.smsStatusCallback = smsStatusCallback;
return this;
}
- public ApplicationCreator setSmsStatusCallback(final String smsStatusCallback){
+ public ApplicationCreator setSmsStatusCallback(
+ final String smsStatusCallback
+ ) {
return setSmsStatusCallback(Promoter.uriFromString(smsStatusCallback));
}
- public ApplicationCreator setMessageStatusCallback(final URI messageStatusCallback){
+
+ public ApplicationCreator setMessageStatusCallback(
+ final URI messageStatusCallback
+ ) {
this.messageStatusCallback = messageStatusCallback;
return this;
}
- public ApplicationCreator setMessageStatusCallback(final String messageStatusCallback){
- return setMessageStatusCallback(Promoter.uriFromString(messageStatusCallback));
+ public ApplicationCreator setMessageStatusCallback(
+ final String messageStatusCallback
+ ) {
+ return setMessageStatusCallback(
+ Promoter.uriFromString(messageStatusCallback)
+ );
}
- public ApplicationCreator setFriendlyName(final String friendlyName){
+
+ public ApplicationCreator setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public ApplicationCreator setPublicApplicationConnectEnabled(final Boolean publicApplicationConnectEnabled){
+
+ public ApplicationCreator setPublicApplicationConnectEnabled(
+ final Boolean publicApplicationConnectEnabled
+ ) {
this.publicApplicationConnectEnabled = publicApplicationConnectEnabled;
return this;
}
@Override
- public Application create(final TwilioRestClient client){
+ public Application create(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Applications.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Application creation failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Application creation failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return Application.fromJson(response.getStream(), client.getObjectMapper());
+ return Application.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
+
private void addPostParams(final Request request) {
if (apiVersion != null) {
request.addPostParam("ApiVersion", apiVersion);
-
}
if (voiceUrl != null) {
request.addPostParam("VoiceUrl", voiceUrl.toString());
-
}
if (voiceMethod != null) {
request.addPostParam("VoiceMethod", voiceMethod.toString());
-
}
if (voiceFallbackUrl != null) {
- request.addPostParam("VoiceFallbackUrl", voiceFallbackUrl.toString());
-
+ request.addPostParam(
+ "VoiceFallbackUrl",
+ voiceFallbackUrl.toString()
+ );
}
if (voiceFallbackMethod != null) {
- request.addPostParam("VoiceFallbackMethod", voiceFallbackMethod.toString());
-
+ request.addPostParam(
+ "VoiceFallbackMethod",
+ voiceFallbackMethod.toString()
+ );
}
if (statusCallback != null) {
request.addPostParam("StatusCallback", statusCallback.toString());
-
}
if (statusCallbackMethod != null) {
- request.addPostParam("StatusCallbackMethod", statusCallbackMethod.toString());
-
+ request.addPostParam(
+ "StatusCallbackMethod",
+ statusCallbackMethod.toString()
+ );
}
if (voiceCallerIdLookup != null) {
- request.addPostParam("VoiceCallerIdLookup", voiceCallerIdLookup.toString());
-
+ request.addPostParam(
+ "VoiceCallerIdLookup",
+ voiceCallerIdLookup.toString()
+ );
}
if (smsUrl != null) {
request.addPostParam("SmsUrl", smsUrl.toString());
-
}
if (smsMethod != null) {
request.addPostParam("SmsMethod", smsMethod.toString());
-
}
if (smsFallbackUrl != null) {
request.addPostParam("SmsFallbackUrl", smsFallbackUrl.toString());
-
}
if (smsFallbackMethod != null) {
- request.addPostParam("SmsFallbackMethod", smsFallbackMethod.toString());
-
+ request.addPostParam(
+ "SmsFallbackMethod",
+ smsFallbackMethod.toString()
+ );
}
if (smsStatusCallback != null) {
- request.addPostParam("SmsStatusCallback", smsStatusCallback.toString());
-
+ request.addPostParam(
+ "SmsStatusCallback",
+ smsStatusCallback.toString()
+ );
}
if (messageStatusCallback != null) {
- request.addPostParam("MessageStatusCallback", messageStatusCallback.toString());
-
+ request.addPostParam(
+ "MessageStatusCallback",
+ messageStatusCallback.toString()
+ );
}
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
if (publicApplicationConnectEnabled != null) {
- request.addPostParam("PublicApplicationConnectEnabled", publicApplicationConnectEnabled.toString());
-
+ request.addPostParam(
+ "PublicApplicationConnectEnabled",
+ publicApplicationConnectEnabled.toString()
+ );
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationDeleter.java b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationDeleter.java
index 21d950bce9..fc2420e3e6 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationDeleter.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationDeleter.java
@@ -24,28 +24,38 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
public class ApplicationDeleter extends Deleter {
+
private String pathSid;
private String pathAccountSid;
- public ApplicationDeleter(final String pathSid){
+ public ApplicationDeleter(final String pathSid) {
this.pathSid = pathSid;
}
- public ApplicationDeleter(final String pathAccountSid, final String pathSid){
+
+ public ApplicationDeleter(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
-
@Override
public boolean delete(final TwilioRestClient client) {
- String path = "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json";
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.DELETE,
@@ -55,11 +65,19 @@ public boolean delete(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Application delete failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Application delete failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationFetcher.java b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationFetcher.java
index 288a995f6e..315e8c90c1 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationFetcher.java
@@ -24,29 +24,38 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class ApplicationFetcher extends Fetcher {
+
private String pathSid;
private String pathAccountSid;
- public ApplicationFetcher(final String pathSid){
+ public ApplicationFetcher(final String pathSid) {
this.pathSid = pathSid;
}
- public ApplicationFetcher(final String pathAccountSid, final String pathSid){
+
+ public ApplicationFetcher(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
-
@Override
public Application fetch(final TwilioRestClient client) {
- String path = "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json";
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.GET,
@@ -56,15 +65,26 @@ public Application fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Application fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Application fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return Application.fromJson(response.getStream(), client.getObjectMapper());
+ return Application.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationReader.java b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationReader.java
index 32faae9780..0ca3bf5f0e 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationReader.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.api.v2010.account;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.exception.ApiConnectionException;
@@ -24,26 +25,25 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
-
-
public class ApplicationReader extends Reader {
+
private String pathAccountSid;
private String friendlyName;
private Integer pageSize;
- public ApplicationReader(){
- }
- public ApplicationReader(final String pathAccountSid){
+ public ApplicationReader() {}
+
+ public ApplicationReader(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
- public ApplicationReader setFriendlyName(final String friendlyName){
+ public ApplicationReader setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public ApplicationReader setPageSize(final Integer pageSize){
+
+ public ApplicationReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -55,8 +55,15 @@ public ResourceSet read(final TwilioRestClient client) {
public Page firstPage(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Applications.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -68,15 +75,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Application read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Application read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -90,7 +108,10 @@ private Page pageForRequest(final TwilioRestClient client, final Re
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.API.toString())
@@ -98,9 +119,11 @@ public Page previousPage(final Page page, final Twilio
return pageForRequest(client, request);
}
-
@Override
- public Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.API.toString())
@@ -109,25 +132,24 @@ public Page nextPage(final Page page, final TwilioRest
}
@Override
- public Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (friendlyName != null) {
-
request.addQueryParam("FriendlyName", friendlyName);
}
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationUpdater.java b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationUpdater.java
index 0ea2b6a657..22e599588d 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/ApplicationUpdater.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/ApplicationUpdater.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010.account;
import com.twilio.base.Updater;
+import com.twilio.constant.EnumConstants;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
@@ -24,12 +25,10 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
import java.net.URI;
+public class ApplicationUpdater extends Updater {
-
-public class ApplicationUpdater extends Updater{
private String pathSid;
private String pathAccountSid;
private String friendlyName;
@@ -49,198 +48,268 @@ public class ApplicationUpdater extends Updater{
private URI messageStatusCallback;
private Boolean publicApplicationConnectEnabled;
- public ApplicationUpdater(final String pathSid){
+ public ApplicationUpdater(final String pathSid) {
this.pathSid = pathSid;
}
- public ApplicationUpdater(final String pathAccountSid, final String pathSid){
+
+ public ApplicationUpdater(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
- public ApplicationUpdater setFriendlyName(final String friendlyName){
+ public ApplicationUpdater setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public ApplicationUpdater setApiVersion(final String apiVersion){
+
+ public ApplicationUpdater setApiVersion(final String apiVersion) {
this.apiVersion = apiVersion;
return this;
}
- public ApplicationUpdater setVoiceUrl(final URI voiceUrl){
+
+ public ApplicationUpdater setVoiceUrl(final URI voiceUrl) {
this.voiceUrl = voiceUrl;
return this;
}
- public ApplicationUpdater setVoiceUrl(final String voiceUrl){
+ public ApplicationUpdater setVoiceUrl(final String voiceUrl) {
return setVoiceUrl(Promoter.uriFromString(voiceUrl));
}
- public ApplicationUpdater setVoiceMethod(final HttpMethod voiceMethod){
+
+ public ApplicationUpdater setVoiceMethod(final HttpMethod voiceMethod) {
this.voiceMethod = voiceMethod;
return this;
}
- public ApplicationUpdater setVoiceFallbackUrl(final URI voiceFallbackUrl){
+
+ public ApplicationUpdater setVoiceFallbackUrl(final URI voiceFallbackUrl) {
this.voiceFallbackUrl = voiceFallbackUrl;
return this;
}
- public ApplicationUpdater setVoiceFallbackUrl(final String voiceFallbackUrl){
+ public ApplicationUpdater setVoiceFallbackUrl(
+ final String voiceFallbackUrl
+ ) {
return setVoiceFallbackUrl(Promoter.uriFromString(voiceFallbackUrl));
}
- public ApplicationUpdater setVoiceFallbackMethod(final HttpMethod voiceFallbackMethod){
+
+ public ApplicationUpdater setVoiceFallbackMethod(
+ final HttpMethod voiceFallbackMethod
+ ) {
this.voiceFallbackMethod = voiceFallbackMethod;
return this;
}
- public ApplicationUpdater setStatusCallback(final URI statusCallback){
+
+ public ApplicationUpdater setStatusCallback(final URI statusCallback) {
this.statusCallback = statusCallback;
return this;
}
- public ApplicationUpdater setStatusCallback(final String statusCallback){
+ public ApplicationUpdater setStatusCallback(final String statusCallback) {
return setStatusCallback(Promoter.uriFromString(statusCallback));
}
- public ApplicationUpdater setStatusCallbackMethod(final HttpMethod statusCallbackMethod){
+
+ public ApplicationUpdater setStatusCallbackMethod(
+ final HttpMethod statusCallbackMethod
+ ) {
this.statusCallbackMethod = statusCallbackMethod;
return this;
}
- public ApplicationUpdater setVoiceCallerIdLookup(final Boolean voiceCallerIdLookup){
+
+ public ApplicationUpdater setVoiceCallerIdLookup(
+ final Boolean voiceCallerIdLookup
+ ) {
this.voiceCallerIdLookup = voiceCallerIdLookup;
return this;
}
- public ApplicationUpdater setSmsUrl(final URI smsUrl){
+
+ public ApplicationUpdater setSmsUrl(final URI smsUrl) {
this.smsUrl = smsUrl;
return this;
}
- public ApplicationUpdater setSmsUrl(final String smsUrl){
+ public ApplicationUpdater setSmsUrl(final String smsUrl) {
return setSmsUrl(Promoter.uriFromString(smsUrl));
}
- public ApplicationUpdater setSmsMethod(final HttpMethod smsMethod){
+
+ public ApplicationUpdater setSmsMethod(final HttpMethod smsMethod) {
this.smsMethod = smsMethod;
return this;
}
- public ApplicationUpdater setSmsFallbackUrl(final URI smsFallbackUrl){
+
+ public ApplicationUpdater setSmsFallbackUrl(final URI smsFallbackUrl) {
this.smsFallbackUrl = smsFallbackUrl;
return this;
}
- public ApplicationUpdater setSmsFallbackUrl(final String smsFallbackUrl){
+ public ApplicationUpdater setSmsFallbackUrl(final String smsFallbackUrl) {
return setSmsFallbackUrl(Promoter.uriFromString(smsFallbackUrl));
}
- public ApplicationUpdater setSmsFallbackMethod(final HttpMethod smsFallbackMethod){
+
+ public ApplicationUpdater setSmsFallbackMethod(
+ final HttpMethod smsFallbackMethod
+ ) {
this.smsFallbackMethod = smsFallbackMethod;
return this;
}
- public ApplicationUpdater setSmsStatusCallback(final URI smsStatusCallback){
+
+ public ApplicationUpdater setSmsStatusCallback(
+ final URI smsStatusCallback
+ ) {
this.smsStatusCallback = smsStatusCallback;
return this;
}
- public ApplicationUpdater setSmsStatusCallback(final String smsStatusCallback){
+ public ApplicationUpdater setSmsStatusCallback(
+ final String smsStatusCallback
+ ) {
return setSmsStatusCallback(Promoter.uriFromString(smsStatusCallback));
}
- public ApplicationUpdater setMessageStatusCallback(final URI messageStatusCallback){
+
+ public ApplicationUpdater setMessageStatusCallback(
+ final URI messageStatusCallback
+ ) {
this.messageStatusCallback = messageStatusCallback;
return this;
}
- public ApplicationUpdater setMessageStatusCallback(final String messageStatusCallback){
- return setMessageStatusCallback(Promoter.uriFromString(messageStatusCallback));
+ public ApplicationUpdater setMessageStatusCallback(
+ final String messageStatusCallback
+ ) {
+ return setMessageStatusCallback(
+ Promoter.uriFromString(messageStatusCallback)
+ );
}
- public ApplicationUpdater setPublicApplicationConnectEnabled(final Boolean publicApplicationConnectEnabled){
+
+ public ApplicationUpdater setPublicApplicationConnectEnabled(
+ final Boolean publicApplicationConnectEnabled
+ ) {
this.publicApplicationConnectEnabled = publicApplicationConnectEnabled;
return this;
}
@Override
- public Application update(final TwilioRestClient client){
- String path = "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json";
+ public Application update(final TwilioRestClient client) {
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/Applications/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Application update failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Application update failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return Application.fromJson(response.getStream(), client.getObjectMapper());
+ return Application.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
+
private void addPostParams(final Request request) {
if (friendlyName != null) {
request.addPostParam("FriendlyName", friendlyName);
-
}
if (apiVersion != null) {
request.addPostParam("ApiVersion", apiVersion);
-
}
if (voiceUrl != null) {
request.addPostParam("VoiceUrl", voiceUrl.toString());
-
}
if (voiceMethod != null) {
request.addPostParam("VoiceMethod", voiceMethod.toString());
-
}
if (voiceFallbackUrl != null) {
- request.addPostParam("VoiceFallbackUrl", voiceFallbackUrl.toString());
-
+ request.addPostParam(
+ "VoiceFallbackUrl",
+ voiceFallbackUrl.toString()
+ );
}
if (voiceFallbackMethod != null) {
- request.addPostParam("VoiceFallbackMethod", voiceFallbackMethod.toString());
-
+ request.addPostParam(
+ "VoiceFallbackMethod",
+ voiceFallbackMethod.toString()
+ );
}
if (statusCallback != null) {
request.addPostParam("StatusCallback", statusCallback.toString());
-
}
if (statusCallbackMethod != null) {
- request.addPostParam("StatusCallbackMethod", statusCallbackMethod.toString());
-
+ request.addPostParam(
+ "StatusCallbackMethod",
+ statusCallbackMethod.toString()
+ );
}
if (voiceCallerIdLookup != null) {
- request.addPostParam("VoiceCallerIdLookup", voiceCallerIdLookup.toString());
-
+ request.addPostParam(
+ "VoiceCallerIdLookup",
+ voiceCallerIdLookup.toString()
+ );
}
if (smsUrl != null) {
request.addPostParam("SmsUrl", smsUrl.toString());
-
}
if (smsMethod != null) {
request.addPostParam("SmsMethod", smsMethod.toString());
-
}
if (smsFallbackUrl != null) {
request.addPostParam("SmsFallbackUrl", smsFallbackUrl.toString());
-
}
if (smsFallbackMethod != null) {
- request.addPostParam("SmsFallbackMethod", smsFallbackMethod.toString());
-
+ request.addPostParam(
+ "SmsFallbackMethod",
+ smsFallbackMethod.toString()
+ );
}
if (smsStatusCallback != null) {
- request.addPostParam("SmsStatusCallback", smsStatusCallback.toString());
-
+ request.addPostParam(
+ "SmsStatusCallback",
+ smsStatusCallback.toString()
+ );
}
if (messageStatusCallback != null) {
- request.addPostParam("MessageStatusCallback", messageStatusCallback.toString());
-
+ request.addPostParam(
+ "MessageStatusCallback",
+ messageStatusCallback.toString()
+ );
}
if (publicApplicationConnectEnabled != null) {
- request.addPostParam("PublicApplicationConnectEnabled", publicApplicationConnectEnabled.toString());
-
+ request.addPostParam(
+ "PublicApplicationConnectEnabled",
+ publicApplicationConnectEnabled.toString()
+ );
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectApp.java b/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectApp.java
index 59bef10218..f7e1d9f67f 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectApp.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectApp.java
@@ -21,51 +21,60 @@
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.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
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.ToString;
+import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class AuthorizedConnectApp extends Resource {
- private static final long serialVersionUID = 15094155294983L;
- public static AuthorizedConnectAppFetcher fetcher(final String pathConnectAppSid){
+ private static final long serialVersionUID = 156350222502843L;
+
+ public static AuthorizedConnectAppFetcher fetcher(
+ final String pathConnectAppSid
+ ) {
return new AuthorizedConnectAppFetcher(pathConnectAppSid);
}
- public static AuthorizedConnectAppFetcher fetcher(final String pathAccountSid, final String pathConnectAppSid){
- return new AuthorizedConnectAppFetcher(pathAccountSid, pathConnectAppSid);
+
+ public static AuthorizedConnectAppFetcher fetcher(
+ final String pathAccountSid,
+ final String pathConnectAppSid
+ ) {
+ return new AuthorizedConnectAppFetcher(
+ pathAccountSid,
+ pathConnectAppSid
+ );
}
- public static AuthorizedConnectAppReader reader(){
+ public static AuthorizedConnectAppReader reader() {
return new AuthorizedConnectAppReader();
}
- public static AuthorizedConnectAppReader reader(final String pathAccountSid){
+
+ public static AuthorizedConnectAppReader reader(
+ final String pathAccountSid
+ ) {
return new AuthorizedConnectAppReader(pathAccountSid);
}
/**
- * Converts a JSON String into a AuthorizedConnectApp object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return AuthorizedConnectApp object represented by the provided JSON
- */
- public static AuthorizedConnectApp fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a AuthorizedConnectApp object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return AuthorizedConnectApp object represented by the provided JSON
+ */
+ public static AuthorizedConnectApp fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, AuthorizedConnectApp.class);
@@ -77,14 +86,17 @@ public static AuthorizedConnectApp fromJson(final String json, final ObjectMappe
}
/**
- * Converts a JSON InputStream into a AuthorizedConnectApp object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return AuthorizedConnectApp object represented by the provided JSON
- */
- public static AuthorizedConnectApp fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a AuthorizedConnectApp object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return AuthorizedConnectApp object represented by the provided JSON
+ */
+ public static AuthorizedConnectApp fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, AuthorizedConnectApp.class);
@@ -94,25 +106,6 @@ public static AuthorizedConnectApp fromJson(final InputStream json, final Object
throw new ApiConnectionException(e.getMessage(), e);
}
}
- public enum Permission {
- GET_ALL("get-all"),
- POST_ALL("post-all");
-
- private final String value;
-
- private Permission(final String value) {
- this.value = value;
- }
-
- public String toString() {
- return value;
- }
-
- @JsonCreator
- public static Permission forValue(final String value) {
- return Promoter.enumFromString(value, Permission.values());
- }
- }
private final String accountSid;
private final String connectAppCompanyName;
@@ -120,42 +113,29 @@ public static Permission forValue(final String value) {
private final String connectAppFriendlyName;
private final URI connectAppHomepageUrl;
private final String connectAppSid;
- private final ZonedDateTime dateCreated;
- private final ZonedDateTime dateUpdated;
private final List permissions;
private final String uri;
@JsonCreator
private AuthorizedConnectApp(
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("connect_app_company_name")
- final String connectAppCompanyName,
-
- @JsonProperty("connect_app_description")
- final String connectAppDescription,
-
- @JsonProperty("connect_app_friendly_name")
- final String connectAppFriendlyName,
-
- @JsonProperty("connect_app_homepage_url")
- final URI connectAppHomepageUrl,
-
- @JsonProperty("connect_app_sid")
- final String connectAppSid,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("permissions")
- final List permissions,
-
- @JsonProperty("uri")
- final String uri
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty(
+ "connect_app_company_name"
+ ) final String connectAppCompanyName,
+ @JsonProperty(
+ "connect_app_description"
+ ) final String connectAppDescription,
+ @JsonProperty(
+ "connect_app_friendly_name"
+ ) final String connectAppFriendlyName,
+ @JsonProperty(
+ "connect_app_homepage_url"
+ ) final URI connectAppHomepageUrl,
+ @JsonProperty("connect_app_sid") final String connectAppSid,
+ @JsonProperty("permissions") final List<
+ AuthorizedConnectApp.Permission
+ > permissions,
+ @JsonProperty("uri") final String uri
) {
this.accountSid = accountSid;
this.connectAppCompanyName = connectAppCompanyName;
@@ -163,46 +143,45 @@ private AuthorizedConnectApp(
this.connectAppFriendlyName = connectAppFriendlyName;
this.connectAppHomepageUrl = connectAppHomepageUrl;
this.connectAppSid = connectAppSid;
- this.dateCreated = DateConverter.rfc2822DateTimeFromString(dateCreated);
- this.dateUpdated = DateConverter.rfc2822DateTimeFromString(dateUpdated);
this.permissions = permissions;
this.uri = uri;
}
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getConnectAppCompanyName() {
- return this.connectAppCompanyName;
- }
- public final String getConnectAppDescription() {
- return this.connectAppDescription;
- }
- public final String getConnectAppFriendlyName() {
- return this.connectAppFriendlyName;
- }
- public final URI getConnectAppHomepageUrl() {
- return this.connectAppHomepageUrl;
- }
- public final String getConnectAppSid() {
- return this.connectAppSid;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final List getPermissions() {
- return this.permissions;
- }
- public final String getUri() {
- return this.uri;
- }
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getConnectAppCompanyName() {
+ return this.connectAppCompanyName;
+ }
+
+ public final String getConnectAppDescription() {
+ return this.connectAppDescription;
+ }
+
+ public final String getConnectAppFriendlyName() {
+ return this.connectAppFriendlyName;
+ }
+
+ public final URI getConnectAppHomepageUrl() {
+ return this.connectAppHomepageUrl;
+ }
+
+ public final String getConnectAppSid() {
+ return this.connectAppSid;
+ }
+
+ public final List getPermissions() {
+ return this.permissions;
+ }
+
+ public final String getUri() {
+ return this.uri;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -212,13 +191,61 @@ public boolean equals(final Object o) {
AuthorizedConnectApp other = (AuthorizedConnectApp) o;
- return Objects.equals(accountSid, other.accountSid) && Objects.equals(connectAppCompanyName, other.connectAppCompanyName) && Objects.equals(connectAppDescription, other.connectAppDescription) && Objects.equals(connectAppFriendlyName, other.connectAppFriendlyName) && Objects.equals(connectAppHomepageUrl, other.connectAppHomepageUrl) && Objects.equals(connectAppSid, other.connectAppSid) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(permissions, other.permissions) && Objects.equals(uri, other.uri) ;
+ return (
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(
+ connectAppCompanyName,
+ other.connectAppCompanyName
+ ) &&
+ Objects.equals(
+ connectAppDescription,
+ other.connectAppDescription
+ ) &&
+ Objects.equals(
+ connectAppFriendlyName,
+ other.connectAppFriendlyName
+ ) &&
+ Objects.equals(
+ connectAppHomepageUrl,
+ other.connectAppHomepageUrl
+ ) &&
+ Objects.equals(connectAppSid, other.connectAppSid) &&
+ Objects.equals(permissions, other.permissions) &&
+ Objects.equals(uri, other.uri)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(accountSid, connectAppCompanyName, connectAppDescription, connectAppFriendlyName, connectAppHomepageUrl, connectAppSid, dateCreated, dateUpdated, permissions, uri);
+ return Objects.hash(
+ accountSid,
+ connectAppCompanyName,
+ connectAppDescription,
+ connectAppFriendlyName,
+ connectAppHomepageUrl,
+ connectAppSid,
+ permissions,
+ uri
+ );
}
-}
+ public enum Permission {
+ GET_ALL("get-all"),
+ POST_ALL("post-all");
+
+ private final String value;
+
+ private Permission(final String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return value;
+ }
+ @JsonCreator
+ public static Permission forValue(final String value) {
+ return Promoter.enumFromString(value, Permission.values());
+ }
+ }
+}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppFetcher.java b/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppFetcher.java
index 52cab1ba2c..43527c0fa6 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppFetcher.java
@@ -24,29 +24,42 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class AuthorizedConnectAppFetcher extends Fetcher {
+
private String pathConnectAppSid;
private String pathAccountSid;
- public AuthorizedConnectAppFetcher(final String pathConnectAppSid){
+ public AuthorizedConnectAppFetcher(final String pathConnectAppSid) {
this.pathConnectAppSid = pathConnectAppSid;
}
- public AuthorizedConnectAppFetcher(final String pathAccountSid, final String pathConnectAppSid){
+
+ public AuthorizedConnectAppFetcher(
+ final String pathAccountSid,
+ final String pathConnectAppSid
+ ) {
this.pathAccountSid = pathAccountSid;
this.pathConnectAppSid = pathConnectAppSid;
}
-
@Override
public AuthorizedConnectApp fetch(final TwilioRestClient client) {
- String path = "/2010-04-01/Accounts/{AccountSid}/AuthorizedConnectApps/{ConnectAppSid}.json";
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/AuthorizedConnectApps/{ConnectAppSid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"ConnectAppSid"+"}", this.pathConnectAppSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path =
+ path.replace(
+ "{" + "ConnectAppSid" + "}",
+ this.pathConnectAppSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -56,15 +69,26 @@ public AuthorizedConnectApp fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("AuthorizedConnectApp fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "AuthorizedConnectApp fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return AuthorizedConnectApp.fromJson(response.getStream(), client.getObjectMapper());
+ return AuthorizedConnectApp.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppReader.java b/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppReader.java
index 8a9689a949..2a7559e070 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppReader.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AuthorizedConnectAppReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.api.v2010.account;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.exception.ApiConnectionException;
@@ -24,34 +25,42 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
-
-
public class AuthorizedConnectAppReader extends Reader {
+
private String pathAccountSid;
private Integer pageSize;
- public AuthorizedConnectAppReader(){
- }
- public AuthorizedConnectAppReader(final String pathAccountSid){
+ public AuthorizedConnectAppReader() {}
+
+ public AuthorizedConnectAppReader(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
- public AuthorizedConnectAppReader setPageSize(final Integer pageSize){
+ public AuthorizedConnectAppReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@Override
- public ResourceSet read(final TwilioRestClient client) {
+ public ResourceSet read(
+ final TwilioRestClient client
+ ) {
return new ResourceSet<>(this, client, firstPage(client));
}
public Page firstPage(final TwilioRestClient client) {
- String path = "/2010-04-01/Accounts/{AccountSid}/AuthorizedConnectApps.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/AuthorizedConnectApps.json";
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -63,15 +72,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("AuthorizedConnectApp read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "AuthorizedConnectApp read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -85,7 +105,10 @@ private Page pageForRequest(final TwilioRestClient client,
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.API.toString())
@@ -93,9 +116,11 @@ public Page previousPage(final Page
return pageForRequest(client, request);
}
-
@Override
- public Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.API.toString())
@@ -104,21 +129,21 @@ public Page nextPage(final Page page
}
@Override
- public Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountry.java b/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountry.java
index a00fa4be8b..9e27b5176b 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountry.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountry.java
@@ -22,51 +22,65 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.twilio.base.Resource;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-
import java.util.Map;
-import java.util.Objects;
-
-
import java.util.Map;
+import java.util.Objects;
+import lombok.ToString;
+import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class AvailablePhoneNumberCountry extends Resource {
+
private static final long serialVersionUID = 173167903952303L;
- public static AvailablePhoneNumberCountryFetcher fetcher(final String pathCountryCode){
+ public static AvailablePhoneNumberCountryFetcher fetcher(
+ final String pathCountryCode
+ ) {
return new AvailablePhoneNumberCountryFetcher(pathCountryCode);
}
- public static AvailablePhoneNumberCountryFetcher fetcher(final String pathAccountSid, final String pathCountryCode){
- return new AvailablePhoneNumberCountryFetcher(pathAccountSid, pathCountryCode);
+
+ public static AvailablePhoneNumberCountryFetcher fetcher(
+ final String pathAccountSid,
+ final String pathCountryCode
+ ) {
+ return new AvailablePhoneNumberCountryFetcher(
+ pathAccountSid,
+ pathCountryCode
+ );
}
- public static AvailablePhoneNumberCountryReader reader(){
+ public static AvailablePhoneNumberCountryReader reader() {
return new AvailablePhoneNumberCountryReader();
}
- public static AvailablePhoneNumberCountryReader reader(final String pathAccountSid){
+
+ public static AvailablePhoneNumberCountryReader reader(
+ final String pathAccountSid
+ ) {
return new AvailablePhoneNumberCountryReader(pathAccountSid);
}
/**
- * Converts a JSON String into a AvailablePhoneNumberCountry object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return AvailablePhoneNumberCountry object represented by the provided JSON
- */
- public static AvailablePhoneNumberCountry fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a AvailablePhoneNumberCountry object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return AvailablePhoneNumberCountry object represented by the provided JSON
+ */
+ public static AvailablePhoneNumberCountry fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
- return objectMapper.readValue(json, AvailablePhoneNumberCountry.class);
+ return objectMapper.readValue(
+ json,
+ AvailablePhoneNumberCountry.class
+ );
} catch (final JsonMappingException | JsonParseException e) {
throw new ApiException(e.getMessage(), e);
} catch (final IOException e) {
@@ -75,17 +89,23 @@ public static AvailablePhoneNumberCountry fromJson(final String json, final Obje
}
/**
- * Converts a JSON InputStream into a AvailablePhoneNumberCountry object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return AvailablePhoneNumberCountry object represented by the provided JSON
- */
- public static AvailablePhoneNumberCountry fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a AvailablePhoneNumberCountry object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return AvailablePhoneNumberCountry object represented by the provided JSON
+ */
+ public static AvailablePhoneNumberCountry fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
- return objectMapper.readValue(json, AvailablePhoneNumberCountry.class);
+ return objectMapper.readValue(
+ json,
+ AvailablePhoneNumberCountry.class
+ );
} catch (final JsonMappingException | JsonParseException e) {
throw new ApiException(e.getMessage(), e);
} catch (final IOException e) {
@@ -101,20 +121,14 @@ public static AvailablePhoneNumberCountry fromJson(final InputStream json, final
@JsonCreator
private AvailablePhoneNumberCountry(
- @JsonProperty("country_code")
- final String countryCode,
-
- @JsonProperty("country")
- final String country,
-
- @JsonProperty("uri")
- final URI uri,
-
- @JsonProperty("beta")
- final Boolean beta,
-
- @JsonProperty("subresource_uris")
- final Map subresourceUris
+ @JsonProperty("country_code") final String countryCode,
+ @JsonProperty("country") final String country,
+ @JsonProperty("uri") final URI uri,
+ @JsonProperty("beta") final Boolean beta,
+ @JsonProperty("subresource_uris") final Map<
+ String,
+ String
+ > subresourceUris
) {
this.countryCode = countryCode;
this.country = country;
@@ -123,25 +137,29 @@ private AvailablePhoneNumberCountry(
this.subresourceUris = subresourceUris;
}
- public final String getCountryCode() {
- return this.countryCode;
- }
- public final String getCountry() {
- return this.country;
- }
- public final URI getUri() {
- return this.uri;
- }
- public final Boolean getBeta() {
- return this.beta;
- }
- public final Map getSubresourceUris() {
- return this.subresourceUris;
- }
+ public final String getCountryCode() {
+ return this.countryCode;
+ }
+
+ public final String getCountry() {
+ return this.country;
+ }
+
+ public final URI getUri() {
+ return this.uri;
+ }
+
+ public final Boolean getBeta() {
+ return this.beta;
+ }
+
+ public final Map getSubresourceUris() {
+ return this.subresourceUris;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -151,13 +169,17 @@ public boolean equals(final Object o) {
AvailablePhoneNumberCountry other = (AvailablePhoneNumberCountry) o;
- return Objects.equals(countryCode, other.countryCode) && Objects.equals(country, other.country) && Objects.equals(uri, other.uri) && Objects.equals(beta, other.beta) && Objects.equals(subresourceUris, other.subresourceUris) ;
+ return (
+ Objects.equals(countryCode, other.countryCode) &&
+ Objects.equals(country, other.country) &&
+ Objects.equals(uri, other.uri) &&
+ Objects.equals(beta, other.beta) &&
+ Objects.equals(subresourceUris, other.subresourceUris)
+ );
}
@Override
public int hashCode() {
return Objects.hash(countryCode, country, uri, beta, subresourceUris);
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryFetcher.java b/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryFetcher.java
index 174a722f63..f6033df965 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryFetcher.java
@@ -24,29 +24,43 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
+public class AvailablePhoneNumberCountryFetcher
+ extends Fetcher {
-
-
-public class AvailablePhoneNumberCountryFetcher extends Fetcher {
private String pathCountryCode;
private String pathAccountSid;
- public AvailablePhoneNumberCountryFetcher(final String pathCountryCode){
+ public AvailablePhoneNumberCountryFetcher(final String pathCountryCode) {
this.pathCountryCode = pathCountryCode;
}
- public AvailablePhoneNumberCountryFetcher(final String pathAccountSid, final String pathCountryCode){
+
+ public AvailablePhoneNumberCountryFetcher(
+ final String pathAccountSid,
+ final String pathCountryCode
+ ) {
this.pathAccountSid = pathAccountSid;
this.pathCountryCode = pathCountryCode;
}
-
@Override
public AvailablePhoneNumberCountry fetch(final TwilioRestClient client) {
- String path = "/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{CountryCode}.json";
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{CountryCode}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"CountryCode"+"}", this.pathCountryCode.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path =
+ path.replace(
+ "{" + "CountryCode" + "}",
+ this.pathCountryCode.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -56,15 +70,26 @@ public AvailablePhoneNumberCountry fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("AvailablePhoneNumberCountry fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "AvailablePhoneNumberCountry fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return AvailablePhoneNumberCountry.fromJson(response.getStream(), client.getObjectMapper());
+ return AvailablePhoneNumberCountry.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryReader.java b/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryReader.java
index 35ca49e4fd..d78f21b5e5 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryReader.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/AvailablePhoneNumberCountryReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.api.v2010.account;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.exception.ApiConnectionException;
@@ -24,34 +25,47 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
-
+public class AvailablePhoneNumberCountryReader
+ extends Reader {
-public class AvailablePhoneNumberCountryReader extends Reader {
private String pathAccountSid;
private Integer pageSize;
- public AvailablePhoneNumberCountryReader(){
- }
- public AvailablePhoneNumberCountryReader(final String pathAccountSid){
+ public AvailablePhoneNumberCountryReader() {}
+
+ public AvailablePhoneNumberCountryReader(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
- public AvailablePhoneNumberCountryReader setPageSize(final Integer pageSize){
+ public AvailablePhoneNumberCountryReader setPageSize(
+ final Integer pageSize
+ ) {
this.pageSize = pageSize;
return this;
}
@Override
- public ResourceSet read(final TwilioRestClient client) {
+ public ResourceSet read(
+ final TwilioRestClient client
+ ) {
return new ResourceSet<>(this, client, firstPage(client));
}
- public Page firstPage(final TwilioRestClient client) {
- String path = "/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ public Page firstPage(
+ final TwilioRestClient client
+ ) {
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers.json";
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -63,15 +77,26 @@ public Page firstPage(final TwilioRestClient client
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("AvailablePhoneNumberCountry read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "AvailablePhoneNumberCountry read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -85,7 +110,10 @@ private Page pageForRequest(final TwilioRestClient
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.API.toString())
@@ -93,9 +121,11 @@ public Page previousPage(final Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.API.toString())
@@ -104,21 +134,21 @@ public Page nextPage(final Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/Balance.java b/src/main/java/com/twilio/rest/api/v2010/account/Balance.java
index 6c39004801..5fb120031a 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/Balance.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/Balance.java
@@ -22,38 +22,38 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.twilio.base.Resource;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
import java.io.IOException;
import java.io.InputStream;
-
import java.util.Objects;
-
-
+import lombok.ToString;
+import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class Balance extends Resource {
+
private static final long serialVersionUID = 101388429668677L;
- public static BalanceFetcher fetcher(){
+ public static BalanceFetcher fetcher() {
return new BalanceFetcher();
}
- public static BalanceFetcher fetcher(final String pathAccountSid){
+
+ public static BalanceFetcher fetcher(final String pathAccountSid) {
return new BalanceFetcher(pathAccountSid);
}
/**
- * Converts a JSON String into a Balance object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return Balance object represented by the provided JSON
- */
- public static Balance fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a Balance object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Balance object represented by the provided JSON
+ */
+ public static Balance fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Balance.class);
@@ -65,14 +65,17 @@ public static Balance fromJson(final String json, final ObjectMapper objectMappe
}
/**
- * Converts a JSON InputStream into a Balance object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return Balance object represented by the provided JSON
- */
- public static Balance fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a Balance object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Balance object represented by the provided JSON
+ */
+ public static Balance fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Balance.class);
@@ -89,33 +92,30 @@ public static Balance fromJson(final InputStream json, final ObjectMapper object
@JsonCreator
private Balance(
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("balance")
- final String balance,
-
- @JsonProperty("currency")
- final String currency
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("balance") final String balance,
+ @JsonProperty("currency") final String currency
) {
this.accountSid = accountSid;
this.balance = balance;
this.currency = currency;
}
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getBalance() {
- return this.balance;
- }
- public final String getCurrency() {
- return this.currency;
- }
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getBalance() {
+ return this.balance;
+ }
+
+ public final String getCurrency() {
+ return this.currency;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -125,13 +125,15 @@ public boolean equals(final Object o) {
Balance other = (Balance) o;
- return Objects.equals(accountSid, other.accountSid) && Objects.equals(balance, other.balance) && Objects.equals(currency, other.currency) ;
+ return (
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(balance, other.balance) &&
+ Objects.equals(currency, other.currency)
+ );
}
@Override
public int hashCode() {
return Objects.hash(accountSid, balance, currency);
}
-
}
-
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/BalanceFetcher.java b/src/main/java/com/twilio/rest/api/v2010/account/BalanceFetcher.java
index 5bda0ea981..6dc769dc11 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/BalanceFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/BalanceFetcher.java
@@ -24,25 +24,29 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class BalanceFetcher extends Fetcher {
+
private String pathAccountSid;
- public BalanceFetcher(){
- }
- public BalanceFetcher(final String pathAccountSid){
+ public BalanceFetcher() {}
+
+ public BalanceFetcher(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
-
@Override
public Balance fetch(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Balance.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -52,11 +56,19 @@ public Balance fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Balance fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Balance fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/Call.java b/src/main/java/com/twilio/rest/api/v2010/account/Call.java
index 69ebce2825..4f327b8bb6 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/Call.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/Call.java
@@ -20,89 +20,133 @@
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.twilio.base.Resource;
-import java.util.Currency;
+import com.twilio.converter.CurrencyDeserializer;
import com.twilio.converter.DateConverter;
import com.twilio.converter.Promoter;
-import com.twilio.converter.CurrencyDeserializer;
import com.twilio.exception.ApiConnectionException;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.time.ZonedDateTime;
-
+import java.util.Currency;
import java.util.Map;
-import java.util.Objects;
-
-
import java.util.Map;
+import java.util.Objects;
+import lombok.ToString;
+import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class Call extends Resource {
+
private static final long serialVersionUID = 229062317637234L;
- public static CallCreator creator(final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final URI url){
+ public static CallCreator creator(
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final URI url
+ ) {
return new CallCreator(to, from, url);
}
- public static CallCreator creator(final String pathAccountSid, final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final URI url){
+
+ public static CallCreator creator(
+ final String pathAccountSid,
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final URI url
+ ) {
return new CallCreator(pathAccountSid, to, from, url);
}
- public static CallCreator creator(final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final com.twilio.type.Twiml twiml){
+
+ public static CallCreator creator(
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final com.twilio.type.Twiml twiml
+ ) {
return new CallCreator(to, from, twiml);
}
- public static CallCreator creator(final String pathAccountSid, final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final com.twilio.type.Twiml twiml){
+
+ public static CallCreator creator(
+ final String pathAccountSid,
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final com.twilio.type.Twiml twiml
+ ) {
return new CallCreator(pathAccountSid, to, from, twiml);
}
- public static CallCreator creator(final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final String applicationSid){
+
+ public static CallCreator creator(
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final String applicationSid
+ ) {
return new CallCreator(to, from, applicationSid);
}
- public static CallCreator creator(final String pathAccountSid, final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final String applicationSid){
+
+ public static CallCreator creator(
+ final String pathAccountSid,
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final String applicationSid
+ ) {
return new CallCreator(pathAccountSid, to, from, applicationSid);
}
- public static CallDeleter deleter(final String pathSid){
+ public static CallDeleter deleter(final String pathSid) {
return new CallDeleter(pathSid);
}
- public static CallDeleter deleter(final String pathAccountSid, final String pathSid){
+
+ public static CallDeleter deleter(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new CallDeleter(pathAccountSid, pathSid);
}
- public static CallFetcher fetcher(final String pathSid){
+ public static CallFetcher fetcher(final String pathSid) {
return new CallFetcher(pathSid);
}
- public static CallFetcher fetcher(final String pathAccountSid, final String pathSid){
+
+ public static CallFetcher fetcher(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new CallFetcher(pathAccountSid, pathSid);
}
- public static CallReader reader(){
+ public static CallReader reader() {
return new CallReader();
}
- public static CallReader reader(final String pathAccountSid){
+
+ public static CallReader reader(final String pathAccountSid) {
return new CallReader(pathAccountSid);
}
- public static CallUpdater updater(final String pathSid){
+ public static CallUpdater updater(final String pathSid) {
return new CallUpdater(pathSid);
}
- public static CallUpdater updater(final String pathAccountSid, final String pathSid){
+
+ public static CallUpdater updater(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new CallUpdater(pathAccountSid, pathSid);
}
/**
- * Converts a JSON String into a Call object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return Call object represented by the provided JSON
- */
- public static Call fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a Call object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Call object represented by the provided JSON
+ */
+ public static Call fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Call.class);
@@ -114,14 +158,17 @@ public static Call fromJson(final String json, final ObjectMapper objectMapper)
}
/**
- * Converts a JSON InputStream into a Call object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return Call object represented by the provided JSON
- */
- public static Call fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a Call object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Call object represented by the provided JSON
+ */
+ public static Call fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Call.class);
@@ -131,31 +178,7 @@ public static Call fromJson(final InputStream json, final ObjectMapper objectMap
throw new ApiConnectionException(e.getMessage(), e);
}
}
- public enum Status {
- QUEUED("queued"),
- RINGING("ringing"),
- IN_PROGRESS("in-progress"),
- COMPLETED("completed"),
- BUSY("busy"),
- FAILED("failed"),
- NO_ANSWER("no-answer"),
- CANCELED("canceled");
- private final String value;
-
- private Status(final String value) {
- this.value = value;
- }
-
- public String toString() {
- return value;
- }
-
- @JsonCreator
- public static Status forValue(final String value) {
- return Promoter.enumFromString(value, Status.values());
- }
- }
public enum UpdateStatus {
CANCELED("canceled"),
COMPLETED("completed");
@@ -205,84 +228,37 @@ public static UpdateStatus forValue(final String value) {
@JsonCreator
private Call(
- @JsonProperty("sid")
- final String sid,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("parent_call_sid")
- final String parentCallSid,
-
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("to")
- final String to,
-
- @JsonProperty("to_formatted")
- final String toFormatted,
-
- @JsonProperty("from")
- final String from,
-
- @JsonProperty("from_formatted")
- final String fromFormatted,
-
- @JsonProperty("phone_number_sid")
- final String phoneNumberSid,
-
- @JsonProperty("status")
- final Call.Status status,
-
- @JsonProperty("start_time")
- final String startTime,
-
- @JsonProperty("end_time")
- final String endTime,
-
- @JsonProperty("duration")
- final String duration,
-
- @JsonProperty("price")
- final String price,
-
- @JsonProperty("price_unit")
- @JsonDeserialize(using = com.twilio.converter.CurrencyDeserializer.class)
- final Currency priceUnit,
-
- @JsonProperty("direction")
- final String direction,
-
- @JsonProperty("answered_by")
- final String answeredBy,
-
- @JsonProperty("api_version")
- final String apiVersion,
-
- @JsonProperty("forwarded_from")
- final String forwardedFrom,
-
- @JsonProperty("group_sid")
- final String groupSid,
-
- @JsonProperty("caller_name")
- final String callerName,
-
- @JsonProperty("queue_time")
- final String queueTime,
-
- @JsonProperty("trunk_sid")
- final String trunkSid,
-
- @JsonProperty("uri")
- final String uri,
-
- @JsonProperty("subresource_uris")
- final Map subresourceUris
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("parent_call_sid") final String parentCallSid,
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("to") final String to,
+ @JsonProperty("to_formatted") final String toFormatted,
+ @JsonProperty("from") final String from,
+ @JsonProperty("from_formatted") final String fromFormatted,
+ @JsonProperty("phone_number_sid") final String phoneNumberSid,
+ @JsonProperty("status") final Call.Status status,
+ @JsonProperty("start_time") final String startTime,
+ @JsonProperty("end_time") final String endTime,
+ @JsonProperty("duration") final String duration,
+ @JsonProperty("price") final String price,
+ @JsonProperty("price_unit") @JsonDeserialize(
+ using = com.twilio.converter.CurrencyDeserializer.class
+ ) final Currency priceUnit,
+ @JsonProperty("direction") final String direction,
+ @JsonProperty("answered_by") final String answeredBy,
+ @JsonProperty("api_version") final String apiVersion,
+ @JsonProperty("forwarded_from") final String forwardedFrom,
+ @JsonProperty("group_sid") final String groupSid,
+ @JsonProperty("caller_name") final String callerName,
+ @JsonProperty("queue_time") final String queueTime,
+ @JsonProperty("trunk_sid") final String trunkSid,
+ @JsonProperty("uri") final String uri,
+ @JsonProperty("subresource_uris") final Map<
+ String,
+ String
+ > subresourceUris
) {
this.sid = sid;
this.dateCreated = DateConverter.rfc2822DateTimeFromString(dateCreated);
@@ -312,88 +288,113 @@ private Call(
this.subresourceUris = subresourceUris;
}
- public final String getSid() {
- return this.sid;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final String getParentCallSid() {
- return this.parentCallSid;
- }
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final String getTo() {
- return this.to;
- }
- public final String getToFormatted() {
- return this.toFormatted;
- }
- public final String getFrom() {
- return this.from;
- }
- public final String getFromFormatted() {
- return this.fromFormatted;
- }
- public final String getPhoneNumberSid() {
- return this.phoneNumberSid;
- }
- public final Call.Status getStatus() {
- return this.status;
- }
- public final ZonedDateTime getStartTime() {
- return this.startTime;
- }
- public final ZonedDateTime getEndTime() {
- return this.endTime;
- }
- public final String getDuration() {
- return this.duration;
- }
- public final String getPrice() {
- return this.price;
- }
- public final Currency getPriceUnit() {
- return this.priceUnit;
- }
- public final String getDirection() {
- return this.direction;
- }
- public final String getAnsweredBy() {
- return this.answeredBy;
- }
- public final String getApiVersion() {
- return this.apiVersion;
- }
- public final String getForwardedFrom() {
- return this.forwardedFrom;
- }
- public final String getGroupSid() {
- return this.groupSid;
- }
- public final String getCallerName() {
- return this.callerName;
- }
- public final String getQueueTime() {
- return this.queueTime;
- }
- public final String getTrunkSid() {
- return this.trunkSid;
- }
- public final String getUri() {
- return this.uri;
- }
- public final Map getSubresourceUris() {
- return this.subresourceUris;
- }
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final String getParentCallSid() {
+ return this.parentCallSid;
+ }
+
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final String getTo() {
+ return this.to;
+ }
+
+ public final String getToFormatted() {
+ return this.toFormatted;
+ }
+
+ public final String getFrom() {
+ return this.from;
+ }
+
+ public final String getFromFormatted() {
+ return this.fromFormatted;
+ }
+
+ public final String getPhoneNumberSid() {
+ return this.phoneNumberSid;
+ }
+
+ public final Call.Status getStatus() {
+ return this.status;
+ }
+
+ public final ZonedDateTime getStartTime() {
+ return this.startTime;
+ }
+
+ public final ZonedDateTime getEndTime() {
+ return this.endTime;
+ }
+
+ public final String getDuration() {
+ return this.duration;
+ }
+
+ public final String getPrice() {
+ return this.price;
+ }
+
+ public final Currency getPriceUnit() {
+ return this.priceUnit;
+ }
+
+ public final String getDirection() {
+ return this.direction;
+ }
+
+ public final String getAnsweredBy() {
+ return this.answeredBy;
+ }
+
+ public final String getApiVersion() {
+ return this.apiVersion;
+ }
+
+ public final String getForwardedFrom() {
+ return this.forwardedFrom;
+ }
+
+ public final String getGroupSid() {
+ return this.groupSid;
+ }
+
+ public final String getCallerName() {
+ return this.callerName;
+ }
+
+ public final String getQueueTime() {
+ return this.queueTime;
+ }
+
+ public final String getTrunkSid() {
+ return this.trunkSid;
+ }
+
+ public final String getUri() {
+ return this.uri;
+ }
+
+ public final Map getSubresourceUris() {
+ return this.subresourceUris;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -403,13 +404,91 @@ public boolean equals(final Object o) {
Call other = (Call) o;
- return Objects.equals(sid, other.sid) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(parentCallSid, other.parentCallSid) && Objects.equals(accountSid, other.accountSid) && Objects.equals(to, other.to) && Objects.equals(toFormatted, other.toFormatted) && Objects.equals(from, other.from) && Objects.equals(fromFormatted, other.fromFormatted) && Objects.equals(phoneNumberSid, other.phoneNumberSid) && Objects.equals(status, other.status) && Objects.equals(startTime, other.startTime) && Objects.equals(endTime, other.endTime) && Objects.equals(duration, other.duration) && Objects.equals(price, other.price) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(direction, other.direction) && Objects.equals(answeredBy, other.answeredBy) && Objects.equals(apiVersion, other.apiVersion) && Objects.equals(forwardedFrom, other.forwardedFrom) && Objects.equals(groupSid, other.groupSid) && Objects.equals(callerName, other.callerName) && Objects.equals(queueTime, other.queueTime) && Objects.equals(trunkSid, other.trunkSid) && Objects.equals(uri, other.uri) && Objects.equals(subresourceUris, other.subresourceUris) ;
+ return (
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(parentCallSid, other.parentCallSid) &&
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(to, other.to) &&
+ Objects.equals(toFormatted, other.toFormatted) &&
+ Objects.equals(from, other.from) &&
+ Objects.equals(fromFormatted, other.fromFormatted) &&
+ Objects.equals(phoneNumberSid, other.phoneNumberSid) &&
+ Objects.equals(status, other.status) &&
+ Objects.equals(startTime, other.startTime) &&
+ Objects.equals(endTime, other.endTime) &&
+ Objects.equals(duration, other.duration) &&
+ Objects.equals(price, other.price) &&
+ Objects.equals(priceUnit, other.priceUnit) &&
+ Objects.equals(direction, other.direction) &&
+ Objects.equals(answeredBy, other.answeredBy) &&
+ Objects.equals(apiVersion, other.apiVersion) &&
+ Objects.equals(forwardedFrom, other.forwardedFrom) &&
+ Objects.equals(groupSid, other.groupSid) &&
+ Objects.equals(callerName, other.callerName) &&
+ Objects.equals(queueTime, other.queueTime) &&
+ Objects.equals(trunkSid, other.trunkSid) &&
+ Objects.equals(uri, other.uri) &&
+ Objects.equals(subresourceUris, other.subresourceUris)
+ );
}
@Override
public int hashCode() {
- return Objects.hash(sid, dateCreated, dateUpdated, parentCallSid, accountSid, to, toFormatted, from, fromFormatted, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, groupSid, callerName, queueTime, trunkSid, uri, subresourceUris);
+ return Objects.hash(
+ sid,
+ dateCreated,
+ dateUpdated,
+ parentCallSid,
+ accountSid,
+ to,
+ toFormatted,
+ from,
+ fromFormatted,
+ phoneNumberSid,
+ status,
+ startTime,
+ endTime,
+ duration,
+ price,
+ priceUnit,
+ direction,
+ answeredBy,
+ apiVersion,
+ forwardedFrom,
+ groupSid,
+ callerName,
+ queueTime,
+ trunkSid,
+ uri,
+ subresourceUris
+ );
}
-}
+ public enum Status {
+ QUEUED("queued"),
+ RINGING("ringing"),
+ IN_PROGRESS("in-progress"),
+ COMPLETED("completed"),
+ BUSY("busy"),
+ FAILED("failed"),
+ NO_ANSWER("no-answer"),
+ CANCELED("canceled");
+
+ private final String value;
+ private Status(final String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return value;
+ }
+
+ @JsonCreator
+ public static Status forValue(final String value) {
+ return Promoter.enumFromString(value, Status.values());
+ }
+ }
+}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java b/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java
index 555c8b58fa..a1eb6dc461 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010.account;
import com.twilio.base.Creator;
+import com.twilio.constant.EnumConstants;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
@@ -24,15 +25,13 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import java.util.List;
import java.net.URI;
-
+import java.net.URI;
+import java.util.List;
import java.util.List;
+public class CallCreator extends Creator {
-import java.net.URI;
-
-public class CallCreator extends Creator{
private com.twilio.type.Endpoint to;
private com.twilio.type.Endpoint from;
private String pathAccountSid;
@@ -70,379 +69,489 @@ public class CallCreator extends Creator{
private com.twilio.type.Twiml twiml;
private String applicationSid;
- public CallCreator(final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final URI url) {
+ public CallCreator(
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final URI url
+ ) {
this.to = to;
this.from = from;
this.url = url;
}
- public CallCreator(final String pathAccountSid, final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final URI url) {
+
+ public CallCreator(
+ final String pathAccountSid,
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final URI url
+ ) {
this.pathAccountSid = pathAccountSid;
this.to = to;
this.from = from;
this.url = url;
}
- public CallCreator(final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final com.twilio.type.Twiml twiml) {
+
+ public CallCreator(
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final com.twilio.type.Twiml twiml
+ ) {
this.to = to;
this.from = from;
this.twiml = twiml;
}
- public CallCreator(final String pathAccountSid, final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final com.twilio.type.Twiml twiml) {
+
+ public CallCreator(
+ final String pathAccountSid,
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final com.twilio.type.Twiml twiml
+ ) {
this.pathAccountSid = pathAccountSid;
this.to = to;
this.from = from;
this.twiml = twiml;
}
- public CallCreator(final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final String applicationSid) {
+
+ public CallCreator(
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final String applicationSid
+ ) {
this.to = to;
this.from = from;
this.applicationSid = applicationSid;
}
- public CallCreator(final String pathAccountSid, final com.twilio.type.Endpoint to, final com.twilio.type.Endpoint from, final String applicationSid) {
+
+ public CallCreator(
+ final String pathAccountSid,
+ final com.twilio.type.Endpoint to,
+ final com.twilio.type.Endpoint from,
+ final String applicationSid
+ ) {
this.pathAccountSid = pathAccountSid;
this.to = to;
this.from = from;
this.applicationSid = applicationSid;
}
- public CallCreator setTo(final com.twilio.type.Endpoint to){
+ public CallCreator setTo(final com.twilio.type.Endpoint to) {
this.to = to;
return this;
}
- public CallCreator setFrom(final com.twilio.type.Endpoint from){
+
+ public CallCreator setFrom(final com.twilio.type.Endpoint from) {
this.from = from;
return this;
}
- public CallCreator setMethod(final HttpMethod method){
+
+ public CallCreator setMethod(final HttpMethod method) {
this.method = method;
return this;
}
- public CallCreator setFallbackUrl(final URI fallbackUrl){
+
+ public CallCreator setFallbackUrl(final URI fallbackUrl) {
this.fallbackUrl = fallbackUrl;
return this;
}
- public CallCreator setFallbackUrl(final String fallbackUrl){
+ public CallCreator setFallbackUrl(final String fallbackUrl) {
return setFallbackUrl(Promoter.uriFromString(fallbackUrl));
}
- public CallCreator setFallbackMethod(final HttpMethod fallbackMethod){
+
+ public CallCreator setFallbackMethod(final HttpMethod fallbackMethod) {
this.fallbackMethod = fallbackMethod;
return this;
}
- public CallCreator setStatusCallback(final URI statusCallback){
+
+ public CallCreator setStatusCallback(final URI statusCallback) {
this.statusCallback = statusCallback;
return this;
}
- public CallCreator setStatusCallback(final String statusCallback){
+ public CallCreator setStatusCallback(final String statusCallback) {
return setStatusCallback(Promoter.uriFromString(statusCallback));
}
- public CallCreator setStatusCallbackEvent(final List statusCallbackEvent){
+
+ public CallCreator setStatusCallbackEvent(
+ final List statusCallbackEvent
+ ) {
this.statusCallbackEvent = statusCallbackEvent;
return this;
}
- public CallCreator setStatusCallbackEvent(final String statusCallbackEvent){
+
+ public CallCreator setStatusCallbackEvent(
+ final String statusCallbackEvent
+ ) {
return setStatusCallbackEvent(Promoter.listOfOne(statusCallbackEvent));
}
- public CallCreator setStatusCallbackMethod(final HttpMethod statusCallbackMethod){
+
+ public CallCreator setStatusCallbackMethod(
+ final HttpMethod statusCallbackMethod
+ ) {
this.statusCallbackMethod = statusCallbackMethod;
return this;
}
- public CallCreator setSendDigits(final String sendDigits){
+
+ public CallCreator setSendDigits(final String sendDigits) {
this.sendDigits = sendDigits;
return this;
}
- public CallCreator setTimeout(final Integer timeout){
+
+ public CallCreator setTimeout(final Integer timeout) {
this.timeout = timeout;
return this;
}
- public CallCreator setRecord(final Boolean record){
+
+ public CallCreator setRecord(final Boolean record) {
this.record = record;
return this;
}
- public CallCreator setRecordingChannels(final String recordingChannels){
+
+ public CallCreator setRecordingChannels(final String recordingChannels) {
this.recordingChannels = recordingChannels;
return this;
}
- public CallCreator setRecordingStatusCallback(final String recordingStatusCallback){
+
+ public CallCreator setRecordingStatusCallback(
+ final String recordingStatusCallback
+ ) {
this.recordingStatusCallback = recordingStatusCallback;
return this;
}
- public CallCreator setRecordingStatusCallbackMethod(final HttpMethod recordingStatusCallbackMethod){
+
+ public CallCreator setRecordingStatusCallbackMethod(
+ final HttpMethod recordingStatusCallbackMethod
+ ) {
this.recordingStatusCallbackMethod = recordingStatusCallbackMethod;
return this;
}
- public CallCreator setSipAuthUsername(final String sipAuthUsername){
+
+ public CallCreator setSipAuthUsername(final String sipAuthUsername) {
this.sipAuthUsername = sipAuthUsername;
return this;
}
- public CallCreator setSipAuthPassword(final String sipAuthPassword){
+
+ public CallCreator setSipAuthPassword(final String sipAuthPassword) {
this.sipAuthPassword = sipAuthPassword;
return this;
}
- public CallCreator setMachineDetection(final String machineDetection){
+
+ public CallCreator setMachineDetection(final String machineDetection) {
this.machineDetection = machineDetection;
return this;
}
- public CallCreator setMachineDetectionTimeout(final Integer machineDetectionTimeout){
+
+ public CallCreator setMachineDetectionTimeout(
+ final Integer machineDetectionTimeout
+ ) {
this.machineDetectionTimeout = machineDetectionTimeout;
return this;
}
- public CallCreator setRecordingStatusCallbackEvent(final List recordingStatusCallbackEvent){
+
+ public CallCreator setRecordingStatusCallbackEvent(
+ final List recordingStatusCallbackEvent
+ ) {
this.recordingStatusCallbackEvent = recordingStatusCallbackEvent;
return this;
}
- public CallCreator setRecordingStatusCallbackEvent(final String recordingStatusCallbackEvent){
- return setRecordingStatusCallbackEvent(Promoter.listOfOne(recordingStatusCallbackEvent));
+
+ public CallCreator setRecordingStatusCallbackEvent(
+ final String recordingStatusCallbackEvent
+ ) {
+ return setRecordingStatusCallbackEvent(
+ Promoter.listOfOne(recordingStatusCallbackEvent)
+ );
}
- public CallCreator setTrim(final String trim){
+
+ public CallCreator setTrim(final String trim) {
this.trim = trim;
return this;
}
- public CallCreator setCallerId(final String callerId){
+
+ public CallCreator setCallerId(final String callerId) {
this.callerId = callerId;
return this;
}
- public CallCreator setMachineDetectionSpeechThreshold(final Integer machineDetectionSpeechThreshold){
+
+ public CallCreator setMachineDetectionSpeechThreshold(
+ final Integer machineDetectionSpeechThreshold
+ ) {
this.machineDetectionSpeechThreshold = machineDetectionSpeechThreshold;
return this;
}
- public CallCreator setMachineDetectionSpeechEndThreshold(final Integer machineDetectionSpeechEndThreshold){
- this.machineDetectionSpeechEndThreshold = machineDetectionSpeechEndThreshold;
+
+ public CallCreator setMachineDetectionSpeechEndThreshold(
+ final Integer machineDetectionSpeechEndThreshold
+ ) {
+ this.machineDetectionSpeechEndThreshold =
+ machineDetectionSpeechEndThreshold;
return this;
}
- public CallCreator setMachineDetectionSilenceTimeout(final Integer machineDetectionSilenceTimeout){
+
+ public CallCreator setMachineDetectionSilenceTimeout(
+ final Integer machineDetectionSilenceTimeout
+ ) {
this.machineDetectionSilenceTimeout = machineDetectionSilenceTimeout;
return this;
}
- public CallCreator setAsyncAmd(final String asyncAmd){
+
+ public CallCreator setAsyncAmd(final String asyncAmd) {
this.asyncAmd = asyncAmd;
return this;
}
- public CallCreator setAsyncAmdStatusCallback(final URI asyncAmdStatusCallback){
+
+ public CallCreator setAsyncAmdStatusCallback(
+ final URI asyncAmdStatusCallback
+ ) {
this.asyncAmdStatusCallback = asyncAmdStatusCallback;
return this;
}
- public CallCreator setAsyncAmdStatusCallback(final String asyncAmdStatusCallback){
- return setAsyncAmdStatusCallback(Promoter.uriFromString(asyncAmdStatusCallback));
+ public CallCreator setAsyncAmdStatusCallback(
+ final String asyncAmdStatusCallback
+ ) {
+ return setAsyncAmdStatusCallback(
+ Promoter.uriFromString(asyncAmdStatusCallback)
+ );
}
- public CallCreator setAsyncAmdStatusCallbackMethod(final HttpMethod asyncAmdStatusCallbackMethod){
+
+ public CallCreator setAsyncAmdStatusCallbackMethod(
+ final HttpMethod asyncAmdStatusCallbackMethod
+ ) {
this.asyncAmdStatusCallbackMethod = asyncAmdStatusCallbackMethod;
return this;
}
- public CallCreator setByoc(final String byoc){
+
+ public CallCreator setByoc(final String byoc) {
this.byoc = byoc;
return this;
}
- public CallCreator setCallReason(final String callReason){
+
+ public CallCreator setCallReason(final String callReason) {
this.callReason = callReason;
return this;
}
- public CallCreator setCallToken(final String callToken){
+
+ public CallCreator setCallToken(final String callToken) {
this.callToken = callToken;
return this;
}
- public CallCreator setRecordingTrack(final String recordingTrack){
+
+ public CallCreator setRecordingTrack(final String recordingTrack) {
this.recordingTrack = recordingTrack;
return this;
}
- public CallCreator setTimeLimit(final Integer timeLimit){
+
+ public CallCreator setTimeLimit(final Integer timeLimit) {
this.timeLimit = timeLimit;
return this;
}
- public CallCreator setUrl(final URI url){
+
+ public CallCreator setUrl(final URI url) {
this.url = url;
return this;
}
- public CallCreator setUrl(final String url){
+ public CallCreator setUrl(final String url) {
return setUrl(Promoter.uriFromString(url));
}
- public CallCreator setTwiml(final com.twilio.type.Twiml twiml){
+
+ public CallCreator setTwiml(final com.twilio.type.Twiml twiml) {
this.twiml = twiml;
return this;
}
- public CallCreator setTwiml(final String twiml){
+ public CallCreator setTwiml(final String twiml) {
return setTwiml(Promoter.twimlFromString(twiml));
}
- public CallCreator setApplicationSid(final String applicationSid){
+
+ public CallCreator setApplicationSid(final String applicationSid) {
this.applicationSid = applicationSid;
return this;
}
@Override
- public Call create(final TwilioRestClient client){
+ public Call create(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Calls.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"To"+"}", this.to.toString());
- path = path.replace("{"+"From"+"}", this.from.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "To" + "}", this.to.toString());
+ path = path.replace("{" + "From" + "}", this.from.toString());
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Call creation failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Call creation failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Call.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (to != null) {
request.addPostParam("To", to.toString());
-
}
if (from != null) {
request.addPostParam("From", from.toString());
-
}
if (method != null) {
request.addPostParam("Method", method.toString());
-
}
if (fallbackUrl != null) {
request.addPostParam("FallbackUrl", fallbackUrl.toString());
-
}
if (fallbackMethod != null) {
request.addPostParam("FallbackMethod", fallbackMethod.toString());
-
}
if (statusCallback != null) {
request.addPostParam("StatusCallback", statusCallback.toString());
-
}
if (statusCallbackEvent != null) {
for (String prop : statusCallbackEvent) {
request.addPostParam("StatusCallbackEvent", prop);
}
-
}
if (statusCallbackMethod != null) {
- request.addPostParam("StatusCallbackMethod", statusCallbackMethod.toString());
-
+ request.addPostParam(
+ "StatusCallbackMethod",
+ statusCallbackMethod.toString()
+ );
}
if (sendDigits != null) {
request.addPostParam("SendDigits", sendDigits);
-
}
if (timeout != null) {
request.addPostParam("Timeout", timeout.toString());
-
}
if (record != null) {
request.addPostParam("Record", record.toString());
-
}
if (recordingChannels != null) {
request.addPostParam("RecordingChannels", recordingChannels);
-
}
if (recordingStatusCallback != null) {
- request.addPostParam("RecordingStatusCallback", recordingStatusCallback);
-
+ request.addPostParam(
+ "RecordingStatusCallback",
+ recordingStatusCallback
+ );
}
if (recordingStatusCallbackMethod != null) {
- request.addPostParam("RecordingStatusCallbackMethod", recordingStatusCallbackMethod.toString());
-
+ request.addPostParam(
+ "RecordingStatusCallbackMethod",
+ recordingStatusCallbackMethod.toString()
+ );
}
if (sipAuthUsername != null) {
request.addPostParam("SipAuthUsername", sipAuthUsername);
-
}
if (sipAuthPassword != null) {
request.addPostParam("SipAuthPassword", sipAuthPassword);
-
}
if (machineDetection != null) {
request.addPostParam("MachineDetection", machineDetection);
-
}
if (machineDetectionTimeout != null) {
- request.addPostParam("MachineDetectionTimeout", machineDetectionTimeout.toString());
-
+ request.addPostParam(
+ "MachineDetectionTimeout",
+ machineDetectionTimeout.toString()
+ );
}
if (recordingStatusCallbackEvent != null) {
for (String prop : recordingStatusCallbackEvent) {
request.addPostParam("RecordingStatusCallbackEvent", prop);
}
-
}
if (trim != null) {
request.addPostParam("Trim", trim);
-
}
if (callerId != null) {
request.addPostParam("CallerId", callerId);
-
}
if (machineDetectionSpeechThreshold != null) {
- request.addPostParam("MachineDetectionSpeechThreshold", machineDetectionSpeechThreshold.toString());
-
+ request.addPostParam(
+ "MachineDetectionSpeechThreshold",
+ machineDetectionSpeechThreshold.toString()
+ );
}
if (machineDetectionSpeechEndThreshold != null) {
- request.addPostParam("MachineDetectionSpeechEndThreshold", machineDetectionSpeechEndThreshold.toString());
-
+ request.addPostParam(
+ "MachineDetectionSpeechEndThreshold",
+ machineDetectionSpeechEndThreshold.toString()
+ );
}
if (machineDetectionSilenceTimeout != null) {
- request.addPostParam("MachineDetectionSilenceTimeout", machineDetectionSilenceTimeout.toString());
-
+ request.addPostParam(
+ "MachineDetectionSilenceTimeout",
+ machineDetectionSilenceTimeout.toString()
+ );
}
if (asyncAmd != null) {
request.addPostParam("AsyncAmd", asyncAmd);
-
}
if (asyncAmdStatusCallback != null) {
- request.addPostParam("AsyncAmdStatusCallback", asyncAmdStatusCallback.toString());
-
+ request.addPostParam(
+ "AsyncAmdStatusCallback",
+ asyncAmdStatusCallback.toString()
+ );
}
if (asyncAmdStatusCallbackMethod != null) {
- request.addPostParam("AsyncAmdStatusCallbackMethod", asyncAmdStatusCallbackMethod.toString());
-
+ request.addPostParam(
+ "AsyncAmdStatusCallbackMethod",
+ asyncAmdStatusCallbackMethod.toString()
+ );
}
if (byoc != null) {
request.addPostParam("Byoc", byoc);
-
}
if (callReason != null) {
request.addPostParam("CallReason", callReason);
-
}
if (callToken != null) {
request.addPostParam("CallToken", callToken);
-
}
if (recordingTrack != null) {
request.addPostParam("RecordingTrack", recordingTrack);
-
}
if (timeLimit != null) {
request.addPostParam("TimeLimit", timeLimit.toString());
-
}
if (url != null) {
request.addPostParam("Url", url.toString());
-
}
if (twiml != null) {
request.addPostParam("Twiml", twiml.toString());
-
}
if (applicationSid != null) {
request.addPostParam("ApplicationSid", applicationSid);
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java b/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java
index f054872cec..362bdaf990 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java
@@ -24,28 +24,34 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
public class CallDeleter extends Deleter {
+
private String pathSid;
private String pathAccountSid;
- public CallDeleter(final String pathSid){
+ public CallDeleter(final String pathSid) {
this.pathSid = pathSid;
}
- public CallDeleter(final String pathAccountSid, final String pathSid){
+
+ public CallDeleter(final String pathAccountSid, final String pathSid) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
-
@Override
public boolean delete(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.DELETE,
@@ -55,11 +61,19 @@ public boolean delete(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Call delete failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Call delete failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java b/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java
index 1e9c3b11a1..3c204e486b 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java
@@ -24,29 +24,34 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class CallFetcher extends Fetcher {
+
private String pathSid;
private String pathAccountSid;
- public CallFetcher(final String pathSid){
+ public CallFetcher(final String pathSid) {
this.pathSid = pathSid;
}
- public CallFetcher(final String pathAccountSid, final String pathSid){
+
+ public CallFetcher(final String pathAccountSid, final String pathSid) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
-
@Override
public Call fetch(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.GET,
@@ -56,11 +61,19 @@ public Call fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Call fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Call fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/CallReader.java b/src/main/java/com/twilio/rest/api/v2010/account/CallReader.java
index 6be5efc9c8..f3f45d89ab 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/CallReader.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/CallReader.java
@@ -14,6 +14,7 @@
package com.twilio.rest.api.v2010.account;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.converter.Promoter;
@@ -25,81 +26,64 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-
-
public class CallReader extends Reader {
+
private String pathAccountSid;
private com.twilio.type.PhoneNumber to;
private com.twilio.type.PhoneNumber from;
private String parentCallSid;
private Call.Status status;
private ZonedDateTime startTime;
- private ZonedDateTime startTimeBefore;
- private ZonedDateTime startTimeAfter;
private ZonedDateTime endTime;
- private ZonedDateTime endTimeBefore;
- private ZonedDateTime endTimeAfter;
private Integer pageSize;
- public CallReader(){
- }
- public CallReader(final String pathAccountSid){
+ public CallReader() {}
+
+ public CallReader(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
- public CallReader setTo(final com.twilio.type.PhoneNumber to){
+ public CallReader setTo(final com.twilio.type.PhoneNumber to) {
this.to = to;
return this;
}
- public CallReader setTo(final String to){
+ public CallReader setTo(final String to) {
return setTo(Promoter.phoneNumberFromString(to));
}
- public CallReader setFrom(final com.twilio.type.PhoneNumber from){
+
+ public CallReader setFrom(final com.twilio.type.PhoneNumber from) {
this.from = from;
return this;
}
- public CallReader setFrom(final String from){
+ public CallReader setFrom(final String from) {
return setFrom(Promoter.phoneNumberFromString(from));
}
- public CallReader setParentCallSid(final String parentCallSid){
+
+ public CallReader setParentCallSid(final String parentCallSid) {
this.parentCallSid = parentCallSid;
return this;
}
- public CallReader setStatus(final Call.Status status){
+
+ public CallReader setStatus(final Call.Status status) {
this.status = status;
return this;
}
- public CallReader setStartTime(final ZonedDateTime startTime){
+
+ public CallReader setStartTime(final ZonedDateTime startTime) {
this.startTime = startTime;
return this;
}
- public CallReader setStartTimeBefore(final ZonedDateTime startTimeBefore){
- this.startTimeBefore = startTimeBefore;
- return this;
- }
- public CallReader setStartTimeAfter(final ZonedDateTime startTimeAfter){
- this.startTimeAfter = startTimeAfter;
- return this;
- }
- public CallReader setEndTime(final ZonedDateTime endTime){
+
+ public CallReader setEndTime(final ZonedDateTime endTime) {
this.endTime = endTime;
return this;
}
- public CallReader setEndTimeBefore(final ZonedDateTime endTimeBefore){
- this.endTimeBefore = endTimeBefore;
- return this;
- }
- public CallReader setEndTimeAfter(final ZonedDateTime endTimeAfter){
- this.endTimeAfter = endTimeAfter;
- return this;
- }
- public CallReader setPageSize(final Integer pageSize){
+
+ public CallReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -111,8 +95,15 @@ public ResourceSet read(final TwilioRestClient client) {
public Page firstPage(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Calls.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -124,15 +115,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page pageForRequest(
+ final TwilioRestClient client,
+ final Request request
+ ) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Call read failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Call read failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
@@ -146,7 +148,10 @@ private Page pageForRequest(final TwilioRestClient client, final Request r
}
@Override
- public Page previousPage(final Page page, final TwilioRestClient client) {
+ public Page previousPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getPreviousPageUrl(Domains.API.toString())
@@ -154,9 +159,11 @@ public Page previousPage(final Page page, final TwilioRestClient cli
return pageForRequest(client, request);
}
-
@Override
- public Page nextPage(final Page page, final TwilioRestClient client) {
+ public Page nextPage(
+ final Page page,
+ final TwilioRestClient client
+ ) {
Request request = new Request(
HttpMethod.GET,
page.getNextPageUrl(Domains.API.toString())
@@ -165,49 +172,44 @@ public Page nextPage(final Page page, final TwilioRestClient client)
}
@Override
- public Page getPage(final String targetUrl, final TwilioRestClient client) {
- Request request = new Request(
- HttpMethod.GET,
- targetUrl
- );
+ public Page getPage(
+ final String targetUrl,
+ final TwilioRestClient client
+ ) {
+ Request request = new Request(HttpMethod.GET, targetUrl);
return pageForRequest(client, request);
}
+
private void addQueryParams(final Request request) {
if (to != null) {
-
request.addQueryParam("To", to.toString());
}
if (from != null) {
-
request.addQueryParam("From", from.toString());
}
if (parentCallSid != null) {
-
request.addQueryParam("ParentCallSid", parentCallSid);
}
if (status != null) {
-
request.addQueryParam("Status", status.toString());
}
if (startTime != null) {
- request.addQueryParam("StartTime", startTime.format(DateTimeFormatter.ofPattern(Request.QUERY_STRING_DATE_TIME_FORMAT)));
- }
- else if (startTimeAfter != null || startTimeBefore != null) {
- request.addQueryDateTimeRange("StartTime", startTimeAfter, startTimeBefore);
+ request.addQueryParam(
+ "StartTime",
+ startTime.toInstant().toString()
+ );
}
+
if (endTime != null) {
- request.addQueryParam("EndTime", endTime.format(DateTimeFormatter.ofPattern(Request.QUERY_STRING_DATE_TIME_FORMAT)));
- }
- else if (endTimeAfter != null || endTimeBefore != null) {
- request.addQueryDateTimeRange("EndTime", endTimeAfter, endTimeBefore);
+ request.addQueryParam("EndTime", endTime.toInstant().toString());
}
+
if (pageSize != null) {
-
request.addQueryParam("PageSize", pageSize.toString());
}
- if(getPageSize() != null) {
+ if (getPageSize() != null) {
request.addQueryParam("PageSize", Integer.toString(getPageSize()));
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/CallUpdater.java b/src/main/java/com/twilio/rest/api/v2010/account/CallUpdater.java
index b478d265df..e0f461315e 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/CallUpdater.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/CallUpdater.java
@@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010.account;
import com.twilio.base.Updater;
+import com.twilio.constant.EnumConstants;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
@@ -24,12 +25,10 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
import java.net.URI;
+public class CallUpdater extends Updater {
-
-public class CallUpdater extends Updater{
private String pathSid;
private String pathAccountSid;
private URI url;
@@ -42,130 +41,152 @@ public class CallUpdater extends Updater{
private com.twilio.type.Twiml twiml;
private Integer timeLimit;
- public CallUpdater(final String pathSid){
+ public CallUpdater(final String pathSid) {
this.pathSid = pathSid;
}
- public CallUpdater(final String pathAccountSid, final String pathSid){
+
+ public CallUpdater(final String pathAccountSid, final String pathSid) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
- public CallUpdater setUrl(final URI url){
+ public CallUpdater setUrl(final URI url) {
this.url = url;
return this;
}
- public CallUpdater setUrl(final String url){
+ public CallUpdater setUrl(final String url) {
return setUrl(Promoter.uriFromString(url));
}
- public CallUpdater setMethod(final HttpMethod method){
+
+ public CallUpdater setMethod(final HttpMethod method) {
this.method = method;
return this;
}
- public CallUpdater setStatus(final Call.UpdateStatus status){
+
+ public CallUpdater setStatus(final Call.UpdateStatus status) {
this.status = status;
return this;
}
- public CallUpdater setFallbackUrl(final URI fallbackUrl){
+
+ public CallUpdater setFallbackUrl(final URI fallbackUrl) {
this.fallbackUrl = fallbackUrl;
return this;
}
- public CallUpdater setFallbackUrl(final String fallbackUrl){
+ public CallUpdater setFallbackUrl(final String fallbackUrl) {
return setFallbackUrl(Promoter.uriFromString(fallbackUrl));
}
- public CallUpdater setFallbackMethod(final HttpMethod fallbackMethod){
+
+ public CallUpdater setFallbackMethod(final HttpMethod fallbackMethod) {
this.fallbackMethod = fallbackMethod;
return this;
}
- public CallUpdater setStatusCallback(final URI statusCallback){
+
+ public CallUpdater setStatusCallback(final URI statusCallback) {
this.statusCallback = statusCallback;
return this;
}
- public CallUpdater setStatusCallback(final String statusCallback){
+ public CallUpdater setStatusCallback(final String statusCallback) {
return setStatusCallback(Promoter.uriFromString(statusCallback));
}
- public CallUpdater setStatusCallbackMethod(final HttpMethod statusCallbackMethod){
+
+ public CallUpdater setStatusCallbackMethod(
+ final HttpMethod statusCallbackMethod
+ ) {
this.statusCallbackMethod = statusCallbackMethod;
return this;
}
- public CallUpdater setTwiml(final com.twilio.type.Twiml twiml){
+
+ public CallUpdater setTwiml(final com.twilio.type.Twiml twiml) {
this.twiml = twiml;
return this;
}
- public CallUpdater setTwiml(final String twiml){
+ public CallUpdater setTwiml(final String twiml) {
return setTwiml(Promoter.twimlFromString(twiml));
}
- public CallUpdater setTimeLimit(final Integer timeLimit){
+
+ public CallUpdater setTimeLimit(final Integer timeLimit) {
this.timeLimit = timeLimit;
return this;
}
@Override
- public Call update(final TwilioRestClient client){
+ public Call update(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.POST,
Domains.API.toString(),
path
);
+ request.setContentType(EnumConstants.ContentType.FORM_URLENCODED);
addPostParams(request);
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Call update failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Call update failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
return Call.fromJson(response.getStream(), client.getObjectMapper());
}
+
private void addPostParams(final Request request) {
if (url != null) {
request.addPostParam("Url", url.toString());
-
}
if (method != null) {
request.addPostParam("Method", method.toString());
-
}
if (status != null) {
request.addPostParam("Status", status.toString());
-
}
if (fallbackUrl != null) {
request.addPostParam("FallbackUrl", fallbackUrl.toString());
-
}
if (fallbackMethod != null) {
request.addPostParam("FallbackMethod", fallbackMethod.toString());
-
}
if (statusCallback != null) {
request.addPostParam("StatusCallback", statusCallback.toString());
-
}
if (statusCallbackMethod != null) {
- request.addPostParam("StatusCallbackMethod", statusCallbackMethod.toString());
-
+ request.addPostParam(
+ "StatusCallbackMethod",
+ statusCallbackMethod.toString()
+ );
}
if (twiml != null) {
request.addPostParam("Twiml", twiml.toString());
-
}
if (timeLimit != null) {
request.addPostParam("TimeLimit", timeLimit.toString());
-
}
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/Conference.java b/src/main/java/com/twilio/rest/api/v2010/account/Conference.java
index 0e97c45326..c1892fabea 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/Conference.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/Conference.java
@@ -24,55 +24,63 @@
import com.twilio.converter.DateConverter;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
-
import com.twilio.exception.ApiException;
-
-import lombok.ToString;
-
import java.io.IOException;
import java.io.InputStream;
import java.time.ZonedDateTime;
-
import java.util.Map;
-import java.util.Objects;
-
-
import java.util.Map;
+import java.util.Objects;
+import lombok.ToString;
+import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class Conference extends Resource {
+
private static final long serialVersionUID = 143481327355997L;
- public static ConferenceFetcher fetcher(final String pathSid){
+ public static ConferenceFetcher fetcher(final String pathSid) {
return new ConferenceFetcher(pathSid);
}
- public static ConferenceFetcher fetcher(final String pathAccountSid, final String pathSid){
+
+ public static ConferenceFetcher fetcher(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new ConferenceFetcher(pathAccountSid, pathSid);
}
- public static ConferenceReader reader(){
+ public static ConferenceReader reader() {
return new ConferenceReader();
}
- public static ConferenceReader reader(final String pathAccountSid){
+
+ public static ConferenceReader reader(final String pathAccountSid) {
return new ConferenceReader(pathAccountSid);
}
- public static ConferenceUpdater updater(final String pathSid){
+ public static ConferenceUpdater updater(final String pathSid) {
return new ConferenceUpdater(pathSid);
}
- public static ConferenceUpdater updater(final String pathAccountSid, final String pathSid){
+
+ public static ConferenceUpdater updater(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
return new ConferenceUpdater(pathAccountSid, pathSid);
}
/**
- * Converts a JSON String into a Conference object using the provided ObjectMapper.
- *
- * @param json Raw JSON String
- * @param objectMapper Jackson ObjectMapper
- * @return Conference object represented by the provided JSON
- */
- public static Conference fromJson(final String json, final ObjectMapper objectMapper) {
+ * Converts a JSON String into a Conference object using the provided ObjectMapper.
+ *
+ * @param json Raw JSON String
+ * @param objectMapper Jackson ObjectMapper
+ * @return Conference object represented by the provided JSON
+ */
+ public static Conference fromJson(
+ final String json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Conference.class);
@@ -84,14 +92,17 @@ public static Conference fromJson(final String json, final ObjectMapper objectMa
}
/**
- * Converts a JSON InputStream into a Conference object using the provided
- * ObjectMapper.
- *
- * @param json Raw JSON InputStream
- * @param objectMapper Jackson ObjectMapper
- * @return Conference object represented by the provided JSON
- */
- public static Conference fromJson(final InputStream json, final ObjectMapper objectMapper) {
+ * Converts a JSON InputStream into a Conference object using the provided
+ * ObjectMapper.
+ *
+ * @param json Raw JSON InputStream
+ * @param objectMapper Jackson ObjectMapper
+ * @return Conference object represented by the provided JSON
+ */
+ public static Conference fromJson(
+ final InputStream json,
+ final ObjectMapper objectMapper
+ ) {
// Convert all checked exceptions to Runtime
try {
return objectMapper.readValue(json, Conference.class);
@@ -101,48 +112,7 @@ public static Conference fromJson(final InputStream json, final ObjectMapper obj
throw new ApiConnectionException(e.getMessage(), e);
}
}
- public enum ReasonConferenceEnded {
- CONFERENCE_ENDED_VIA_API("conference-ended-via-api"),
- PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_LEFT("participant-with-end-conference-on-exit-left"),
- PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_KICKED("participant-with-end-conference-on-exit-kicked"),
- LAST_PARTICIPANT_KICKED("last-participant-kicked"),
- LAST_PARTICIPANT_LEFT("last-participant-left");
-
- private final String value;
-
- private ReasonConferenceEnded(final String value) {
- this.value = value;
- }
-
- public String toString() {
- return value;
- }
-
- @JsonCreator
- public static ReasonConferenceEnded forValue(final String value) {
- return Promoter.enumFromString(value, ReasonConferenceEnded.values());
- }
- }
- public enum Status {
- INIT("init"),
- IN_PROGRESS("in-progress"),
- COMPLETED("completed");
-
- private final String value;
-
- private Status(final String value) {
- this.value = value;
- }
- public String toString() {
- return value;
- }
-
- @JsonCreator
- public static Status forValue(final String value) {
- return Promoter.enumFromString(value, Status.values());
- }
- }
public enum UpdateStatus {
COMPLETED("completed");
@@ -177,41 +147,25 @@ public static UpdateStatus forValue(final String value) {
@JsonCreator
private Conference(
- @JsonProperty("account_sid")
- final String accountSid,
-
- @JsonProperty("date_created")
- final String dateCreated,
-
- @JsonProperty("date_updated")
- final String dateUpdated,
-
- @JsonProperty("api_version")
- final String apiVersion,
-
- @JsonProperty("friendly_name")
- final String friendlyName,
-
- @JsonProperty("region")
- final String region,
-
- @JsonProperty("sid")
- final String sid,
-
- @JsonProperty("status")
- final Conference.Status status,
-
- @JsonProperty("uri")
- final String uri,
-
- @JsonProperty("subresource_uris")
- final Map subresourceUris,
-
- @JsonProperty("reason_conference_ended")
- final Conference.ReasonConferenceEnded reasonConferenceEnded,
-
- @JsonProperty("call_sid_ending_conference")
- final String callSidEndingConference
+ @JsonProperty("account_sid") final String accountSid,
+ @JsonProperty("date_created") final String dateCreated,
+ @JsonProperty("date_updated") final String dateUpdated,
+ @JsonProperty("api_version") final String apiVersion,
+ @JsonProperty("friendly_name") final String friendlyName,
+ @JsonProperty("region") final String region,
+ @JsonProperty("sid") final String sid,
+ @JsonProperty("status") final Conference.Status status,
+ @JsonProperty("uri") final String uri,
+ @JsonProperty("subresource_uris") final Map<
+ String,
+ String
+ > subresourceUris,
+ @JsonProperty(
+ "reason_conference_ended"
+ ) final Conference.ReasonConferenceEnded reasonConferenceEnded,
+ @JsonProperty(
+ "call_sid_ending_conference"
+ ) final String callSidEndingConference
) {
this.accountSid = accountSid;
this.dateCreated = DateConverter.rfc2822DateTimeFromString(dateCreated);
@@ -227,46 +181,57 @@ private Conference(
this.callSidEndingConference = callSidEndingConference;
}
- public final String getAccountSid() {
- return this.accountSid;
- }
- public final ZonedDateTime getDateCreated() {
- return this.dateCreated;
- }
- public final ZonedDateTime getDateUpdated() {
- return this.dateUpdated;
- }
- public final String getApiVersion() {
- return this.apiVersion;
- }
- public final String getFriendlyName() {
- return this.friendlyName;
- }
- public final String getRegion() {
- return this.region;
- }
- public final String getSid() {
- return this.sid;
- }
- public final Conference.Status getStatus() {
- return this.status;
- }
- public final String getUri() {
- return this.uri;
- }
- public final Map getSubresourceUris() {
- return this.subresourceUris;
- }
- public final Conference.ReasonConferenceEnded getReasonConferenceEnded() {
- return this.reasonConferenceEnded;
- }
- public final String getCallSidEndingConference() {
- return this.callSidEndingConference;
- }
+ public final String getAccountSid() {
+ return this.accountSid;
+ }
+
+ public final ZonedDateTime getDateCreated() {
+ return this.dateCreated;
+ }
+
+ public final ZonedDateTime getDateUpdated() {
+ return this.dateUpdated;
+ }
+
+ public final String getApiVersion() {
+ return this.apiVersion;
+ }
+
+ public final String getFriendlyName() {
+ return this.friendlyName;
+ }
+
+ public final String getRegion() {
+ return this.region;
+ }
+
+ public final String getSid() {
+ return this.sid;
+ }
+
+ public final Conference.Status getStatus() {
+ return this.status;
+ }
+
+ public final String getUri() {
+ return this.uri;
+ }
+
+ public final Map getSubresourceUris() {
+ return this.subresourceUris;
+ }
+
+ public final Conference.ReasonConferenceEnded getReasonConferenceEnded() {
+ return this.reasonConferenceEnded;
+ }
+
+ public final String getCallSidEndingConference() {
+ return this.callSidEndingConference;
+ }
@Override
public boolean equals(final Object o) {
- if (this==o) {
+ if (this == o) {
return true;
}
@@ -276,13 +241,94 @@ public boolean equals(final Object o) {
Conference other = (Conference) o;
- return Objects.equals(accountSid, other.accountSid) && Objects.equals(dateCreated, other.dateCreated) && Objects.equals(dateUpdated, other.dateUpdated) && Objects.equals(apiVersion, other.apiVersion) && Objects.equals(friendlyName, other.friendlyName) && Objects.equals(region, other.region) && Objects.equals(sid, other.sid) && Objects.equals(status, other.status) && Objects.equals(uri, other.uri) && Objects.equals(subresourceUris, other.subresourceUris) && Objects.equals(reasonConferenceEnded, other.reasonConferenceEnded) && Objects.equals(callSidEndingConference, other.callSidEndingConference) ;
+ return (
+ Objects.equals(accountSid, other.accountSid) &&
+ Objects.equals(dateCreated, other.dateCreated) &&
+ Objects.equals(dateUpdated, other.dateUpdated) &&
+ Objects.equals(apiVersion, other.apiVersion) &&
+ Objects.equals(friendlyName, other.friendlyName) &&
+ Objects.equals(region, other.region) &&
+ Objects.equals(sid, other.sid) &&
+ Objects.equals(status, other.status) &&
+ Objects.equals(uri, other.uri) &&
+ Objects.equals(subresourceUris, other.subresourceUris) &&
+ Objects.equals(
+ reasonConferenceEnded,
+ other.reasonConferenceEnded
+ ) &&
+ Objects.equals(
+ callSidEndingConference,
+ other.callSidEndingConference
+ )
+ );
}
@Override
public int hashCode() {
- return Objects.hash(accountSid, dateCreated, dateUpdated, apiVersion, friendlyName, region, sid, status, uri, subresourceUris, reasonConferenceEnded, callSidEndingConference);
+ return Objects.hash(
+ accountSid,
+ dateCreated,
+ dateUpdated,
+ apiVersion,
+ friendlyName,
+ region,
+ sid,
+ status,
+ uri,
+ subresourceUris,
+ reasonConferenceEnded,
+ callSidEndingConference
+ );
}
-}
+ public enum ReasonConferenceEnded {
+ CONFERENCE_ENDED_VIA_API("conference-ended-via-api"),
+ PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_LEFT(
+ "participant-with-end-conference-on-exit-left"
+ ),
+ PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_KICKED(
+ "participant-with-end-conference-on-exit-kicked"
+ ),
+ LAST_PARTICIPANT_KICKED("last-participant-kicked"),
+ LAST_PARTICIPANT_LEFT("last-participant-left");
+ private final String value;
+
+ private ReasonConferenceEnded(final String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return value;
+ }
+
+ @JsonCreator
+ public static ReasonConferenceEnded forValue(final String value) {
+ return Promoter.enumFromString(
+ value,
+ ReasonConferenceEnded.values()
+ );
+ }
+ }
+
+ public enum Status {
+ INIT("init"),
+ IN_PROGRESS("in-progress"),
+ COMPLETED("completed");
+
+ private final String value;
+
+ private Status(final String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return value;
+ }
+
+ @JsonCreator
+ public static Status forValue(final String value) {
+ return Promoter.enumFromString(value, Status.values());
+ }
+ }
+}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/ConferenceFetcher.java b/src/main/java/com/twilio/rest/api/v2010/account/ConferenceFetcher.java
index d54a43b50c..d7bbf95020 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/ConferenceFetcher.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/ConferenceFetcher.java
@@ -24,29 +24,38 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-
-
-
public class ConferenceFetcher extends Fetcher {
+
private String pathSid;
private String pathAccountSid;
- public ConferenceFetcher(final String pathSid){
+ public ConferenceFetcher(final String pathSid) {
this.pathSid = pathSid;
}
- public ConferenceFetcher(final String pathAccountSid, final String pathSid){
+
+ public ConferenceFetcher(
+ final String pathAccountSid,
+ final String pathSid
+ ) {
this.pathAccountSid = pathAccountSid;
this.pathSid = pathSid;
}
-
@Override
public Conference fetch(final TwilioRestClient client) {
- String path = "/2010-04-01/Accounts/{AccountSid}/Conferences/{Sid}.json";
+ String path =
+ "/2010-04-01/Accounts/{AccountSid}/Conferences/{Sid}.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
- path = path.replace("{"+"Sid"+"}", this.pathSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
+ path = path.replace("{" + "Sid" + "}", this.pathSid.toString());
Request request = new Request(
HttpMethod.GET,
@@ -56,15 +65,26 @@ public Conference fetch(final TwilioRestClient client) {
Response response = client.request(request);
if (response == null) {
- throw new ApiConnectionException("Conference fetch failed: Unable to connect to server");
+ throw new ApiConnectionException(
+ "Conference fetch failed: Unable to connect to server"
+ );
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
- RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
+ RestException restException = RestException.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
if (restException == null) {
- throw new ApiException("Server Error, no content");
+ throw new ApiException(
+ "Server Error, no content",
+ response.getStatusCode()
+ );
}
throw new ApiException(restException);
}
- return Conference.fromJson(response.getStream(), client.getObjectMapper());
+ return Conference.fromJson(
+ response.getStream(),
+ client.getObjectMapper()
+ );
}
}
diff --git a/src/main/java/com/twilio/rest/api/v2010/account/ConferenceReader.java b/src/main/java/com/twilio/rest/api/v2010/account/ConferenceReader.java
index a30c6df034..f2bfb84be6 100644
--- a/src/main/java/com/twilio/rest/api/v2010/account/ConferenceReader.java
+++ b/src/main/java/com/twilio/rest/api/v2010/account/ConferenceReader.java
@@ -14,8 +14,10 @@
package com.twilio.rest.api.v2010.account;
+import com.twilio.base.Page;
import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
+import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
@@ -24,63 +26,44 @@
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
-import com.twilio.base.Page;
import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-
public class ConferenceReader extends Reader {
+
private String pathAccountSid;
private LocalDate dateCreated;
- private LocalDate dateCreatedBefore;
- private LocalDate dateCreatedAfter;
private LocalDate dateUpdated;
- private LocalDate dateUpdatedBefore;
- private LocalDate dateUpdatedAfter;
private String friendlyName;
private Conference.Status status;
private Integer pageSize;
- public ConferenceReader(){
- }
- public ConferenceReader(final String pathAccountSid){
+ public ConferenceReader() {}
+
+ public ConferenceReader(final String pathAccountSid) {
this.pathAccountSid = pathAccountSid;
}
- public ConferenceReader setDateCreated(final LocalDate dateCreated){
+ public ConferenceReader setDateCreated(final LocalDate dateCreated) {
this.dateCreated = dateCreated;
return this;
}
- public ConferenceReader setDateCreatedBefore(final LocalDate dateCreatedBefore){
- this.dateCreatedBefore = dateCreatedBefore;
- return this;
- }
- public ConferenceReader setDateCreatedAfter(final LocalDate dateCreatedAfter){
- this.dateCreatedAfter = dateCreatedAfter;
- return this;
- }
- public ConferenceReader setDateUpdated(final LocalDate dateUpdated){
+
+ public ConferenceReader setDateUpdated(final LocalDate dateUpdated) {
this.dateUpdated = dateUpdated;
return this;
}
- public ConferenceReader setDateUpdatedBefore(final LocalDate dateUpdatedBefore){
- this.dateUpdatedBefore = dateUpdatedBefore;
- return this;
- }
- public ConferenceReader setDateUpdatedAfter(final LocalDate dateUpdatedAfter){
- this.dateUpdatedAfter = dateUpdatedAfter;
- return this;
- }
- public ConferenceReader setFriendlyName(final String friendlyName){
+
+ public ConferenceReader setFriendlyName(final String friendlyName) {
this.friendlyName = friendlyName;
return this;
}
- public ConferenceReader setStatus(final Conference.Status status){
+
+ public ConferenceReader setStatus(final Conference.Status status) {
this.status = status;
return this;
}
- public ConferenceReader setPageSize(final Integer pageSize){
+
+ public ConferenceReader setPageSize(final Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@@ -92,8 +75,15 @@ public ResourceSet read(final TwilioRestClient client) {
public Page firstPage(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Conferences.json";
- this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
- path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString());
+ this.pathAccountSid =
+ this.pathAccountSid == null
+ ? client.getAccountSid()
+ : this.pathAccountSid;
+ path =
+ path.replace(
+ "{" + "AccountSid" + "}",
+ this.pathAccountSid.toString()
+ );
Request request = new Request(
HttpMethod.GET,
@@ -105,15 +95,26 @@ public Page firstPage(final TwilioRestClient client) {
return pageForRequest(client, request);
}
- private Page pageForRequest(final TwilioRestClient client, final Request request) {
+ private Page