Skip to content

Commit

Permalink
Merge branch 'main' into public-oauth-rest-client
Browse files Browse the repository at this point in the history
  • Loading branch information
sbansla authored Sep 27, 2024
2 parents 5176a49 + fab34c1 commit 8ee69fe
Show file tree
Hide file tree
Showing 59 changed files with 7,034 additions and 119 deletions.
24 changes: 24 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
twilio-java changelog
=====================

[2024-09-25] Version 10.5.2
---------------------------
**Library - Chore**
- [PR #815](https://github.com/twilio/twilio-java/pull/815): updated readme for Beta flag. Thanks to [@sbansla](https://github.com/sbansla)!

**Accounts**
- Update docs and mounts.
- Change library visibility to public
- Enable consent and contact bulk upsert APIs in prod.

**Serverless**
- Add is_plugin parameter in deployments api to check if it is plugins deployment


[2024-09-18] Version 10.5.1
---------------------------
**Intelligence**
- Remove public from operator_type
- Update operator_type to include general-availablity and deprecated

**Numbers**
- Remove beta flag for bundle clone API


[2024-09-05] Version 10.5.0
---------------------------
**Iam**
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>twilio</artifactId>
<packaging>jar</packaging>
<name>twilio</name>
<version>10.5.0</version>
<version>10.5.2</version>
<description>Twilio Java Helper Library</description>
<url>https://www.twilio.com</url>
<licenses>
Expand All @@ -19,7 +19,7 @@
<url>[email protected]:twilio/twilio-java.git</url>
<connection>scm:git:[email protected]:twilio/twilio-java.git</connection>
<developerConnection>scm:git:[email protected]:twilio/twilio-java.git</developerConnection>
<tag>10.5.0</tag>
<tag>10.5.2</tag>
</scm>
<developers>
<developer>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/twilio/Domains.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public enum Domains {
ACCOUNTS("accounts"),
API("api"),
ASSISTANTS("assistants"),
BULKEXPORTS("bulkexports"),
CHAT("chat"),
CONTENT("content"),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/twilio/Twilio.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class Twilio {

public static final String VERSION = "10.5.0";
public static final String VERSION = "10.5.2";
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");
Expand Down
122 changes: 122 additions & 0 deletions src/main/java/com/twilio/rest/accounts/v1/BulkConsents.java
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 src/main/java/com/twilio/rest/accounts/v1/BulkConsentsCreator.java
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));
}
}
}
}
Loading

0 comments on commit 8ee69fe

Please sign in to comment.