Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: java enum type changes #187

Merged
merged 21 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 27 additions & 42 deletions examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@
import com.twilio.type.OutboundSmsPrice;
import com.twilio.type.OutboundCallPrice;
import com.twilio.type.RecordingRule;
import com.twilio.type.SubscribeRule;

@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class Account extends Resource {
private static final long serialVersionUID = 101016944188709L;
private static final long serialVersionUID = 259833493148625L;

public static AccountCreator creator(){
return new AccountCreator();
Expand Down Expand Up @@ -138,13 +139,17 @@ public static Account fromJson(final InputStream json, final ObjectMapper object
throw new ApiConnectionException(e.getMessage(), e);
}
}
public enum TestEnum {
DIALVERB("DialVerb"),
TRUNKING("Trunking");
public enum Status {
IN_PROGRESS("in-progress"),
PAUSED("paused"),
STOPPED("stopped"),
PROCESSING("processing"),
COMPLETED("completed"),
ABSENT("absent");

private final String value;

private TestEnum(final String value) {
private Status(final String value) {
this.value = value;
}

Expand All @@ -153,17 +158,17 @@ public String toString() {
}

@JsonCreator
public static TestEnum forValue(final String value) {
return Promoter.enumFromString(value, TestEnum.values());
public static Status forValue(final String value) {
return Promoter.enumFromString(value, Status.values());
}
}
public enum XTwilioWebhookEnabled {
TRUE("true"),
FALSE("false");
public enum TestEnum {
DIALVERB("DialVerb"),
TRUNKING("Trunking");

private final String value;

private XTwilioWebhookEnabled(final String value) {
private TestEnum(final String value) {
this.value = value;
}

Expand All @@ -172,21 +177,17 @@ public String toString() {
}

@JsonCreator
public static XTwilioWebhookEnabled forValue(final String value) {
return Promoter.enumFromString(value, XTwilioWebhookEnabled.values());
public static TestEnum forValue(final String value) {
return Promoter.enumFromString(value, TestEnum.values());
}
}
public enum Status {
IN_PROGRESS("in-progress"),
PAUSED("paused"),
STOPPED("stopped"),
PROCESSING("processing"),
COMPLETED("completed"),
ABSENT("absent");
public enum XTwilioWebhookEnabled {
TRUE("true"),
FALSE("false");

private final String value;

private Status(final String value) {
private XTwilioWebhookEnabled(final String value) {
this.value = value;
}

Expand All @@ -195,8 +196,8 @@ public String toString() {
}

@JsonCreator
public static Status forValue(final String value) {
return Promoter.enumFromString(value, Status.values());
public static XTwilioWebhookEnabled forValue(final String value) {
return Promoter.enumFromString(value, XTwilioWebhookEnabled.values());
}
}

Expand All @@ -213,8 +214,6 @@ public static Status forValue(final String value) {
private final List<Integer> testArrayOfIntegers;
private final List<List<Integer>> testArrayOfArrayOfIntegers;
private final List<FeedbackIssue> testArrayOfObjects;
private final Account.XTwilioWebhookEnabled xTwilioWebhookEnabled;
private final Account.Status status;

@JsonCreator
private Account(
Expand Down Expand Up @@ -256,13 +255,7 @@ private Account(
final List<List<Integer>> testArrayOfArrayOfIntegers,

@JsonProperty("test_array_of_objects")
final List<FeedbackIssue> testArrayOfObjects,

@JsonProperty("x_twilio_webhook_enabled")
final Account.XTwilioWebhookEnabled xTwilioWebhookEnabled,

@JsonProperty("status")
final Account.Status status
final List<FeedbackIssue> testArrayOfObjects
) {
this.accountSid = accountSid;
this.sid = sid;
Expand All @@ -277,8 +270,6 @@ private Account(
this.testArrayOfIntegers = testArrayOfIntegers;
this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers;
this.testArrayOfObjects = testArrayOfObjects;
this.xTwilioWebhookEnabled = xTwilioWebhookEnabled;
this.status = status;
}

public final String getAccountSid() {
Expand Down Expand Up @@ -320,12 +311,6 @@ public final List<List<Integer>> getTestArrayOfArrayOfIntegers() {
public final List<FeedbackIssue> getTestArrayOfObjects() {
return this.testArrayOfObjects;
}
public final Account.XTwilioWebhookEnabled getXTwilioWebhookEnabled() {
return this.xTwilioWebhookEnabled;
}
public final Account.Status getStatus() {
return this.status;
}

@Override
public boolean equals(final Object o) {
Expand All @@ -339,12 +324,12 @@ public boolean equals(final Object o) {

Account other = (Account) o;

return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) && Objects.equals(testObject, other.testObject) && Objects.equals(testDateTime, other.testDateTime) && Objects.equals(testNumber, other.testNumber) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(testNumberFloat, other.testNumberFloat) && Objects.equals(testEnum, other.testEnum) && Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && Objects.equals(xTwilioWebhookEnabled, other.xTwilioWebhookEnabled) && Objects.equals(status, other.status) ;
return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) && Objects.equals(testObject, other.testObject) && Objects.equals(testDateTime, other.testDateTime) && Objects.equals(testNumber, other.testNumber) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(testNumberFloat, other.testNumberFloat) && Objects.equals(testEnum, other.testEnum) && Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && Objects.equals(testArrayOfObjects, other.testArrayOfObjects) ;
}

@Override
public int hashCode() {
return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, xTwilioWebhookEnabled, status);
return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,20 @@ public AccountCreator setRecordingStatusCallback(final URI recordingStatusCallba
this.recordingStatusCallback = recordingStatusCallback;
return this;
}

public AccountCreator setRecordingStatusCallback(final String recordingStatusCallback){
this.recordingStatusCallback = Promoter.uriFromString(recordingStatusCallback);
return this;
}
public AccountCreator setRecordingStatusCallbackEvent(final List<String> recordingStatusCallbackEvent){
this.recordingStatusCallbackEvent = recordingStatusCallbackEvent;
return this;
}

@Override
public Account create(final TwilioRestClient client){
String path = "/2010-04-01/Accounts.json";
String path = "/2010-04-01/Accounts.json";


Request request = new Request(
HttpMethod.POST,
Expand Down Expand Up @@ -120,6 +126,7 @@ private void addPostParams(final Request request) {
private void addHeaderParams(final Request request) {
if (xTwilioWebhookEnabled != null) {
request.addHeaderParam("X-Twilio-Webhook-Enabled", xTwilioWebhookEnabled.toString());

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010;

import com.twilio.base.Deleter;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.converter.PrefixedCollapsibleMap;
import com.twilio.exception.ApiException;
Expand Down Expand Up @@ -65,7 +66,8 @@ public AccountDeleter(final String sid){

@Override
public boolean delete(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{Sid}.json";
String path = "/2010-04-01/Accounts/{Sid}.json";

this.sid = this.sid == null ? client.getAccountSid() : this.sid;
path = path.replace("{"+"Sid"+"}", this.sid.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010;

import com.twilio.base.Fetcher;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.converter.PrefixedCollapsibleMap;
import com.twilio.exception.ApiException;
Expand Down Expand Up @@ -66,7 +67,8 @@ public AccountFetcher(final String sid){

@Override
public Account fetch(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{Sid}.json";
String path = "/2010-04-01/Accounts/{Sid}.json";

this.sid = this.sid == null ? client.getAccountSid() : this.sid;
path = path.replace("{"+"Sid"+"}", this.sid.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.twilio.base.Reader;
import com.twilio.base.ResourceSet;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.converter.PrefixedCollapsibleMap;
import com.twilio.exception.ApiException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public AccountUpdater setPauseBehavior(final String pauseBehavior){

@Override
public Account update(final TwilioRestClient client){
String path = "/2010-04-01/Accounts/{Sid}.json";
String path = "/2010-04-01/Accounts/{Sid}.json";

this.sid = this.sid == null ? client.getAccountSid() : this.sid;
path = path.replace("{"+"Sid"+"}", this.sid.toString());
path = path.replace("{"+"Status"+"}", this.status.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@
import com.twilio.type.OutboundSmsPrice;
import com.twilio.type.OutboundCallPrice;
import com.twilio.type.RecordingRule;
import com.twilio.type.SubscribeRule;

@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class Call extends Resource {
private static final long serialVersionUID = 191475196031556L;
private static final long serialVersionUID = 67961494484503L;

public static CallCreator creator(final String requiredStringProperty){
return new CallCreator(requiredStringProperty);
Expand Down Expand Up @@ -151,48 +152,6 @@ public static TestEnum forValue(final String value) {
return Promoter.enumFromString(value, TestEnum.values());
}
}
public enum XTwilioWebhookEnabled {
TRUE("true"),
FALSE("false");

private final String value;

private XTwilioWebhookEnabled(final String value) {
this.value = value;
}

public String toString() {
return value;
}

@JsonCreator
public static XTwilioWebhookEnabled forValue(final String value) {
return Promoter.enumFromString(value, XTwilioWebhookEnabled.values());
}
}
public enum Status {
IN_PROGRESS("in-progress"),
PAUSED("paused"),
STOPPED("stopped"),
PROCESSING("processing"),
COMPLETED("completed"),
ABSENT("absent");

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

private final String accountSid;
private final String sid;
Expand All @@ -207,8 +166,6 @@ public static Status forValue(final String value) {
private final List<Integer> testArrayOfIntegers;
private final List<List<Integer>> testArrayOfArrayOfIntegers;
private final List<FeedbackIssue> testArrayOfObjects;
private final Call.XTwilioWebhookEnabled xTwilioWebhookEnabled;
private final Call.Status status;

@JsonCreator
private Call(
Expand Down Expand Up @@ -250,13 +207,7 @@ private Call(
final List<List<Integer>> testArrayOfArrayOfIntegers,

@JsonProperty("test_array_of_objects")
final List<FeedbackIssue> testArrayOfObjects,

@JsonProperty("x_twilio_webhook_enabled")
final Call.XTwilioWebhookEnabled xTwilioWebhookEnabled,

@JsonProperty("status")
final Call.Status status
final List<FeedbackIssue> testArrayOfObjects
) {
this.accountSid = accountSid;
this.sid = sid;
Expand All @@ -271,8 +222,6 @@ private Call(
this.testArrayOfIntegers = testArrayOfIntegers;
this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers;
this.testArrayOfObjects = testArrayOfObjects;
this.xTwilioWebhookEnabled = xTwilioWebhookEnabled;
this.status = status;
}

public final String getAccountSid() {
Expand Down Expand Up @@ -314,12 +263,6 @@ public final List<List<Integer>> getTestArrayOfArrayOfIntegers() {
public final List<FeedbackIssue> getTestArrayOfObjects() {
return this.testArrayOfObjects;
}
public final Call.XTwilioWebhookEnabled getXTwilioWebhookEnabled() {
return this.xTwilioWebhookEnabled;
}
public final Call.Status getStatus() {
return this.status;
}

@Override
public boolean equals(final Object o) {
Expand All @@ -333,12 +276,12 @@ public boolean equals(final Object o) {

Call other = (Call) o;

return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) && Objects.equals(testObject, other.testObject) && Objects.equals(testDateTime, other.testDateTime) && Objects.equals(testNumber, other.testNumber) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(testNumberFloat, other.testNumberFloat) && Objects.equals(testEnum, other.testEnum) && Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && Objects.equals(testArrayOfObjects, other.testArrayOfObjects) && Objects.equals(xTwilioWebhookEnabled, other.xTwilioWebhookEnabled) && Objects.equals(status, other.status) ;
return Objects.equals(accountSid, other.accountSid) && Objects.equals(sid, other.sid) && Objects.equals(testString, other.testString) && Objects.equals(testInteger, other.testInteger) && Objects.equals(testObject, other.testObject) && Objects.equals(testDateTime, other.testDateTime) && Objects.equals(testNumber, other.testNumber) && Objects.equals(priceUnit, other.priceUnit) && Objects.equals(testNumberFloat, other.testNumberFloat) && Objects.equals(testEnum, other.testEnum) && Objects.equals(testArrayOfIntegers, other.testArrayOfIntegers) && Objects.equals(testArrayOfArrayOfIntegers, other.testArrayOfArrayOfIntegers) && Objects.equals(testArrayOfObjects, other.testArrayOfObjects) ;
}

@Override
public int hashCode() {
return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, xTwilioWebhookEnabled, status);
return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public CallCreator setTestArrayOfStrings(final List<String> testArrayOfStrings){

@Override
public Call create(final TwilioRestClient client){
String path = "/2010-04-01/Accounts/{AccountSid}/Calls.json";
String path = "/2010-04-01/Accounts/{AccountSid}/Calls.json";

this.accountSid = this.accountSid == null ? client.getAccountSid() : this.accountSid;
path = path.replace("{"+"AccountSid"+"}", this.accountSid.toString());
path = path.replace("{"+"RequiredStringProperty"+"}", this.requiredStringProperty.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.twilio.rest.api.v2010.account;

import com.twilio.base.Deleter;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.converter.PrefixedCollapsibleMap;
import com.twilio.exception.ApiException;
Expand Down Expand Up @@ -68,7 +69,8 @@ public CallDeleter(final String accountSid, final Integer testInteger){

@Override
public boolean delete(final TwilioRestClient client) {
String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json";
String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json";

this.accountSid = this.accountSid == null ? client.getAccountSid() : this.accountSid;
path = path.replace("{"+"AccountSid"+"}", this.accountSid.toString());
path = path.replace("{"+"TestInteger"+"}", this.testInteger.toString());
Expand Down
Loading