diff --git a/examples/go/go-client/helper/rest/api/v2010/README.md b/examples/go/go-client/helper/rest/api/v2010/README.md index f2a08bf6c..8aacd3ebc 100644 --- a/examples/go/go-client/helper/rest/api/v2010/README.md +++ b/examples/go/go-client/helper/rest/api/v2010/README.md @@ -49,12 +49,12 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [ListAccountResponse](docs/ListAccountResponse.md) - [ListCredentialAwsResponse](docs/ListCredentialAwsResponse.md) - - [ListCredentialAwsResponseMeta](docs/ListCredentialAwsResponseMeta.md) + - [ListAccountResponse](docs/ListAccountResponse.md) + - [TestResponseObjectTestObject](docs/TestResponseObjectTestObject.md) - [TestResponseObject](docs/TestResponseObject.md) + - [ListCredentialAwsResponseMeta](docs/ListCredentialAwsResponseMeta.md) - [TestResponseObjectTestArrayOfObjects](docs/TestResponseObjectTestArrayOfObjects.md) - - [TestResponseObjectTestObject](docs/TestResponseObjectTestObject.md) ## Documentation For Authorization diff --git a/examples/go/go-client/helper/rest/api/v2010/api_test.go b/examples/go/go-client/helper/rest/api/v2010/api_test.go index 043511d06..2dad8792c 100644 --- a/examples/go/go-client/helper/rest/api/v2010/api_test.go +++ b/examples/go/go-client/helper/rest/api/v2010/api_test.go @@ -47,7 +47,7 @@ func TestPost(t *testing.T) { params.SetTestNumberInt64(222) params.SetTestDateTime(time.Now()) params.SetTestDate("2022-01-01") - params.SetTestEnum("consumer-checking") + params.SetTestEnum("completed") // "Any" type should expect any type of value. We'll test with an array of maps, but any type should work. params.SetTestAnyType([]map[string]interface{}{{ @@ -116,7 +116,7 @@ func TestCustomHeaders(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, resp) assert.Equal(t, float32(100.22), *resp.TestNumberFloat) - assert.Equal(t, "Trunking", *resp.TestEnum) + assert.Equal(t, "completed", *resp.TestEnum) } func TestRequiredParameters(t *testing.T) { diff --git a/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go b/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go index 3bd88e611..f9653a35d 100644 --- a/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go +++ b/examples/go/go-client/helper/rest/api/v2010/model_test_response_object.go @@ -35,6 +35,8 @@ type TestResponseObject struct { TestArrayOfIntegers []int `json:"test_array_of_integers,omitempty"` TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers,omitempty"` TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjects `json:"test_array_of_objects,omitempty"` + // Permissions authorized to the app + TestArrayOfEnum *[]string `json:"test_array_of_enum,omitempty"` } func (response *TestResponseObject) UnmarshalJSON(bytes []byte) (err error) { @@ -52,6 +54,7 @@ func (response *TestResponseObject) UnmarshalJSON(bytes []byte) (err error) { TestArrayOfIntegers []int `json:"test_array_of_integers"` TestArrayOfArrayOfIntegers [][]int `json:"test_array_of_array_of_integers"` TestArrayOfObjects *[]TestResponseObjectTestArrayOfObjects `json:"test_array_of_objects"` + TestArrayOfEnum *[]string `json:"test_array_of_enum"` }{} if err = json.Unmarshal(bytes, &raw); err != nil { @@ -70,6 +73,7 @@ func (response *TestResponseObject) UnmarshalJSON(bytes []byte) (err error) { TestArrayOfIntegers: raw.TestArrayOfIntegers, TestArrayOfArrayOfIntegers: raw.TestArrayOfArrayOfIntegers, TestArrayOfObjects: raw.TestArrayOfObjects, + TestArrayOfEnum: raw.TestArrayOfEnum, } responseTestNumber, err := client.UnmarshalFloat32(raw.TestNumber) diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java index 8886932ff..3bc27c3e3 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/Account.java @@ -72,7 +72,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Account extends Resource { - private static final long serialVersionUID = 259833493148625L; + private static final long serialVersionUID = 195758856312528L; public static AccountCreator creator(){ return new AccountCreator(); @@ -162,25 +162,6 @@ public static Status forValue(final String value) { return Promoter.enumFromString(value, Status.values()); } } - public enum TestEnum { - DIALVERB("DialVerb"), - TRUNKING("Trunking"); - - private final String value; - - private TestEnum(final String value) { - this.value = value; - } - - public String toString() { - return value; - } - - @JsonCreator - public static TestEnum forValue(final String value) { - return Promoter.enumFromString(value, TestEnum.values()); - } - } public enum XTwilioWebhookEnabled { TRUE("true"), FALSE("false"); @@ -210,10 +191,11 @@ public static XTwilioWebhookEnabled forValue(final String value) { private final BigDecimal testNumber; private final Currency priceUnit; private final Float testNumberFloat; - private final Account.TestEnum testEnum; + private final Account.Status testEnum; private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; + private final List testArrayOfEnum; @JsonCreator private Account( @@ -246,7 +228,7 @@ private Account( final Float testNumberFloat, @JsonProperty("test_enum") - final Account.TestEnum testEnum, + final Account.Status testEnum, @JsonProperty("test_array_of_integers") final List testArrayOfIntegers, @@ -255,7 +237,10 @@ private Account( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects + final List testArrayOfObjects, + + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum ) { this.accountSid = accountSid; this.sid = sid; @@ -270,6 +255,7 @@ private Account( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; + this.testArrayOfEnum = testArrayOfEnum; } public final String getAccountSid() { @@ -299,7 +285,7 @@ public final Currency getPriceUnit() { public final Float getTestNumberFloat() { return this.testNumberFloat; } - public final Account.TestEnum getTestEnum() { + public final Account.Status getTestEnum() { return this.testEnum; } public final List getTestArrayOfIntegers() { @@ -311,6 +297,9 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } + public final List getTestArrayOfEnum() { + return this.testArrayOfEnum; + } @Override public boolean equals(final Object o) { @@ -324,12 +313,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) ; + 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(testArrayOfEnum, other.testArrayOfEnum) ; } @Override public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects); + return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java index cd01cbcdf..fa08c5ded 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/Call.java @@ -72,7 +72,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Call extends Resource { - private static final long serialVersionUID = 67961494484503L; + private static final long serialVersionUID = 193205363285633L; public static CallCreator creator(final String requiredStringProperty){ return new CallCreator(requiredStringProperty); @@ -133,13 +133,17 @@ public static Call fromJson(final InputStream json, final ObjectMapper objectMap 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; } @@ -148,8 +152,8 @@ 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()); } } @@ -162,10 +166,11 @@ public static TestEnum forValue(final String value) { private final BigDecimal testNumber; private final Currency priceUnit; private final Float testNumberFloat; - private final Call.TestEnum testEnum; + private final Call.Status testEnum; private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; + private final List testArrayOfEnum; @JsonCreator private Call( @@ -198,7 +203,7 @@ private Call( final Float testNumberFloat, @JsonProperty("test_enum") - final Call.TestEnum testEnum, + final Call.Status testEnum, @JsonProperty("test_array_of_integers") final List testArrayOfIntegers, @@ -207,7 +212,10 @@ private Call( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects + final List testArrayOfObjects, + + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum ) { this.accountSid = accountSid; this.sid = sid; @@ -222,6 +230,7 @@ private Call( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; + this.testArrayOfEnum = testArrayOfEnum; } public final String getAccountSid() { @@ -251,7 +260,7 @@ public final Currency getPriceUnit() { public final Float getTestNumberFloat() { return this.testNumberFloat; } - public final Call.TestEnum getTestEnum() { + public final Call.Status getTestEnum() { return this.testEnum; } public final List getTestArrayOfIntegers() { @@ -263,6 +272,9 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } + public final List getTestArrayOfEnum() { + return this.testArrayOfEnum; + } @Override public boolean equals(final Object o) { @@ -276,12 +288,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) ; + 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(testArrayOfEnum, other.testArrayOfEnum) ; } @Override public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects); + return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java index c36cd8ee4..daf9c922e 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummary.java @@ -72,7 +72,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class FeedbackCallSummary extends Resource { - private static final long serialVersionUID = 67961494484503L; + private static final long serialVersionUID = 193205363285633L; public static FeedbackCallSummaryCreator creator(final LocalDate endDate, final LocalDate startDate){ return new FeedbackCallSummaryCreator(endDate, startDate); @@ -121,13 +121,17 @@ public static FeedbackCallSummary fromJson(final InputStream json, final ObjectM 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; } @@ -136,8 +140,8 @@ 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()); } } @@ -150,10 +154,11 @@ public static TestEnum forValue(final String value) { private final BigDecimal testNumber; private final Currency priceUnit; private final Float testNumberFloat; - private final FeedbackCallSummary.TestEnum testEnum; + private final FeedbackCallSummary.Status testEnum; private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; + private final List testArrayOfEnum; @JsonCreator private FeedbackCallSummary( @@ -186,7 +191,7 @@ private FeedbackCallSummary( final Float testNumberFloat, @JsonProperty("test_enum") - final FeedbackCallSummary.TestEnum testEnum, + final FeedbackCallSummary.Status testEnum, @JsonProperty("test_array_of_integers") final List testArrayOfIntegers, @@ -195,7 +200,10 @@ private FeedbackCallSummary( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects + final List testArrayOfObjects, + + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum ) { this.accountSid = accountSid; this.sid = sid; @@ -210,6 +218,7 @@ private FeedbackCallSummary( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; + this.testArrayOfEnum = testArrayOfEnum; } public final String getAccountSid() { @@ -239,7 +248,7 @@ public final Currency getPriceUnit() { public final Float getTestNumberFloat() { return this.testNumberFloat; } - public final FeedbackCallSummary.TestEnum getTestEnum() { + public final FeedbackCallSummary.Status getTestEnum() { return this.testEnum; } public final List getTestArrayOfIntegers() { @@ -251,6 +260,9 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } + public final List getTestArrayOfEnum() { + return this.testArrayOfEnum; + } @Override public boolean equals(final Object o) { @@ -264,12 +276,12 @@ public boolean equals(final Object o) { FeedbackCallSummary other = (FeedbackCallSummary) 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) ; + 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(testArrayOfEnum, other.testArrayOfEnum) ; } @Override public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects); + return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/Aws.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/Aws.java index 1a5a605b9..519d3528d 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/Aws.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/Aws.java @@ -72,7 +72,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class Aws extends Resource { - private static final long serialVersionUID = 204159094531598L; + private static final long serialVersionUID = 91236299650619L; public static AwsFetcher fetcher(final String sid){ @@ -127,13 +127,17 @@ public static Aws fromJson(final InputStream json, final ObjectMapper objectMapp 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; } @@ -142,8 +146,8 @@ 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()); } } @@ -156,10 +160,11 @@ public static TestEnum forValue(final String value) { private final BigDecimal testNumber; private final Currency priceUnit; private final Float testNumberFloat; - private final Aws.TestEnum testEnum; + private final Aws.Status testEnum; private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; + private final List testArrayOfEnum; @JsonCreator private Aws( @@ -192,7 +197,7 @@ private Aws( final Float testNumberFloat, @JsonProperty("test_enum") - final Aws.TestEnum testEnum, + final Aws.Status testEnum, @JsonProperty("test_array_of_integers") final List testArrayOfIntegers, @@ -201,7 +206,10 @@ private Aws( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects + final List testArrayOfObjects, + + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum ) { this.accountSid = accountSid; this.sid = sid; @@ -216,6 +224,7 @@ private Aws( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; + this.testArrayOfEnum = testArrayOfEnum; } public final String getAccountSid() { @@ -245,7 +254,7 @@ public final Currency getPriceUnit() { public final Float getTestNumberFloat() { return this.testNumberFloat; } - public final Aws.TestEnum getTestEnum() { + public final Aws.Status getTestEnum() { return this.testEnum; } public final List getTestArrayOfIntegers() { @@ -257,6 +266,9 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } + public final List getTestArrayOfEnum() { + return this.testArrayOfEnum; + } @Override public boolean equals(final Object o) { @@ -270,12 +282,12 @@ public boolean equals(final Object o) { Aws other = (Aws) 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) ; + 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(testArrayOfEnum, other.testArrayOfEnum) ; } @Override public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects); + return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentials.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentials.java index e21128eb1..995d048b4 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentials.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentials.java @@ -72,7 +72,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) @ToString public class NewCredentials extends Resource { - private static final long serialVersionUID = 204159094531598L; + private static final long serialVersionUID = 91236299650619L; public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Float testNumberFloat){ return new NewCredentialsCreator(testString, testInteger, testNumberFloat); @@ -146,13 +146,17 @@ public static Permissions forValue(final String value) { return Promoter.enumFromString(value, Permissions.values()); } } - 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; } @@ -161,8 +165,8 @@ 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()); } } @@ -175,10 +179,11 @@ public static TestEnum forValue(final String value) { private final BigDecimal testNumber; private final Currency priceUnit; private final Float testNumberFloat; - private final NewCredentials.TestEnum testEnum; + private final NewCredentials.Status testEnum; private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; + private final List testArrayOfEnum; @JsonCreator private NewCredentials( @@ -211,7 +216,7 @@ private NewCredentials( final Float testNumberFloat, @JsonProperty("test_enum") - final NewCredentials.TestEnum testEnum, + final NewCredentials.Status testEnum, @JsonProperty("test_array_of_integers") final List testArrayOfIntegers, @@ -220,7 +225,10 @@ private NewCredentials( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects + final List testArrayOfObjects, + + @JsonProperty("test_array_of_enum") + final List testArrayOfEnum ) { this.accountSid = accountSid; this.sid = sid; @@ -235,6 +243,7 @@ private NewCredentials( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; + this.testArrayOfEnum = testArrayOfEnum; } public final String getAccountSid() { @@ -264,7 +273,7 @@ public final Currency getPriceUnit() { public final Float getTestNumberFloat() { return this.testNumberFloat; } - public final NewCredentials.TestEnum getTestEnum() { + public final NewCredentials.Status getTestEnum() { return this.testEnum; } public final List getTestArrayOfIntegers() { @@ -276,6 +285,9 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } + public final List getTestArrayOfEnum() { + return this.testArrayOfEnum; + } @Override public boolean equals(final Object o) { @@ -289,12 +301,12 @@ public boolean equals(final Object o) { NewCredentials other = (NewCredentials) 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) ; + 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(testArrayOfEnum, other.testArrayOfEnum) ; } @Override public int hashCode() { - return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects); + return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects, testArrayOfEnum); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentialsCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentialsCreator.java index fae9e6789..363ae468e 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentialsCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/NewCredentialsCreator.java @@ -72,7 +72,7 @@ public class NewCredentialsCreator extends Creator{ private Map testObject; private ZonedDateTime testDateTime; private LocalDate testDate; - private NewCredentials.TestEnum testEnum; + private NewCredentials.Status testEnum; private List testObjectArray; private Map testAnyType; private List permissions; @@ -142,7 +142,7 @@ public NewCredentialsCreator setTestDate(final LocalDate testDate){ this.testDate = testDate; return this; } - public NewCredentialsCreator setTestEnum(final NewCredentials.TestEnum testEnum){ + public NewCredentialsCreator setTestEnum(final NewCredentials.Status testEnum){ this.testEnum = testEnum; return this; } diff --git a/examples/java/unit-test/rest/TwilioRestTest.java b/examples/java/unit-test/rest/TwilioRestTest.java index 97ad62fce..7a64a7bc1 100644 --- a/examples/java/unit-test/rest/TwilioRestTest.java +++ b/examples/java/unit-test/rest/TwilioRestTest.java @@ -434,7 +434,7 @@ public void testObjectArrayTypeParamNullResponseNewCredentialsCreator() { permissions.add(NewCredentials.Permissions.GET_ALL); permissions.add(NewCredentials.Permissions.POST_ALL); credentialsCreator.setPermissions( permissions); - credentialsCreator.setTestEnum(NewCredentials.TestEnum.DIALVERB); + credentialsCreator.setTestEnum(NewCredentials.Status.PAUSED); LocalDate localDate = LocalDate.now(); ZonedDateTime zonedDateTime = ZonedDateTime.now(); credentialsCreator.setTestDate(localDate); @@ -952,11 +952,9 @@ public void testAccountCrud() { @Test public void testAccountVariables() { - Account.TestEnum testEnum = Account.TestEnum.forValue("DialVerb"); Account.XTwilioWebhookEnabled xTwilioWebhookEnabled = Account.XTwilioWebhookEnabled.forValue("true"); Account.Status status = Account.Status.forValue("paused"); - assertEquals("DialVerb", testEnum.toString()); assertEquals("true", xTwilioWebhookEnabled.toString()); assertEquals("paused", status.toString()); } @@ -1043,8 +1041,8 @@ public void testAccountObjectCreationInvalidInputStream() { @Test public void testCallGetters() { ObjectMapper objectMapper = new ObjectMapper(); - String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\"}"; - String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\"}"; + String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"paused\"}"; + String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"paused\"}"; Call call = Call.fromJson(json, objectMapper); Call callDuplicate = Call.fromJson(jsonDuplicate, objectMapper); @@ -1056,7 +1054,7 @@ public void testCallGetters() { assertEquals(BigDecimal.valueOf(123.1), call.getTestNumber()); assertNull(call.getPriceUnit()); assertEquals(Float.valueOf("123.2"), call.getTestNumberFloat()); - assertEquals("Trunking", call.getTestEnum().toString()); + assertEquals("paused", call.getTestEnum().toString()); assertNull(call.getTestArrayOfIntegers()); assertNull(call.getTestArrayOfArrayOfIntegers()); assertNull(call.getTestArrayOfObjects()); @@ -1072,10 +1070,10 @@ public void testCallGetters() { @Test public void testAwsGetters() { ObjectMapper objectMapper = new ObjectMapper(); - String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\", " + - "\"testEnum\": \"Trunking\"}"; - String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\", " + - "\"testEnum\": \"Trunking\"}"; + String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, " + + "\"testEnum\": \"paused\"}"; + String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, " + + "\"testEnum\": \"paused\"}"; Aws aws = Aws.fromJson(json, objectMapper); Aws awsDuplicate = Aws.fromJson(jsonDuplicate, objectMapper); @@ -1087,7 +1085,7 @@ public void testAwsGetters() { assertEquals(BigDecimal.valueOf(123.1), aws.getTestNumber()); assertNull(aws.getPriceUnit()); assertEquals(Float.valueOf("123.2"), aws.getTestNumberFloat()); - assertEquals("Trunking", aws.getTestEnum().toString()); + assertEquals(Aws.Status.PAUSED.toString(), aws.getTestEnum().toString()); assertNull(aws.getTestArrayOfIntegers()); assertNull(aws.getTestArrayOfArrayOfIntegers()); assertNull(aws.getTestArrayOfObjects()); @@ -1103,8 +1101,8 @@ public void testAwsGetters() { @Test public void testNewCredentialsGetters() { final ObjectMapper objectMapper = new ObjectMapper(); - final String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\", " + - "\"testEnum\": \"Trunking\"}"; + final String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"paused\", " + + "\"testEnum\": \"paused\"}"; final NewCredentials credentials = NewCredentials.fromJson(json, objectMapper); final NewCredentials credentialsDuplicate = NewCredentials.fromJson(json, objectMapper); @@ -1117,7 +1115,7 @@ public void testNewCredentialsGetters() { assertEquals(BigDecimal.valueOf(123.1), credentials.getTestNumber()); assertNull(credentials.getPriceUnit()); assertEquals(Float.valueOf("123.2"), credentials.getTestNumberFloat()); - assertEquals("Trunking", credentials.getTestEnum().toString()); + assertEquals("paused", credentials.getTestEnum().toString()); assertNull(credentials.getTestArrayOfIntegers()); assertNull(credentials.getTestArrayOfArrayOfIntegers()); assertNull(credentials.getTestArrayOfObjects()); @@ -1131,10 +1129,8 @@ public void testNewCredentialsGetters() { @Test public void testAccountGetters() { ObjectMapper objectMapper = new ObjectMapper(); - String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\", " + - "\"testEnum\": \"Trunking\"}"; - String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\", " + - "\"testEnum\": \"Trunking\"}"; + String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"paused\"}"; + String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"paused\"}"; Account account = Account.fromJson(json, objectMapper); Account accountDuplicate = Account.fromJson(jsonDuplicate, objectMapper); @@ -1146,7 +1142,7 @@ public void testAccountGetters() { assertEquals(BigDecimal.valueOf(123.1), account.getTestNumber()); assertNull(account.getPriceUnit()); assertEquals(Float.valueOf("123.2"), account.getTestNumberFloat()); - assertEquals("Trunking", account.getTestEnum().toString()); + assertEquals(Account.Status.PAUSED.toString(), account.getTestEnum().toString()); assertNull(account.getTestArrayOfIntegers()); assertNull(account.getTestArrayOfArrayOfIntegers()); assertNull(account.getTestArrayOfObjects()); @@ -1291,10 +1287,8 @@ public void testFeedbackCallSummaryObjectCreationResponseNotSuccess() { @Test public void testFeedbackCallSummaryObjectCreationFromString() { - String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\", " + - "\"status\": \"paused\"}"; - String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"Trunking\", " + - "\"status\": \"paused\"}"; + String json = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"paused\"}"; + String jsonDuplicate = "{\"accountSid\": \"a123\", \"sid\": \"123\", \"testInteger\": 123, \"testNumber\": 123.1, \"testNumberFloat\": 123.2, \"testEnum\": \"paused\"}"; ObjectMapper objectMapper = new ObjectMapper(); FeedbackCallSummary feedbackCallSummary = FeedbackCallSummary.fromJson(json, objectMapper); @@ -1308,7 +1302,7 @@ public void testFeedbackCallSummaryObjectCreationFromString() { assertEquals(BigDecimal.valueOf(123.1), feedbackCallSummary.getTestNumber()); assertNull(feedbackCallSummary.getPriceUnit()); assertEquals(Float.valueOf("123.2"), feedbackCallSummary.getTestNumberFloat()); - assertEquals("Trunking", feedbackCallSummary.getTestEnum().toString()); + assertEquals(FeedbackCallSummary.Status.PAUSED.toString(), feedbackCallSummary.getTestEnum().toString()); assertNull(feedbackCallSummary.getTestArrayOfIntegers()); assertNull(feedbackCallSummary.getTestArrayOfArrayOfIntegers()); assertNull(feedbackCallSummary.getTestArrayOfObjects()); diff --git a/examples/node/lib/rest/api/v2010/accounts.ts b/examples/node/lib/rest/api/v2010/accounts.ts index 658dbfc6c..1a871df12 100644 --- a/examples/node/lib/rest/api/v2010/accounts.ts +++ b/examples/node/lib/rest/api/v2010/accounts.ts @@ -21,11 +21,11 @@ import { CallListInstance } from './Accounts/Calls'; /** * Options to pass to update a AccountInstance * - * @property { string } status + * @property { TestEnumStatus } status * @property { string } [pauseBehavior] */ export interface AccountContextUpdateOptions { - status: string; + status: TestEnumStatus; pauseBehavior?: string; } @@ -194,7 +194,6 @@ export class AccountContextImpl implements AccountContext { } } -export type AccountTestEnum = 'DialVerb'|'Trunking'; interface AccountPayload extends AccountResource, Page.TwilioResponsePayload { } @@ -209,10 +208,11 @@ interface AccountResource { test_number?: number | null; price_unit?: string | null; test_number_float?: number | null; - test_enum?: AccountTestEnum; + test_enum?: object; test_array_of_integers?: Array; test_array_of_array_of_integers?: Array>; test_array_of_objects?: Array | null; + test_array_of_enum?: Array | null; } export class AccountInstance { @@ -233,6 +233,7 @@ export class AccountInstance { this.testArrayOfIntegers = payload.test_array_of_integers; this.testArrayOfArrayOfIntegers = payload.test_array_of_array_of_integers; this.testArrayOfObjects = payload.test_array_of_objects; + this.testArrayOfEnum = payload.test_array_of_enum; this._solution = { sid: sid || this.sid }; } @@ -246,10 +247,14 @@ export class AccountInstance { testNumber?: number | null; priceUnit?: string | null; testNumberFloat?: number | null; - testEnum?: AccountTestEnum; + testEnum?: object; testArrayOfIntegers?: Array; testArrayOfArrayOfIntegers?: Array>; testArrayOfObjects?: Array | null; + /** + * Permissions authorized to the app + */ + testArrayOfEnum?: Array | null; private get _proxy(): AccountContext { this._context = this._context || new AccountContextImpl(this._version, this._solution.sid); @@ -320,7 +325,8 @@ export class AccountInstance { testEnum: this.testEnum, testArrayOfIntegers: this.testArrayOfIntegers, testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers, - testArrayOfObjects: this.testArrayOfObjects + testArrayOfObjects: this.testArrayOfObjects, + testArrayOfEnum: this.testArrayOfEnum } } diff --git a/examples/node/lib/rest/api/v2010/accounts/calls.ts b/examples/node/lib/rest/api/v2010/accounts/calls.ts index 711832ca7..6102848a9 100644 --- a/examples/node/lib/rest/api/v2010/accounts/calls.ts +++ b/examples/node/lib/rest/api/v2010/accounts/calls.ts @@ -214,7 +214,6 @@ export class CallContextImpl implements CallContext { } } -export type CallTestEnum = 'DialVerb'|'Trunking'; interface CallPayload extends CallResource, Page.TwilioResponsePayload { } @@ -229,10 +228,11 @@ interface CallResource { test_number?: number | null; price_unit?: string | null; test_number_float?: number | null; - test_enum?: CallTestEnum; + test_enum?: object; test_array_of_integers?: Array; test_array_of_array_of_integers?: Array>; test_array_of_objects?: Array | null; + test_array_of_enum?: Array | null; } export class CallInstance { @@ -253,6 +253,7 @@ export class CallInstance { this.testArrayOfIntegers = payload.test_array_of_integers; this.testArrayOfArrayOfIntegers = payload.test_array_of_array_of_integers; this.testArrayOfObjects = payload.test_array_of_objects; + this.testArrayOfEnum = payload.test_array_of_enum; this._solution = { accountSid, testInteger: testInteger || this.testInteger }; } @@ -266,10 +267,14 @@ export class CallInstance { testNumber?: number | null; priceUnit?: string | null; testNumberFloat?: number | null; - testEnum?: CallTestEnum; + testEnum?: object; testArrayOfIntegers?: Array; testArrayOfArrayOfIntegers?: Array>; testArrayOfObjects?: Array | null; + /** + * Permissions authorized to the app + */ + testArrayOfEnum?: Array | null; private get _proxy(): CallContext { this._context = this._context || new CallContextImpl(this._version, this._solution.accountSid, this._solution.testInteger); @@ -319,7 +324,8 @@ export class CallInstance { testEnum: this.testEnum, testArrayOfIntegers: this.testArrayOfIntegers, testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers, - testArrayOfObjects: this.testArrayOfObjects + testArrayOfObjects: this.testArrayOfObjects, + testArrayOfEnum: this.testArrayOfEnum } } diff --git a/examples/node/lib/rest/api/v2010/accounts/calls/feedbackSummary.ts b/examples/node/lib/rest/api/v2010/accounts/calls/feedbackSummary.ts index e51ad9ccb..3bf03690b 100644 --- a/examples/node/lib/rest/api/v2010/accounts/calls/feedbackSummary.ts +++ b/examples/node/lib/rest/api/v2010/accounts/calls/feedbackSummary.ts @@ -112,7 +112,6 @@ export function FeedbackSummaryListInstance(version: V2010, accountSid: string): return instance; } -export type FeedbackSummaryTestEnum = 'DialVerb'|'Trunking'; interface FeedbackSummaryPayload extends FeedbackSummaryResource, Page.TwilioResponsePayload { } @@ -127,10 +126,11 @@ interface FeedbackSummaryResource { test_number?: number | null; price_unit?: string | null; test_number_float?: number | null; - test_enum?: FeedbackSummaryTestEnum; + test_enum?: object; test_array_of_integers?: Array; test_array_of_array_of_integers?: Array>; test_array_of_objects?: Array | null; + test_array_of_enum?: Array | null; } export class FeedbackSummaryInstance { @@ -151,6 +151,7 @@ export class FeedbackSummaryInstance { this.testArrayOfIntegers = payload.test_array_of_integers; this.testArrayOfArrayOfIntegers = payload.test_array_of_array_of_integers; this.testArrayOfObjects = payload.test_array_of_objects; + this.testArrayOfEnum = payload.test_array_of_enum; this._solution = { accountSid: accountSid || this.accountSid }; } @@ -164,10 +165,14 @@ export class FeedbackSummaryInstance { testNumber?: number | null; priceUnit?: string | null; testNumberFloat?: number | null; - testEnum?: FeedbackSummaryTestEnum; + testEnum?: object; testArrayOfIntegers?: Array; testArrayOfArrayOfIntegers?: Array>; testArrayOfObjects?: Array | null; + /** + * Permissions authorized to the app + */ + testArrayOfEnum?: Array | null; /** * Provide a user-friendly representation @@ -188,7 +193,8 @@ export class FeedbackSummaryInstance { testEnum: this.testEnum, testArrayOfIntegers: this.testArrayOfIntegers, testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers, - testArrayOfObjects: this.testArrayOfObjects + testArrayOfObjects: this.testArrayOfObjects, + testArrayOfEnum: this.testArrayOfEnum } } diff --git a/examples/node/lib/rest/api/v2010/credentials/aWS.ts b/examples/node/lib/rest/api/v2010/credentials/aWS.ts index a22add2ff..2446fe7ac 100644 --- a/examples/node/lib/rest/api/v2010/credentials/aWS.ts +++ b/examples/node/lib/rest/api/v2010/credentials/aWS.ts @@ -42,7 +42,7 @@ export interface AWSContextUpdateOptions { * @property { object } [testObject] * @property { Date } [testDateTime] * @property { string } [testDate] - * @property { string } [testEnum] + * @property { TestEnumStatus } [testEnum] * @property { Array } [testObjectArray] * @property { any } [testAnyType] * @property { Array } [permissions] A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`. @@ -59,7 +59,7 @@ export interface AWSListInstanceCreateOptions { testObject?: object; testDateTime?: Date; testDate?: string; - testEnum?: string; + testEnum?: TestEnumStatus; testObjectArray?: Array; testAnyType?: any; permissions?: Array; @@ -209,7 +209,6 @@ export class AWSContextImpl implements AWSContext { } } -export type AWSTestEnum = 'DialVerb'|'Trunking'; interface AWSPayload extends AWSResource, Page.TwilioResponsePayload { } @@ -224,10 +223,11 @@ interface AWSResource { test_number?: number | null; price_unit?: string | null; test_number_float?: number | null; - test_enum?: AWSTestEnum; + test_enum?: object; test_array_of_integers?: Array; test_array_of_array_of_integers?: Array>; test_array_of_objects?: Array | null; + test_array_of_enum?: Array | null; } export class AWSInstance { @@ -248,6 +248,7 @@ export class AWSInstance { this.testArrayOfIntegers = payload.test_array_of_integers; this.testArrayOfArrayOfIntegers = payload.test_array_of_array_of_integers; this.testArrayOfObjects = payload.test_array_of_objects; + this.testArrayOfEnum = payload.test_array_of_enum; this._solution = { sid: sid || this.sid }; } @@ -261,10 +262,14 @@ export class AWSInstance { testNumber?: number | null; priceUnit?: string | null; testNumberFloat?: number | null; - testEnum?: AWSTestEnum; + testEnum?: object; testArrayOfIntegers?: Array; testArrayOfArrayOfIntegers?: Array>; testArrayOfObjects?: Array | null; + /** + * Permissions authorized to the app + */ + testArrayOfEnum?: Array | null; private get _proxy(): AWSContext { this._context = this._context || new AWSContextImpl(this._version, this._solution.sid); @@ -336,7 +341,8 @@ export class AWSInstance { testEnum: this.testEnum, testArrayOfIntegers: this.testArrayOfIntegers, testArrayOfArrayOfIntegers: this.testArrayOfArrayOfIntegers, - testArrayOfObjects: this.testArrayOfObjects + testArrayOfObjects: this.testArrayOfObjects, + testArrayOfEnum: this.testArrayOfEnum } } diff --git a/examples/twilio_api_v2010.yaml b/examples/twilio_api_v2010.yaml index 05e20db7a..f61e28616 100644 --- a/examples/twilio_api_v2010.yaml +++ b/examples/twilio_api_v2010.yaml @@ -1,5 +1,14 @@ components: schemas: + test_enum_status: + enum: + - in-progress + - paused + - stopped + - processing + - completed + - absent + type: string test.response_object: properties: account_sid: @@ -45,9 +54,7 @@ components: type: number format: float test_enum: - enum: - - DialVerb - - Trunking + $ref: '#/components/schemas/test_enum_status' nullable: true type: string test_array_of_integers: @@ -71,6 +78,13 @@ components: type: object nullable: true type: array + test_array_of_enum: + description: Permissions authorized to the app + items: + $ref: '#/components/schemas/test_enum_status' + type: string + nullable: true + type: array type: object examples: test.response_object.example: @@ -83,7 +97,7 @@ components: sms: true voice: true test_number_float: 100.22 - test_enum: "Trunking" + test_enum: "completed" securitySchemes: accountSid_authToken: scheme: basic @@ -211,10 +225,8 @@ paths: type: string format: date TestEnum: - enum: - - consumer-checking - - consumer-savings - - commercial-checking + $ref: '#/components/schemas/test_enum_status' + type: string TestObjectArray: items: type: object @@ -522,13 +534,7 @@ paths: PauseBehavior: type: string Status: - enum: - - in-progress - - paused - - stopped - - processing - - completed - - absent + $ref: '#/components/schemas/test_enum_status' type: string required: - Status diff --git a/src/main/java/com/twilio/oai/AbstractTwilioGoGenerator.java b/src/main/java/com/twilio/oai/AbstractTwilioGoGenerator.java index 265c94e7a..5815197cc 100644 --- a/src/main/java/com/twilio/oai/AbstractTwilioGoGenerator.java +++ b/src/main/java/com/twilio/oai/AbstractTwilioGoGenerator.java @@ -1,10 +1,7 @@ package com.twilio.oai; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; +import java.util.stream.Collectors; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; @@ -12,9 +9,11 @@ import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponses; import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.languages.GoClientCodegen; +import org.openapitools.codegen.model.ModelsMap; import org.openapitools.codegen.model.OperationMap; import org.openapitools.codegen.model.OperationsMap; import org.openapitools.codegen.model.ModelMap; @@ -113,6 +112,21 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L return objs; } + private Map filterOutEnumResults( Map results) { + HashMap resultMap = new HashMap<>(); + results.forEach((key ,value) -> { + if (!key.contains("_enum_")) { + resultMap.put(key, value); + }}); + return resultMap; + } + + @Override + public Map postProcessAllModels(final Map allModels) { + Map results = filterOutEnumResults(super.postProcessAllModels(allModels)); + return results; + } + @Override protected ApiResponse findMethodResponse(final ApiResponses responses) { final ApiResponse response = super.findMethodResponse(responses); diff --git a/src/main/java/com/twilio/oai/TwilioGoGenerator.java b/src/main/java/com/twilio/oai/TwilioGoGenerator.java index 11762b30e..94dd6d67b 100644 --- a/src/main/java/com/twilio/oai/TwilioGoGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioGoGenerator.java @@ -63,6 +63,44 @@ public ModelsMap postProcessModels(final ModelsMap objs) { return results; } + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + super.postProcessModelProperty(model, property); + if (property.dataType.startsWith("[]") && property.dataType.contains("Enum")) { + property._enum = (List) property.items.allowableValues.get("values"); + property.allowableValues = property.items.allowableValues; + property.dataType = "[]string"; + property.isEnum = property.dataType == null; + property.isNullable = true; + } else if (property.dataType.contains("Enum")) { + String[] value = property.dataType.split("Enum"); + property.datatypeWithEnum = value[value.length-1]; + property.dataType = "string"; + property.isEnum = property.dataFormat == null; + property.isNullable = true; + } + + } + + + private void processEnumParameters(final CodegenParameter parameter) { + if (parameter.dataType.startsWith("[]") && parameter.dataType.contains("Enum")) { + parameter._enum = (List) parameter.items.allowableValues.get("values"); + parameter.allowableValues = parameter.items.allowableValues; + parameter.dataType = "[]string"; + parameter.isEnum = parameter.dataType == null; + parameter.isNullable = true; + } else if (parameter.dataType.contains("Enum")) { + String[] value = parameter.dataType.split("Enum"); + parameter.datatypeWithEnum = value[value.length-1]; + parameter.dataType = "string"; + parameter.isEnum = parameter.dataFormat == null; + parameter.isNullable = true; + } + } + + + @SuppressWarnings("unchecked") @Override public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, List allModels) { final OperationsMap results = super.postProcessOperationsWithModels(objs, allModels); @@ -125,7 +163,7 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L @Override public void postProcessParameter(final CodegenParameter parameter) { super.postProcessParameter(parameter); - + processEnumParameters(parameter); // Make sure required non-path params get into the options block. parameter.required = parameter.isPathParam; parameter.vendorExtensions.put("x-custom", parameter.baseName.equals("limit"));