-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into public-oauth-rest-client
- Loading branch information
Showing
59 changed files
with
7,034 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
src/main/java/com/twilio/rest/accounts/v1/BulkConsents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* 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.List; | ||
import java.util.Map; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import lombok.ToString; | ||
import lombok.ToString; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@ToString | ||
public class BulkConsents extends Resource { | ||
|
||
private static final long serialVersionUID = 126137950684284L; | ||
|
||
public static BulkConsentsCreator creator( | ||
final List<Map<String, Object>> items | ||
) { | ||
return new BulkConsentsCreator(items); | ||
} | ||
|
||
/** | ||
* Converts a JSON String into a BulkConsents object using the provided ObjectMapper. | ||
* | ||
* @param json Raw JSON String | ||
* @param objectMapper Jackson ObjectMapper | ||
* @return BulkConsents object represented by the provided JSON | ||
*/ | ||
public static BulkConsents fromJson( | ||
final String json, | ||
final ObjectMapper objectMapper | ||
) { | ||
// Convert all checked exceptions to Runtime | ||
try { | ||
return objectMapper.readValue(json, BulkConsents.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 BulkConsents object using the provided | ||
* ObjectMapper. | ||
* | ||
* @param json Raw JSON InputStream | ||
* @param objectMapper Jackson ObjectMapper | ||
* @return BulkConsents object represented by the provided JSON | ||
*/ | ||
public static BulkConsents fromJson( | ||
final InputStream json, | ||
final ObjectMapper objectMapper | ||
) { | ||
// Convert all checked exceptions to Runtime | ||
try { | ||
return objectMapper.readValue(json, BulkConsents.class); | ||
} catch (final JsonMappingException | JsonParseException e) { | ||
throw new ApiException(e.getMessage(), e); | ||
} catch (final IOException e) { | ||
throw new ApiConnectionException(e.getMessage(), e); | ||
} | ||
} | ||
|
||
private final Map<String, Object> items; | ||
|
||
@JsonCreator | ||
private BulkConsents( | ||
@JsonProperty("items") final Map<String, Object> items | ||
) { | ||
this.items = items; | ||
} | ||
|
||
public final Map<String, Object> getItems() { | ||
return this.items; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
BulkConsents other = (BulkConsents) o; | ||
|
||
return Objects.equals(items, other.items); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(items); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
src/main/java/com/twilio/rest/accounts/v1/BulkConsentsCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* 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.converter.Converter; | ||
import com.twilio.converter.Converter; | ||
import com.twilio.converter.Promoter; | ||
import com.twilio.exception.ApiConnectionException; | ||
import com.twilio.exception.ApiException; | ||
import com.twilio.exception.RestException; | ||
import com.twilio.http.HttpMethod; | ||
import com.twilio.http.Request; | ||
import com.twilio.http.Response; | ||
import com.twilio.http.TwilioRestClient; | ||
import com.twilio.rest.Domains; | ||
import java.util.List; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Map; | ||
|
||
public class BulkConsentsCreator extends Creator<BulkConsents> { | ||
|
||
private List<Map<String, Object>> items; | ||
|
||
public BulkConsentsCreator(final List<Map<String, Object>> items) { | ||
this.items = items; | ||
} | ||
|
||
public BulkConsentsCreator setItems(final List<Map<String, Object>> items) { | ||
this.items = items; | ||
return this; | ||
} | ||
|
||
public BulkConsentsCreator setItems(final Map<String, Object> items) { | ||
return setItems(Promoter.listOfOne(items)); | ||
} | ||
|
||
@Override | ||
public BulkConsents create(final TwilioRestClient client) { | ||
String path = "/v1/Consents/Bulk"; | ||
|
||
path = path.replace("{" + "Items" + "}", this.items.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( | ||
"BulkConsents 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 BulkConsents.fromJson( | ||
response.getStream(), | ||
client.getObjectMapper() | ||
); | ||
} | ||
|
||
private void addPostParams(final Request request) { | ||
if (items != null) { | ||
for (Map<String, Object> prop : items) { | ||
request.addPostParam("Items", Converter.mapToJson(prop)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.