Skip to content

Commit

Permalink
chore: apiexception changes from oai-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sbansla committed Oct 19, 2023
1 parent 37d6e88 commit 666d198
Show file tree
Hide file tree
Showing 1,937 changed files with 75,069 additions and 109,651 deletions.
124 changes: 61 additions & 63 deletions src/main/java/com/twilio/rest/accounts/v1/AuthTokenPromotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +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 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);
Expand All @@ -64,17 +68,14 @@ public static AuthTokenPromotion fromJson(
}

/**
* 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);
Expand All @@ -85,6 +86,7 @@ public static AuthTokenPromotion fromJson(
}
}


private final String accountSid;
private final String authToken;
private final ZonedDateTime dateCreated;
Expand All @@ -93,11 +95,20 @@ public static AuthTokenPromotion fromJson(

@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;
Expand All @@ -106,29 +117,25 @@ 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;
}

Expand All @@ -138,23 +145,14 @@ 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);
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,36 @@
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;

public class AuthTokenPromotionUpdater extends Updater<AuthTokenPromotion> {

public AuthTokenPromotionUpdater() {}


public class AuthTokenPromotionUpdater extends Updater<AuthTokenPromotion>{

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(),
path
);
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());
}
}
Loading

0 comments on commit 666d198

Please sign in to comment.