From ed92e3c401619d2087cb057a2a9d3eda29cc112d Mon Sep 17 00:00:00 2001 From: kridai Date: Wed, 13 Jul 2022 20:50:23 +0530 Subject: [PATCH] fix: java enum type changes (#187) * process enum schemas * fix enum dataType * fix(): enum fix changes * fix(): added enum changes * fix: enum types * fix(): fixing enum issue * fix(): removing iml file * fix delete header param enums * changes for handling preview * fix(): fixing failing test issues * fix url path * fix: incorrect uri issue * refactor path Item operator code * fix: added promotion types support * fix: basic enum types * fix: update examples * fix: enum changes * fix: enum changes * fix: unit test Co-authored-by: chsingh Co-authored-by: sburman --- .../com/twilio/rest/api/v2010/Account.java | 69 ++- .../twilio/rest/api/v2010/AccountCreator.java | 9 +- .../twilio/rest/api/v2010/AccountDeleter.java | 4 +- .../twilio/rest/api/v2010/AccountFetcher.java | 4 +- .../twilio/rest/api/v2010/AccountReader.java | 1 + .../twilio/rest/api/v2010/AccountUpdater.java | 3 +- .../twilio/rest/api/v2010/account/Call.java | 67 +-- .../rest/api/v2010/account/CallCreator.java | 3 +- .../rest/api/v2010/account/CallDeleter.java | 4 +- .../rest/api/v2010/account/CallFetcher.java | 4 +- .../account/call/FeedbackCallSummary.java | 67 +-- .../call/FeedbackCallSummaryCreator.java | 3 +- .../twilio/rest/api/v2010/credential/Aws.java | 67 +-- .../rest/api/v2010/credential/AwsDeleter.java | 4 +- .../rest/api/v2010/credential/AwsFetcher.java | 4 +- .../rest/api/v2010/credential/AwsReader.java | 1 + .../rest/api/v2010/credential/AwsUpdater.java | 3 +- .../api/v2010/credential/NewCredentials.java | 99 +---- .../credential/NewCredentialsCreator.java | 1 + .../java/unit-test/rest/TwilioRestTest.java | 49 +-- .../com/twilio/oai/ConventionResolver.java | 24 +- src/main/java/com/twilio/oai/Inflector.java | 1 + src/main/java/com/twilio/oai/Segments.java | 4 +- .../com/twilio/oai/TwilioJavaGenerator.java | 402 +++++++++++++----- .../oai/mlambdas/ReplaceHyphenLambda.java | 70 +++ src/main/resources/config/java.json | 13 +- src/main/resources/twilio-java/api.mustache | 1 + .../resources/twilio-java/creator.mustache | 31 +- .../resources/twilio-java/deleter.mustache | 32 +- .../resources/twilio-java/fetcher.mustache | 32 +- .../twilio-java/generate_uri.mustache | 21 + .../twilio-java/headerParams.mustache | 6 + .../resources/twilio-java/postParams.mustache | 4 +- .../resources/twilio-java/reader.mustache | 20 + .../twilio-java/responseModel.mustache | 18 +- .../resources/twilio-java/updater.mustache | 31 +- 36 files changed, 643 insertions(+), 533 deletions(-) create mode 100644 src/main/java/com/twilio/oai/mlambdas/ReplaceHyphenLambda.java create mode 100644 src/main/resources/twilio-java/generate_uri.mustache 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 6f33163e5..8886932ff 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 @@ -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(); @@ -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; } @@ -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; } @@ -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; } @@ -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()); } } @@ -213,8 +214,6 @@ public static Status forValue(final String value) { private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; - private final Account.XTwilioWebhookEnabled xTwilioWebhookEnabled; - private final Account.Status status; @JsonCreator private Account( @@ -256,13 +255,7 @@ private Account( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("x_twilio_webhook_enabled") - final Account.XTwilioWebhookEnabled xTwilioWebhookEnabled, - - @JsonProperty("status") - final Account.Status status + final List testArrayOfObjects ) { this.accountSid = accountSid; this.sid = sid; @@ -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() { @@ -320,12 +311,6 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List 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) { @@ -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); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java index 10e75b726..ec8e532e9 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java @@ -76,6 +76,11 @@ 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 recordingStatusCallbackEvent){ this.recordingStatusCallbackEvent = recordingStatusCallbackEvent; return this; @@ -83,7 +88,8 @@ public AccountCreator setRecordingStatusCallbackEvent(final List recordi @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, @@ -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()); + } } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java index c5657c797..ddc07e60d 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java @@ -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; @@ -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()); diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java index c81bf596b..a20780cb7 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java @@ -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; @@ -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()); diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java index b55241916..060f802e9 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java @@ -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; diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java index 8ac5eae14..e787098a4 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java @@ -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()); 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 12ec1f240..cd01cbcdf 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 @@ -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); @@ -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; @@ -207,8 +166,6 @@ public static Status forValue(final String value) { private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; - private final Call.XTwilioWebhookEnabled xTwilioWebhookEnabled; - private final Call.Status status; @JsonCreator private Call( @@ -250,13 +207,7 @@ private Call( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("x_twilio_webhook_enabled") - final Call.XTwilioWebhookEnabled xTwilioWebhookEnabled, - - @JsonProperty("status") - final Call.Status status + final List testArrayOfObjects ) { this.accountSid = accountSid; this.sid = sid; @@ -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() { @@ -314,12 +263,6 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List 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) { @@ -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); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java index 070e43be9..c9cd7691f 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java @@ -84,7 +84,8 @@ public CallCreator setTestArrayOfStrings(final List 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()); diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java index 9e69fbd2c..aa94bf2e0 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java @@ -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; @@ -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()); diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java index 84b438cb2..ff4fbd29f 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010.account; 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; @@ -69,7 +70,8 @@ public CallFetcher(final String accountSid, final Integer testInteger){ @Override public Call fetch(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()); 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 d1dad0d40..c36cd8ee4 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 @@ -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 FeedbackCallSummary extends Resource { - private static final long serialVersionUID = 191475196031556L; + private static final long serialVersionUID = 67961494484503L; public static FeedbackCallSummaryCreator creator(final LocalDate endDate, final LocalDate startDate){ return new FeedbackCallSummaryCreator(endDate, startDate); @@ -139,48 +140,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; @@ -195,8 +154,6 @@ public static Status forValue(final String value) { private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; - private final FeedbackCallSummary.XTwilioWebhookEnabled xTwilioWebhookEnabled; - private final FeedbackCallSummary.Status status; @JsonCreator private FeedbackCallSummary( @@ -238,13 +195,7 @@ private FeedbackCallSummary( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("x_twilio_webhook_enabled") - final FeedbackCallSummary.XTwilioWebhookEnabled xTwilioWebhookEnabled, - - @JsonProperty("status") - final FeedbackCallSummary.Status status + final List testArrayOfObjects ) { this.accountSid = accountSid; this.sid = sid; @@ -259,8 +210,6 @@ private FeedbackCallSummary( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; - this.xTwilioWebhookEnabled = xTwilioWebhookEnabled; - this.status = status; } public final String getAccountSid() { @@ -302,12 +251,6 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } - public final FeedbackCallSummary.XTwilioWebhookEnabled getXTwilioWebhookEnabled() { - return this.xTwilioWebhookEnabled; - } - public final FeedbackCallSummary.Status getStatus() { - return this.status; - } @Override public boolean equals(final Object o) { @@ -321,12 +264,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) && 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); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryCreator.java index 16e62cde5..89444263c 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryCreator.java @@ -86,7 +86,8 @@ public FeedbackCallSummaryCreator setStartDate(final LocalDate startDate){ @Override public FeedbackCallSummary create(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts/{AccountSid}/Calls/FeedbackSummary.json"; + String path = "/2010-04-01/Accounts/{AccountSid}/Calls/FeedbackSummary.json"; + this.accountSid = this.accountSid == null ? client.getAccountSid() : this.accountSid; path = path.replace("{"+"AccountSid"+"}", this.accountSid.toString()); path = path.replace("{"+"EndDate"+"}", this.endDate.toString()); 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 296c8dd36..1a5a605b9 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 @@ -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 Aws extends Resource { - private static final long serialVersionUID = 102879623605645L; + private static final long serialVersionUID = 204159094531598L; public static AwsFetcher fetcher(final String sid){ @@ -145,48 +146,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; @@ -201,8 +160,6 @@ public static Status forValue(final String value) { private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; - private final Aws.XTwilioWebhookEnabled xTwilioWebhookEnabled; - private final Aws.Status status; @JsonCreator private Aws( @@ -244,13 +201,7 @@ private Aws( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("x_twilio_webhook_enabled") - final Aws.XTwilioWebhookEnabled xTwilioWebhookEnabled, - - @JsonProperty("status") - final Aws.Status status + final List testArrayOfObjects ) { this.accountSid = accountSid; this.sid = sid; @@ -265,8 +216,6 @@ private Aws( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; - this.xTwilioWebhookEnabled = xTwilioWebhookEnabled; - this.status = status; } public final String getAccountSid() { @@ -308,12 +257,6 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } - public final Aws.XTwilioWebhookEnabled getXTwilioWebhookEnabled() { - return this.xTwilioWebhookEnabled; - } - public final Aws.Status getStatus() { - return this.status; - } @Override public boolean equals(final Object o) { @@ -327,12 +270,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) && 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); } } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsDeleter.java index 4a581a61d..2b1cedf4b 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsDeleter.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010.credential; 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; @@ -63,7 +64,8 @@ public AwsDeleter(final String sid){ @Override public boolean delete(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}"; + String path = "/v1/Credentials/AWS/{Sid}"; + path = path.replace("{"+"Sid"+"}", this.sid.toString()); Request request = new Request( diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsFetcher.java index 77aefcf48..c48798944 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsFetcher.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010.credential; 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; @@ -64,7 +65,8 @@ public AwsFetcher(final String sid){ @Override public Aws fetch(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}"; + String path = "/v1/Credentials/AWS/{Sid}"; + path = path.replace("{"+"Sid"+"}", this.sid.toString()); Request request = new Request( diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsReader.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsReader.java index 404338766..e061716eb 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsReader.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsReader.java @@ -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; diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsUpdater.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsUpdater.java index c0054fe3f..135f19600 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/credential/AwsUpdater.java @@ -74,7 +74,8 @@ public AwsUpdater setTestBoolean(final Boolean testBoolean){ @Override public Aws update(final TwilioRestClient client){ - String path = "/v1/Credentials/AWS/{Sid}"; + String path = "/v1/Credentials/AWS/{Sid}"; + path = path.replace("{"+"Sid"+"}", this.sid.toString()); Request request = new Request( 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 6357705bd..e21128eb1 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 @@ -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 NewCredentials extends Resource { - private static final long serialVersionUID = 102879623605645L; + private static final long serialVersionUID = 204159094531598L; public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Float testNumberFloat){ return new NewCredentialsCreator(testString, testInteger, testNumberFloat); @@ -126,55 +127,13 @@ public static NewCredentials fromJson(final InputStream json, final ObjectMapper throw new ApiConnectionException(e.getMessage(), e); } } - 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"); - - 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"); + public enum Permissions { + GET_ALL("get-all"), + POST_ALL("post-all"); private final String value; - private Status(final String value) { + private Permissions(final String value) { this.value = value; } @@ -183,17 +142,17 @@ public String toString() { } @JsonCreator - public static Status forValue(final String value) { - return Promoter.enumFromString(value, Status.values()); + public static Permissions forValue(final String value) { + return Promoter.enumFromString(value, Permissions.values()); } } - public enum Permissions { - GET_ALL("get-all"), - POST_ALL("post-all"); + public enum TestEnum { + DIALVERB("DialVerb"), + TRUNKING("Trunking"); private final String value; - private Permissions(final String value) { + private TestEnum(final String value) { this.value = value; } @@ -202,8 +161,8 @@ public String toString() { } @JsonCreator - public static Permissions forValue(final String value) { - return Promoter.enumFromString(value, Permissions.values()); + public static TestEnum forValue(final String value) { + return Promoter.enumFromString(value, TestEnum.values()); } } @@ -220,9 +179,6 @@ public static Permissions forValue(final String value) { private final List testArrayOfIntegers; private final List> testArrayOfArrayOfIntegers; private final List testArrayOfObjects; - private final NewCredentials.XTwilioWebhookEnabled xTwilioWebhookEnabled; - private final NewCredentials.Status status; - private final NewCredentials.Permissions permissions; @JsonCreator private NewCredentials( @@ -264,16 +220,7 @@ private NewCredentials( final List> testArrayOfArrayOfIntegers, @JsonProperty("test_array_of_objects") - final List testArrayOfObjects, - - @JsonProperty("x_twilio_webhook_enabled") - final NewCredentials.XTwilioWebhookEnabled xTwilioWebhookEnabled, - - @JsonProperty("status") - final NewCredentials.Status status, - - @JsonProperty("permissions") - final NewCredentials.Permissions permissions + final List testArrayOfObjects ) { this.accountSid = accountSid; this.sid = sid; @@ -288,9 +235,6 @@ private NewCredentials( this.testArrayOfIntegers = testArrayOfIntegers; this.testArrayOfArrayOfIntegers = testArrayOfArrayOfIntegers; this.testArrayOfObjects = testArrayOfObjects; - this.xTwilioWebhookEnabled = xTwilioWebhookEnabled; - this.status = status; - this.permissions = permissions; } public final String getAccountSid() { @@ -332,15 +276,6 @@ public final List> getTestArrayOfArrayOfIntegers() { public final List getTestArrayOfObjects() { return this.testArrayOfObjects; } - public final NewCredentials.XTwilioWebhookEnabled getXTwilioWebhookEnabled() { - return this.xTwilioWebhookEnabled; - } - public final NewCredentials.Status getStatus() { - return this.status; - } - public final NewCredentials.Permissions getPermissions() { - return this.permissions; - } @Override public boolean equals(final Object o) { @@ -354,12 +289,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) && Objects.equals(xTwilioWebhookEnabled, other.xTwilioWebhookEnabled) && Objects.equals(status, other.status) && Objects.equals(permissions, other.permissions) ; + 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, permissions); + return Objects.hash(accountSid, sid, testString, testInteger, testObject, testDateTime, testNumber, priceUnit, testNumberFloat, testEnum, testArrayOfIntegers, testArrayOfArrayOfIntegers, testArrayOfObjects); } } 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 8fc6abac9..fae9e6789 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 @@ -162,6 +162,7 @@ public NewCredentialsCreator setPermissions(final List resolve(Optional model) { for (CodegenProperty property : model.get().vars) { Map> vendorExtensions = new HashMap<>(); @@ -48,11 +56,25 @@ public static Optional resolveParameter(CodegenParameter param if(parameter.dataType.equalsIgnoreCase(OBJECT)) { parameter.dataType = (String)conventionMap.get(Segments.SEGMENT_PROPERTIES.getSegment()).get(OBJECT); } + boolean hasPromotion = conventionMap.get(Segments.SEGMENT_PROMOTIONS.getSegment()).containsKey(parameter.dataFormat); + if (hasPromotion) { + // cloning to prevent update in source map + HashMap promotionsMap = new HashMap<>((Map) conventionMap + .get(Segments.SEGMENT_PROMOTIONS.getSegment()).get(parameter.dataFormat)); + if(parameter.isArray && conventionMap.get(Segments.SEGMENT_PROMOTIONS.getSegment()).containsKey(LIST_PREFIX+parameter.dataFormat)) { + promotionsMap.put(parameter.baseType, (String) ((Map)conventionMap.get(Segments.SEGMENT_PROMOTIONS.getSegment()).get(LIST_PREFIX+parameter.dataFormat)).get(parameter.dataFormat)); + } + promotionsMap.replaceAll((dataType, value) -> String.format(value, parameter.paramName) ); + parameter.vendorExtensions.put("x-promotions", promotionsMap); + } boolean hasProperty = conventionMap.get(Segments.SEGMENT_PROPERTIES.getSegment()).containsKey(parameter.dataFormat); if (hasProperty) { parameter.dataType = (String)conventionMap.get(Segments.SEGMENT_PROPERTIES.getSegment()).get(parameter.dataFormat); } + if( PHONE_NUMBER_FORMAT.equals(parameter.dataFormat)) { + parameter.vendorExtensions.put(X_IS_PHONE_NUMBER_FORMAT, true); + } parameter.paramName = StringUtils.camelize(parameter.paramName, true); return Optional.of(parameter); } @@ -77,7 +99,7 @@ public static CodegenParameter prefixedCollapsibleMap(CodegenParameter parameter public static Map> getConventionalMap() { try { - return new ObjectMapper().readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream("config/java.json"), new TypeReference>>(){}); + return new ObjectMapper().readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream(CONFIG_JAVA_JSON_PATH), new TypeReference>>(){}); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/twilio/oai/Inflector.java b/src/main/java/com/twilio/oai/Inflector.java index 9a02014e1..61faa6984 100644 --- a/src/main/java/com/twilio/oai/Inflector.java +++ b/src/main/java/com/twilio/oai/Inflector.java @@ -115,6 +115,7 @@ public void initWildCardMapping() { wildCardMapping.put("BuildStatus", "BuildStatus"); wildCardMapping.put("Activities", "Activity"); wildCardMapping.put("Entities", "Entity"); + wildCardMapping.put("ESimProfiles", "EsimProfile"); } } } diff --git a/src/main/java/com/twilio/oai/Segments.java b/src/main/java/com/twilio/oai/Segments.java index 08a9a72fb..fed0aefba 100644 --- a/src/main/java/com/twilio/oai/Segments.java +++ b/src/main/java/com/twilio/oai/Segments.java @@ -5,7 +5,9 @@ enum Segments { SEGMENT_SERIALIZE("serialize"), SEGMENT_DESERIALIZE("deserialize"), SEGMENT_PROPERTIES("properties"), - SEGMENT_LIBRARY("library"); + SEGMENT_LIBRARY("library"), + //promotions is uses to provide support for different datatypes of same parameter + SEGMENT_PROMOTIONS("promotions"); private final String segment; diff --git a/src/main/java/com/twilio/oai/TwilioJavaGenerator.java b/src/main/java/com/twilio/oai/TwilioJavaGenerator.java index 7871c2a03..6717dc6ff 100644 --- a/src/main/java/com/twilio/oai/TwilioJavaGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioJavaGenerator.java @@ -4,10 +4,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; +import com.twilio.oai.mlambdas.ReplaceHyphenLambda; import com.twilio.oai.resource.IResourceTree; import com.twilio.oai.resource.ResourceMap; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.PathItem; +import io.swagger.v3.oas.models.Paths; import lombok.AllArgsConstructor; import org.openapitools.codegen.*; import org.openapitools.codegen.languages.JavaClientCodegen; @@ -24,6 +26,8 @@ import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import com.google.common.collect.ImmutableMap; +import com.samskivert.mustache.Mustache.Lambda; public class TwilioJavaGenerator extends JavaClientCodegen { @@ -61,9 +65,15 @@ public TwilioJavaGenerator() { public void processOpts() { super.processOpts(); String[] inputSpecs = inputSpec.split("_"); - final String version = inputSpecs[inputSpecs.length-1].replaceAll("\\.[^/]+$", ""); - final String domain = String.join("", Arrays.copyOfRange(inputSpecs, 1, inputSpecs.length-1)); - apiPackage = version; // Place the API files in the version folder. + String version = inputSpecs[inputSpecs.length-1].replaceAll("\\.[^/]+$", ""); + String domain = String.join("", Arrays.copyOfRange(inputSpecs, 1, inputSpecs.length-1)); + + if(inputSpecs.length <3){ // version is missing + version = ""; + domain = inputSpecs[inputSpecs.length-1].replaceAll("\\.[^/]+$", ""); + } + + apiPackage = (version != "")? version : domain ; // Place the API files in the version folder. additionalProperties.put("apiVersion", version); additionalProperties.put("apiVersionClass", version.toUpperCase()); additionalProperties.put("domain", StringUtils.camelize(domain)); @@ -78,7 +88,7 @@ public void processOpenAPI(final OpenAPI openAPI) { resourceTree = new ResourceMap(inflector, PATH_SEPARATOR_PLACEHOLDER); // regex example : https://flex-api.twilio.com Pattern serverUrlPattern = Pattern.compile("https:\\/\\/([a-zA-Z-]+)\\.twilio\\.com"); - openAPI.getPaths().forEach((name, path) -> { + extendOpenAPI(openAPI).getPaths().forEach((name, path) -> { resourceTree.addResource(name, path); }); openAPI.getPaths().forEach((name, path) -> { @@ -94,6 +104,81 @@ public void processOpenAPI(final OpenAPI openAPI) { } }); } + + private OpenAPI extendOpenAPI(OpenAPI openAPI) { + Paths newPaths = new Paths(); + openAPI.getPaths().forEach((name, path) -> { + if (hasOperatorWithClassName(path)) { + for(Map.Entry newPathItem : extractMultiPathItemFromOperatorWithClassName(name, path).entrySet()) { + newPaths.addPathItem(newPathItem.getKey(), newPathItem.getValue()); + } + } + else { + newPaths.addPathItem(name, path); + } + }); + openAPI.paths(newPaths); + return openAPI; + } + + private Map extractMultiPathItemFromOperatorWithClassName(String name, PathItem path) { + ObjectMapper objectMapper = new ObjectMapper(); + Map pathItemMap = new HashMap<>(); + try { + PathItem pathItemOperatorClassVendExt = objectMapper + .readValue(objectMapper.writeValueAsString(path), PathItem.class); + PathItem pathItemClassVendExt = objectMapper + .readValue(objectMapper.writeValueAsString(path), PathItem.class); + resetOperationMethodCalls(pathItemOperatorClassVendExt, pathItemClassVendExt); + for (Map.Entry entryMapOperation: path.readOperationsMap().entrySet()) { + if (isClassName(entryMapOperation.getValue())) { + String[] urls = name.split("/"); + String className = Arrays.stream(((Map)entryMapOperation.getValue() + .getExtensions().get("x-twilio")).get("className").split("_")). + map(StringUtils::camelize).collect(Collectors.joining()); + urls[urls.length-1] = className + ".json"; + String urlPath = String.join("/", urls); + entryMapOperation.getValue().getExtensions().put("parentUrl", name); + pathItemOperatorClassVendExt.operation(entryMapOperation.getKey(), entryMapOperation.getValue()); + pathItemMap.put(urlPath, pathItemOperatorClassVendExt); + } else { + pathItemClassVendExt.operation(entryMapOperation.getKey(), entryMapOperation.getValue()); + pathItemMap.put(name, pathItemClassVendExt); + } + } + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return pathItemMap; + } + + private void resetOperationMethodCalls(PathItem pathItemOperatorClassVendExt, PathItem pathItemClassVendExt) { + pathItemClassVendExt.put(null); + pathItemClassVendExt.get(null); + pathItemClassVendExt.post(null); + pathItemClassVendExt.delete(null); + pathItemClassVendExt.patch(null); + pathItemOperatorClassVendExt.put(null); + pathItemOperatorClassVendExt.get(null); + pathItemOperatorClassVendExt.post(null); + pathItemOperatorClassVendExt.delete(null); + pathItemOperatorClassVendExt.patch(null); + } + + private boolean hasOperatorWithClassName(PathItem path) { + for (io.swagger.v3.oas.models.Operation operation: path.readOperations()) { + if (isClassName(operation)) { + return true; + } + } + return false; + } + + private boolean isClassName(io.swagger.v3.oas.models.Operation operation) { + return (operation.getExtensions().containsKey("x-twilio")) && + ((Map) operation.getExtensions().get("x-twilio")).containsKey("className"); + } + /** * make accountSid an optional param * @param path @@ -122,14 +207,49 @@ public String toParamName(String name) { @Override public void postProcessParameter(final CodegenParameter parameter) { super.postProcessParameter(parameter); - + if (parameter.dataType.startsWith("List<") && parameter.dataType.contains("Enum")) { + parameter.vendorExtensions.put("refEnum", true); + String[] value = parameter.dataType.split("Enum"); + String lastValue = value[value.length-1]; + parameter.dataType = "List<"+lastValue; + parameter.baseType = lastValue.substring(0, lastValue.length()-1); + } else if(parameter.dataType.contains("Enum")) { + parameter.vendorExtensions.put("refEnum", true); + String[] value = parameter.dataType.split("Enum"); + parameter.dataType = value[value.length-1]; + parameter.baseType = value[value.length-1]; + } + else if (parameter.isEnum) { + parameter.enumName = parameter.paramName; + } // Make sure required non-path params get into the options block. - parameter.paramName = StringUtils.camelize(parameter.paramName, false); + parameter.paramName = StringUtils.camelize(parameter.paramName, true); } @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { super.postProcessModelProperty(model, property); + if (property.dataType.startsWith("List<") && property.dataType.contains("Enum")) { + property.vendorExtensions.put("refEnum", true); + String[] value = property.dataType.split("Enum"); + String lastValue = value[value.length-1]; + property.dataType = "List<" + lastValue; + property.complexType = lastValue.substring(0, lastValue.length()-1); + property.baseType = lastValue.substring(0, lastValue.length()-1); + property.isEnum = true; + property.allowableValues = property.items.allowableValues; + property._enum = (List) property.items.allowableValues.get("values"); + } else if (property.dataType.contains("Enum")) { + property.vendorExtensions.put("refEnum", true); + String[] value = property.dataType.split("Enum"); + property.dataType = value[value.length - 1]; + property.complexType = property.dataType; + property.baseType = property.dataType; + property.isEnum = true; + property._enum = (List) property.allowableValues.get("values"); + } else if (property.isEnum ) { + property.enumName = property.baseName; + } property.isEnum = property.isEnum && property.dataFormat == null; } @@ -231,38 +351,39 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L apiTemplateFiles.remove("deleter.mustache"); apiTemplateFiles.remove("reader.mustache"); apiTemplateFiles.remove("fetcher.mustache"); + resetAllModelVendorExtensions(); // iterate over the operation and perhaps modify something for (final CodegenOperation co : opList) { // Group operations by resource. String path = co.path; - co.vendorExtensions.put("x-is-version-v2010", isVersionV2010); String[] filePathArray = co.baseName.split(PATH_SEPARATOR_PLACEHOLDER); String resourceName = filePathArray[filePathArray.length-1]; final Map resource = resources.computeIfAbsent(resourceName, k -> new LinkedHashMap<>()); populateCrudOperations(resource, co); - updateCodeOperationParams(co); + updateCodeOperationParams(co, resourceName); if (co.nickname.startsWith("update")) { resource.put("hasUpdate", true); addOperationName(co, "Update"); co.vendorExtensions.put("x-is-update-operation", true); - resource.put("signatureListUpdate", generateSignatureList(resource, co, isVersionV2010)); + resource.put("signatureListUpdate", generateSignatureList(resource, co)); apiTemplateFiles.put("updater.mustache", "Updater.java"); } else if (co.nickname.startsWith("delete")) { resource.put("hasDelete", true); addOperationName(co, "Remove"); co.vendorExtensions.put("x-is-delete-operation", true); - resource.put("signatureListDelete", generateSignatureList(resource, co, isVersionV2010)); + resource.put("signatureListDelete", generateSignatureList(resource, co)); apiTemplateFiles.put("deleter.mustache", "Deleter.java"); + addDeleteHeaderEnums(co, responseModels); } else if (co.nickname.startsWith("create")) { resource.put("hasCreate", true); co.vendorExtensions.put("x-is-create-operation", true); addOperationName(co, "Create"); - resource.put("signatureListCreate", generateSignatureList(resource, co, isVersionV2010)); + resource.put("signatureListCreate", generateSignatureList(resource, co)); apiTemplateFiles.put("creator.mustache", "Creator.java"); } else if (co.nickname.startsWith("fetch")) { resource.put("hasFetch", true); - resource.put("signatureListFetch", generateSignatureList(resource, co, isVersionV2010)); + resource.put("signatureListFetch", generateSignatureList(resource, co)); co.vendorExtensions.put("x-is-fetch-operation", true); addOperationName(co, "Fetch"); apiTemplateFiles.put("fetcher.mustache", "Fetcher.java"); @@ -270,7 +391,7 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L resource.put("hasRead", true); co.vendorExtensions.put("x-is-read-operation", true); addOperationName(co, "Page"); - resource.put("signatureListRead", generateSignatureList(resource, co, isVersionV2010)); + resource.put("signatureListRead", generateSignatureList(resource, co)); apiTemplateFiles.put("reader.mustache", "Reader.java"); } @@ -282,7 +403,6 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L resourceOperationList.add(co); resource.put("path", path); resource.put("resourceName", resourceName); - updateCodeOperationParams(co); co.queryParams = preProcessQueryParameters(co); co.pathParams = null; co.hasParams = !co.allParams.isEmpty(); @@ -305,11 +425,9 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L .map(item -> ConventionResolver.resolveComplexType(item, modelFormatMap)) .flatMap(Optional::stream) .forEach(model -> { - resource.put("serialVersionUID", calculateSerialVersionUid(model.vars)); - responseModels.add(model); - processEnumVarsForAll(responseModels, co, model, resourceName); - + CodegenModel responseModel = processEnumVarsForAll(model, co, resourceName); + responseModels.add(responseModel); }); results.put("recordKey", getRecordKey(opList, this.allModels)); @@ -333,44 +451,94 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L return results; } - private void processEnumVarsForAll(List responseModels, CodegenOperation co, CodegenModel model, String resourceName) { - for (CodegenParameter param : co.allParams) { - if(param.isEnum){ - Optional alreadyExisting = model.vars.stream().filter(item -> item.name.equalsIgnoreCase(param.paramName)).findFirst(); - if(!alreadyExisting.isPresent()){ - responseModels.get(0).vars.add(createCodeGenPropertyFromParameter(param)); - model.vars.add(createCodeGenPropertyFromParameter(param)); - } - } + private void resetAllModelVendorExtensions() { + allModels.forEach(item -> item.getVendorExtensions().remove("enumVars")); + } + + private void addDeleteHeaderEnums(CodegenOperation co, List responseModels) { + List codegenProperties = new ArrayList<>(); + for (CodegenParameter cp: co.allParams) { + if (cp.isEnum && cp.isHeaderParam) { + codegenProperties.add(createCodeGenPropertyFromParameter(cp)); } + } + if (codegenProperties.size() > 0) { + CodegenModel codegenModel = new CodegenModel(); + codegenModel.vendorExtensions.put("enumVars", codegenProperties); + responseModels.add(codegenModel); + } + } + private CodegenModel processEnumVarsForAll(CodegenModel model, CodegenOperation co, String resourceName) { + List enumProperties = new ArrayList<>(); model.vars.forEach(item -> { - if(item.isEnum){ - item.dataType = generateDataType(resourceName, item.nameInCamelCase); + if (item.isEnum && item.dataFormat == null && !item.dataType.contains(resourceName+ ".")) { + if (item.vendorExtensions.containsKey("refEnum")) { + if (item.containerType != null && item.containerType.equals("array")) { + item.enumName = item.baseType; + item.dataType = "List<"+resourceName +"." + item.complexType+">"; + } else { + item.enumName = item.baseType; + String[] values = item.dataType.split("\\."); + item.dataType = resourceName + "." + values[values.length -1]; + } + } else { + String baseName = Arrays.stream(item.baseName.split("_")).map(StringUtils::camelize) + .collect(Collectors.joining()); + item.enumName = baseName; + if (item.containerType != null && item.containerType.equals("array")) { + item.dataType = "List<"+ resourceName + "." + baseName + ">"; + item.baseType = resourceName + "." + baseName; + } else { + item.dataType = resourceName + "." + baseName; + } + } item.vendorExtensions.put("x-is-other-data-type", true); - } + }); + for (CodegenProperty codegenProperty: model.vars) { + if (codegenProperty.isEnum && codegenProperty.dataFormat == null) { + enumProperties.add(codegenProperty); + } + } + for (CodegenParameter param : co.allParams) { + if (param.isEnum) { + Optional alreadyAdded = enumProperties.stream(). + filter(item -> item.enumName.equalsIgnoreCase(param.enumName)).findFirst(); + if (!alreadyAdded.isPresent() && param.dataFormat == null) { + enumProperties.add(createCodeGenPropertyFromParameter(param)); + } + } + } + TreeSet ts = getEnumPropertyComparator(); + ts.addAll(enumProperties); + if (model.getVendorExtensions().get("enumVars") != null) { + List codegenProperties = (List) model.getVendorExtensions().get("enumVars"); + ts.addAll(codegenProperties); + } + model.vendorExtensions.put("enumVars",new ArrayList<>(ts)); + return model; + } + private TreeSet getEnumPropertyComparator() { + return new TreeSet(new Comparator() { + public int compare(CodegenProperty cp1, CodegenProperty cp2) { + return cp1.enumName.compareTo(cp2.getEnumName()); + } }); - co.queryParams.forEach(param -> processEnumVars(param, model, resourceName)); - co.formParams.forEach(param -> processEnumVars(param, model, resourceName)); - co.allParams.forEach(param -> processEnumVars(param, model, resourceName)); - co.headerParams.forEach(param -> processEnumVars(param, model, resourceName)); - co.requiredParams.forEach(param -> processEnumVars(param, model, resourceName)); } private CodegenProperty createCodeGenPropertyFromParameter(CodegenParameter co) { CodegenProperty property = new CodegenProperty(); property.isEnum = co.isEnum; property.baseName = co.baseName; + property.enumName = co.enumName; property.allowableValues = co.allowableValues; property.dataType = co.dataType; property.vendorExtensions = co.vendorExtensions; property.datatypeWithEnum = co.datatypeWithEnum; property.complexType = co.getComplexType(); - - property.name = co.paramName; property.nameInCamelCase = co.baseName.replaceAll("-",""); property.nameInSnakeCase = co.baseName.replaceAll("-","_").toLowerCase(); @@ -395,6 +563,27 @@ private CodegenModel getConcatenatedResponseModel(List responseMod resModel.allowableValues.forEach( (key, value) -> codegenModel.allowableValues.merge(key, value, (oldValue, newValue) -> newValue)); } + if (resModel.vendorExtensions != null && resModel.vendorExtensions.size() > 0) { + List resEnum1 = (List)resModel.vendorExtensions.get("enumVars"); + List codeModelEnums = (List)codegenModel.vendorExtensions.get("enumVars"); + if (codeModelEnums != null) { + for (CodegenProperty resCodegenProperty: resEnum1) { + boolean found = false; + for (CodegenProperty codeEnumProperty: codeModelEnums) { + if (codeEnumProperty.enumName.equals(resCodegenProperty.getEnumName())) { + found = true; + } + } + if (!found) { + codeModelEnums.add(resCodegenProperty); + } + } + resModel.vendorExtensions.put("enumVars", codeModelEnums); + } + resModel.vendorExtensions.forEach( + (key, value) -> codegenModel.vendorExtensions.merge(key, value, (oldValue, newValue) -> newValue)); + } + for (CodegenProperty modelProp : resModel.vars) { boolean contains = false; for (CodegenProperty property : codegenProperties) { @@ -428,39 +617,6 @@ private Optional getModelCoPath(final String modelName, CodegenOpe return allModels.stream().filter(model -> model.getClassname().equals(modelName)).findFirst(); } - private String generateDataType(String resourceName, String nameInCamelCase){ - String name = nameInCamelCase; - String dataType = ""; - String nameArr[] = name.split("[.]", 0); - if(nameArr.length > 0){ - String itemName = String.join("", nameArr); - dataType = resourceName + "." + itemName; - } - else{ - dataType = resourceName + "." + name; - } - return dataType; - } - - private CodegenParameter processEnumVars(CodegenParameter param, CodegenModel model, String resourceName) { - if(param.isEnum){ - model.vars.forEach(item -> { - if(param.paramName.equalsIgnoreCase(item.nameInCamelCase) && item.isEnum == true){ - String baseType = generateDataType(resourceName, item.nameInCamelCase); - if(param.isArray){ - param.dataType = "List<"+ baseType +">"; - param.baseType = baseType; - } - else{ - param.dataType = baseType; - } - param.vendorExtensions.put("x-is-other-data-type", true); - } - }); - } - return param; - } - private String getRecordKey(List opList, List models) { String recordKey = ""; for (CodegenOperation co: opList) { @@ -490,41 +646,38 @@ private enum Operation { * keep track of signature list that would contain different combinations of signatures for constructor generation (since Account sid is optional, so different constructor are needed) * @param resource * @param co - * @param isVersionV2010 * @return */ - private ArrayList> generateSignatureList(final Map resource, final CodegenOperation co, boolean isVersionV2010) { + private ArrayList> generateSignatureList(final Map resource, final CodegenOperation co) { CodegenParameter accountSidParam = null; List> conditionalCodegenParam = new ArrayList<>(); - if (isVersionV2010) { - Optional optionalParam = co.allParams.stream() - .filter(param -> param.vendorExtensions.containsKey("x-is-account-sid")).findAny(); - if(optionalParam.isPresent()){ - accountSidParam = optionalParam.get(); - } - /** - * structure for vendorExtensions - * @ x-twilio: - * conditional: - * - - from - * - messaging_service_sid - * - - body - * - media_url - */ - if(co.vendorExtensions.containsKey("x-twilio")) { - HashMap twilioVendorExtension = (HashMap) co.vendorExtensions.get("x-twilio"); - if(twilioVendorExtension.containsKey("conditional")) { - List> conditionalParams = (List>) twilioVendorExtension.get("conditional"); - // map the conditional param names with the codegenParameter added in optional params - conditionalCodegenParam = conditionalParams.stream().map( - paramList -> paramList.stream().map( - cp -> co.optionalParams.stream().filter( - op -> op.paramName.equals(StringUtils.camelize(cp, true)) - ).findAny().get() - ).collect(Collectors.toList())).collect(Collectors.toList()); - // added filter to prevent same signature types - conditionalCodegenParam = conditionalCodegenParam.stream().filter(cpList -> (cpList.size() <=1 || !cpList.get(0).dataType.equals(cpList.get(1).dataType))).collect(Collectors.toList()); - } + Optional optionalParam = co.allParams.stream() + .filter(param -> param.vendorExtensions.containsKey("x-is-account-sid")).findAny(); + if(optionalParam.isPresent()){ + accountSidParam = optionalParam.get(); + } + /** + * structure for vendorExtensions + * @ x-twilio: + * conditional: + * - - from + * - messaging_service_sid + * - - body + * - media_url + */ + if(co.vendorExtensions.containsKey("x-twilio")) { + HashMap twilioVendorExtension = (HashMap) co.vendorExtensions.get("x-twilio"); + if(twilioVendorExtension.containsKey("conditional")) { + List> conditionalParams = (List>) twilioVendorExtension.get("conditional"); + // map the conditional param names with the codegenParameter added in optional params + conditionalCodegenParam = conditionalParams.stream().map( + paramList -> paramList.stream().map( + cp -> co.optionalParams.stream().filter( + op -> op.paramName.equals(StringUtils.camelize(cp, true)) + ).findAny().get() + ).collect(Collectors.toList())).collect(Collectors.toList()); + // added filter to prevent same signature types + conditionalCodegenParam = conditionalCodegenParam.stream().filter(cpList -> (cpList.size() <=1 || !cpList.get(0).dataType.equals(cpList.get(1).dataType))).collect(Collectors.toList()); } } conditionalCodegenParam = Lists.cartesianProduct(conditionalCodegenParam); @@ -649,40 +802,48 @@ public static String capitalize(String str) { return str.substring(0, 1).toUpperCase() + str.substring(1); } - private void updateCodeOperationParams(final CodegenOperation co) { + private void updateCodeOperationParams(final CodegenOperation co, String resourceName) { co.allParams = co.allParams .stream() .map(ConventionResolver::resolveParameter) .map(Optional::get) + .map(item -> this.resolveEnumParameter(item, resourceName)) .collect(Collectors.toList()); co.pathParams = co.pathParams .stream() .map(ConventionResolver::resolveParameter) .map(Optional::get) + .map(item -> this.resolveEnumParameter(item, resourceName)) .collect(Collectors.toList()); co.pathParams.stream(). map(ConventionResolver::resolveParamTypes) + .map(item -> this.resolveEnumParameter(item, resourceName)) .forEach(param -> param.paramName = "path"+param.paramName); co.queryParams = co.queryParams.stream().map(ConventionResolver::resolveParamTypes) .map(ConventionResolver::prefixedCollapsibleMap) + .map(item -> this.resolveEnumParameter(item, resourceName)) .collect(Collectors.toList()); co.queryParams = preProcessQueryParameters(co); co.formParams = co.formParams.stream().map(ConventionResolver::resolveParamTypes) .map(ConventionResolver::prefixedCollapsibleMap) + .map(item -> this.resolveEnumParameter(item, resourceName)) .collect(Collectors.toList()); co.formParams = preProcessFormParams(co); co.headerParams = co.headerParams.stream().map(ConventionResolver::resolveParamTypes) .map(ConventionResolver::prefixedCollapsibleMap) + .map(item -> this.resolveEnumParameter(item, resourceName)) .collect(Collectors.toList()); co.optionalParams = co.optionalParams .stream() .map(ConventionResolver::resolveParameter) .map(Optional::get) + .map(item -> this.resolveEnumParameter(item, resourceName)) .collect(Collectors.toList()); co.requiredParams = co.requiredParams .stream() .map(ConventionResolver::resolveParameter) .map(Optional::get) + .map(item -> this.resolveEnumParameter(item, resourceName)) .collect(Collectors.toList()); } @@ -696,6 +857,43 @@ private List preProcessFormParams(CodegenOperation co) { return co.formParams; } + @Override + protected ImmutableMap.Builder addMustacheLambdas() { + ImmutableMap.Builder lambdaBuilder = super.addMustacheLambdas(); + lambdaBuilder.put("replacehyphen", new ReplaceHyphenLambda()); + return lambdaBuilder; + } + + private CodegenParameter resolveEnumParameter(CodegenParameter parameter, String resourceName) { + if( parameter.isEnum && !parameter.vendorExtensions.containsKey("refEnum")) { + parameter.enumName = Arrays.stream(parameter.enumName.split("_")).map(StringUtils::camelize) + .collect(Collectors.joining()); + if (parameter.items != null && parameter.items.allowableValues != null && parameter.items.allowableValues.containsKey("values")) { + parameter.dataType = "List<" + resourceName+"."+ parameter.enumName + ">"; + parameter.baseType = resourceName + "." + parameter.enumName; + } else { + parameter.dataType = resourceName+"."+ parameter.enumName; + } + + return parameter; + } + if (parameter.items != null && parameter.items.allowableValues != null && parameter.items.allowableValues.containsKey("values") ) { + parameter.isEnum = true; + parameter.enumName = parameter.baseType; + parameter._enum = (List) parameter.items.allowableValues.get("values"); + parameter.dataType = "List<" + resourceName + "." + parameter.baseType + ">"; + parameter.baseType = resourceName + "." + parameter.baseType; + parameter.allowableValues = parameter.items.allowableValues; + } + if (parameter.allowableValues != null && parameter.allowableValues.containsKey("enumVars")) { + parameter.isEnum = true; + parameter._enum = (List) parameter.allowableValues.get("values"); + parameter.enumName = parameter.dataType; + parameter.dataType=resourceName+"."+parameter.dataType; + } + return parameter; + } + @Override public String getName() { return "twilio-java"; diff --git a/src/main/java/com/twilio/oai/mlambdas/ReplaceHyphenLambda.java b/src/main/java/com/twilio/oai/mlambdas/ReplaceHyphenLambda.java new file mode 100644 index 000000000..ee5075fa8 --- /dev/null +++ b/src/main/java/com/twilio/oai/mlambdas/ReplaceHyphenLambda.java @@ -0,0 +1,70 @@ +package com.twilio.oai.mlambdas; + + +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template; + +import java.io.IOException; +import java.io.Writer; +import java.util.Locale; + +/** + * Converts text in a fragment to title case. + * + * Register: + *
+ * additionalProperties.put("titlecase", new TitlecaseLambda());
+ * 
+ * + * Use: + *
+ * {{#titlecase}}{{classname}}{{/titlecase}}
+ * 
+ */ +public class ReplaceHyphenLambda implements Mustache.Lambda { + private String delimiter; + + /** + * Constructs a new instance of {@link org.openapitools.codegen.templating.mustache.TitlecaseLambda}, which will convert all text + * in a space delimited string to title-case. + */ + public ReplaceHyphenLambda() { + this(" "); + } + + /** + * Constructs a new instance of {@link org.openapitools.codegen.templating.mustache.TitlecaseLambda}, splitting on the specified + * delimiter and converting each word to title-case. + * + * NOTE: passing {@code null} results in a title-casing the first word only. + * + * @param delimiter Provided to allow an override for the default space delimiter. + */ + public ReplaceHyphenLambda(String delimiter) { + this.delimiter = delimiter; + } + + private String titleCase(final String input) { + return input.replaceAll("-","_"); + } + + @Override + public void execute(Template.Fragment fragment, Writer writer) throws IOException { + String text = fragment.execute(); + if (delimiter == null) { + writer.write(titleCase(text)); + return; + } + + // Split accepts regex. \Q and \E wrap the delimiter to create a literal regex, + // so things like "." and "|" aren't treated as their regex equivalents. + String[] parts = text.split("\\Q" + delimiter + "\\E"); + for (int i = 0; i < parts.length; i++) { + String part = parts[i]; + writer.write(titleCase(part)); + if (i != parts.length - 1) { + writer.write(delimiter); + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/config/java.json b/src/main/resources/config/java.json index 8b584ba15..b60bea694 100644 --- a/src/main/resources/config/java.json +++ b/src/main/resources/config/java.json @@ -95,14 +95,17 @@ }, "promotions": { - "url": { - "string": "Promoter.uriFromString({})" + "uri": { + "string": "Promoter.uriFromString(%s)" }, - "phone_number": { - "string": "Promoter.phoneNumberFromString({})" + "list-uri": { + "uri": "Promoter.listOfOne(%s)" + }, + "phone-number": { + "string": "Promoter.phoneNumberFromString(%s)" }, "twiml": { - "string": "Promoter.twimlFromString({})" + "string": "Promoter.twimlFromString(%s)" } }, diff --git a/src/main/resources/twilio-java/api.mustache b/src/main/resources/twilio-java/api.mustache index 621be83e9..8b8fcc68d 100644 --- a/src/main/resources/twilio-java/api.mustache +++ b/src/main/resources/twilio-java/api.mustache @@ -57,6 +57,7 @@ import com.twilio.type.InboundSmsPrice; import com.twilio.type.OutboundSmsPrice; import com.twilio.type.OutboundCallPrice; import com.twilio.type.RecordingRule; +import com.twilio.type.SubscribeRule; @JsonIgnoreProperties(ignoreUnknown = true) @ToString diff --git a/src/main/resources/twilio-java/creator.mustache b/src/main/resources/twilio-java/creator.mustache index c0e1dc258..ab49d024f 100644 --- a/src/main/resources/twilio-java/creator.mustache +++ b/src/main/resources/twilio-java/creator.mustache @@ -60,21 +60,30 @@ public class {{resourceName}}Creator extends Creator<{{resourceName}}>{ this.{{paramName}} = {{paramName}}; return this; } +{{#vendorExtensions.x-promotions}} +{{#isArray}} +{{#entrySet}} + + public {{resourceName}}Creator set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + return set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}({{value}}); + } +{{/entrySet}} +{{/isArray}} +{{^isArray}} +{{#entrySet}} + + public {{resourceName}}Creator set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + this.{{paramName}} = {{value}}; + return this; + } +{{/entrySet}} +{{/isArray}} +{{/vendorExtensions.x-promotions}} {{/vendorExtensions.x-non-path-params}} @Override public {{resourceName}} create(final TwilioRestClient client){ - String path = "{{{path}}}"; - {{#allParams}} - {{#vendorExtensions.x-is-account-sid}} - this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/vendorExtensions.x-is-account-sid}} - {{/allParams}} - {{#requiredParams}} - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/requiredParams}} - +{{>generate_uri}} Request request = new Request( HttpMethod.POST, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), diff --git a/src/main/resources/twilio-java/deleter.mustache b/src/main/resources/twilio-java/deleter.mustache index 4aed483be..3f1ef2227 100644 --- a/src/main/resources/twilio-java/deleter.mustache +++ b/src/main/resources/twilio-java/deleter.mustache @@ -3,6 +3,7 @@ package com.twilio.rest.{{domainPackage}}.{{package}}{{packageSubPart}}; 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; @@ -53,21 +54,30 @@ public class {{resourceName}}Deleter extends Deleter<{{resourceName}}> { this.{{paramName}} = {{paramName}}; return this; } +{{#vendorExtensions.x-promotions}} +{{#isArray}} +{{#entrySet}} + + public {{resourceName}}Deleter set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + return set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}({{value}}); + } +{{/entrySet}} +{{/isArray}} +{{^isArray}} +{{#entrySet}} + + public {{resourceName}}Deleter set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + this.{{paramName}} = {{value}}; + return this; + } +{{/entrySet}} +{{/isArray}} +{{/vendorExtensions.x-promotions}} {{/vendorExtensions.x-non-path-params}} @Override public boolean delete(final TwilioRestClient client) { - String path = "{{{path}}}"; - {{#allParams}} - {{#vendorExtensions.x-is-account-sid}} - this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/vendorExtensions.x-is-account-sid}} - {{/allParams}} - {{#requiredParams}} - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/requiredParams}} - +{{>generate_uri}} Request request = new Request( HttpMethod.DELETE, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), diff --git a/src/main/resources/twilio-java/fetcher.mustache b/src/main/resources/twilio-java/fetcher.mustache index a117187c4..26fe18960 100644 --- a/src/main/resources/twilio-java/fetcher.mustache +++ b/src/main/resources/twilio-java/fetcher.mustache @@ -3,6 +3,7 @@ package com.twilio.rest.{{domainPackage}}.{{package}}{{packageSubPart}}; 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; @@ -54,21 +55,30 @@ public class {{resourceName}}Fetcher extends Fetcher<{{resourceName}}> { this.{{paramName}} = {{paramName}}; return this; } +{{#vendorExtensions.x-promotions}} +{{#isArray}} +{{#entrySet}} + + public {{resourceName}}Fetcher set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + return set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}({{value}}); + } +{{/entrySet}} +{{/isArray}} +{{^isArray}} +{{#entrySet}} + + public {{resourceName}}Fetcher set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + this.{{paramName}} = {{value}}; + return this; + } +{{/entrySet}} +{{/isArray}} +{{/vendorExtensions.x-promotions}} {{/vendorExtensions.x-non-path-params}} @Override public {{resourceName}} fetch(final TwilioRestClient client) { - String path = "{{{path}}}"; - {{#allParams}} - {{#vendorExtensions.x-is-account-sid}} - this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/vendorExtensions.x-is-account-sid}} - {{/allParams}} - {{#requiredParams}} - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/requiredParams}} - +{{>generate_uri}} Request request = new Request( HttpMethod.GET, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), diff --git a/src/main/resources/twilio-java/generate_uri.mustache b/src/main/resources/twilio-java/generate_uri.mustache new file mode 100644 index 000000000..50c2061bd --- /dev/null +++ b/src/main/resources/twilio-java/generate_uri.mustache @@ -0,0 +1,21 @@ +{{#vendorExtensions.parentUrl}} + String path = "{{{vendorExtensions.parentUrl}}}"; +{{/vendorExtensions.parentUrl}} +{{^vendorExtensions.parentUrl}} + String path = "{{{path}}}"; +{{/vendorExtensions.parentUrl}} + +{{#allParams}} + {{#vendorExtensions.x-is-account-sid}} + this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; + path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); + {{/vendorExtensions.x-is-account-sid}} +{{/allParams}} +{{#requiredParams}} + {{#vendorExtensions.x-is-phone-number-format}} + path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.encode("utf-8")); + {{/vendorExtensions.x-is-phone-number-format}} + {{^vendorExtensions.x-is-phone-number-format}} + path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); + {{/vendorExtensions.x-is-phone-number-format}} +{{/requiredParams}} \ No newline at end of file diff --git a/src/main/resources/twilio-java/headerParams.mustache b/src/main/resources/twilio-java/headerParams.mustache index 1a4cc164f..bb423155a 100644 --- a/src/main/resources/twilio-java/headerParams.mustache +++ b/src/main/resources/twilio-java/headerParams.mustache @@ -5,12 +5,18 @@ request.addHeaderParam("{{baseName}}", {{paramName}}.toString()); {{/vendorExtensions.x-is-other-data-type}} {{^vendorExtensions.x-is-other-data-type}} + {{#isEnum}} + request.addHeaderParam("{{baseName}}", {{paramName}}.toString()); + {{/isEnum}} + {{^isEnum}} {{#isString}} request.addHeaderParam("{{baseName}}", {{paramName}}); {{/isString}} {{^isString}} request.addHeaderParam("{{baseName}}", {{paramName}}.toString()); {{/isString}} + {{/isEnum}} + {{/vendorExtensions.x-is-other-data-type}} } {{/headerParams}} diff --git a/src/main/resources/twilio-java/postParams.mustache b/src/main/resources/twilio-java/postParams.mustache index 70a1ab656..689ad4497 100644 --- a/src/main/resources/twilio-java/postParams.mustache +++ b/src/main/resources/twilio-java/postParams.mustache @@ -8,7 +8,7 @@ {{#isArray}} {{#isEnum}} for ({{baseType}} prop : {{paramName}}) { - request.addPostParam("{{baseName}}", prop.toString()); + request.addPostParam("{{#lambda.titlecase}}{{{paramName}}}{{/lambda.titlecase}}", prop.toString()); } {{/isEnum}} {{^isEnum}} @@ -26,7 +26,7 @@ {{/isArray}} {{^isArray}} {{#vendorExtensions.x-is-other-data-type}} - request.addPostParam("{{baseName}}", {{paramName}}.toString()); + request.addPostParam("{{#lambda.titlecase}}{{{paramName}}}{{/lambda.titlecase}}", {{paramName}}.toString()); {{/vendorExtensions.x-is-other-data-type}} {{^vendorExtensions.x-is-other-data-type}} {{#isString}} diff --git a/src/main/resources/twilio-java/reader.mustache b/src/main/resources/twilio-java/reader.mustache index 5f1f93df5..1fa615367 100644 --- a/src/main/resources/twilio-java/reader.mustache +++ b/src/main/resources/twilio-java/reader.mustache @@ -4,6 +4,7 @@ package com.twilio.rest.{{domainPackage}}.{{package}}{{packageSubPart}}; 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; @@ -56,6 +57,25 @@ public class {{resourceName}}Reader extends Reader<{{resourceName}}> { this.{{paramName}} = {{paramName}}; return this; } +{{#vendorExtensions.x-promotions}} +{{#isArray}} +{{#entrySet}} + + public {{resourceName}}Reader set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + return set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}({{value}}); + } +{{/entrySet}} +{{/isArray}} +{{^isArray}} +{{#entrySet}} + + public {{resourceName}}Reader set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + this.{{paramName}} = {{value}}; + return this; + } +{{/entrySet}} +{{/isArray}} +{{/vendorExtensions.x-promotions}} {{/vendorExtensions.x-non-path-params}} @Override diff --git a/src/main/resources/twilio-java/responseModel.mustache b/src/main/resources/twilio-java/responseModel.mustache index fae339875..e81fd1b97 100644 --- a/src/main/resources/twilio-java/responseModel.mustache +++ b/src/main/resources/twilio-java/responseModel.mustache @@ -1,16 +1,16 @@ {{#responseModel}} -{{#vars}} +{{#vendorExtensions.enumVars}} {{#isEnum}} - public enum {{#lambda.titlecase}}{{{baseName}}}{{/lambda.titlecase}} { + public enum {{#lambda.titlecase}}{{{enumName}}}{{/lambda.titlecase}} { {{#allowableValues}} - {{#enumVars}} - {{#lambda.uppercase}}{{{name}}}({{/lambda.uppercase}}{{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}} - {{/enumVars}} + {{#values}} + {{#lambda.uppercase}}{{#lambda.replacehyphen}}{{{.}}}{{/lambda.replacehyphen}}({{/lambda.uppercase}}"{{{.}}}"){{^-last}},{{/-last}}{{#-last}};{{/-last}} + {{/values}} {{/allowableValues}} private final String value; - private {{#lambda.titlecase}}{{{baseName}}}{{/lambda.titlecase}}(final String value) { + private {{#lambda.titlecase}}{{{enumName}}}{{/lambda.titlecase}}(final String value) { this.value = value; } @@ -19,12 +19,12 @@ } @JsonCreator - public static {{#lambda.titlecase}}{{{baseName}}}{{/lambda.titlecase}} forValue(final String value) { - return Promoter.enumFromString(value, {{#lambda.titlecase}}{{{baseName}}}{{/lambda.titlecase}}.values()); + public static {{#lambda.titlecase}}{{{enumName}}}{{/lambda.titlecase}} forValue(final String value) { + return Promoter.enumFromString(value, {{#lambda.titlecase}}{{{enumName}}}{{/lambda.titlecase}}.values()); } } {{/isEnum}} -{{/vars}} +{{/vendorExtensions.enumVars}} {{#vars}} private final {{{dataType}}} {{name}}; diff --git a/src/main/resources/twilio-java/updater.mustache b/src/main/resources/twilio-java/updater.mustache index 1585cc413..6d147501c 100644 --- a/src/main/resources/twilio-java/updater.mustache +++ b/src/main/resources/twilio-java/updater.mustache @@ -54,21 +54,30 @@ public class {{resourceName}}Updater extends Updater<{{resourceName}}>{ this.{{paramName}} = {{paramName}}; return this; } +{{#vendorExtensions.x-promotions}} +{{#isArray}} +{{#entrySet}} + + public {{resourceName}}Updater set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + return set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}({{value}}); + } +{{/entrySet}} +{{/isArray}} +{{^isArray}} +{{#entrySet}} + + public {{resourceName}}Updater set{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}(final {{#lambda.titlecase}}{{key}}{{/lambda.titlecase}} {{paramName}}){ + this.{{paramName}} = {{value}}; + return this; + } +{{/entrySet}} +{{/isArray}} +{{/vendorExtensions.x-promotions}} {{/vendorExtensions.x-non-path-params}} @Override public {{resourceName}} update(final TwilioRestClient client){ - String path = "{{{path}}}"; - {{#allParams}} - {{#vendorExtensions.x-is-account-sid}} - this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/vendorExtensions.x-is-account-sid}} - {{/allParams}} - {{#requiredParams}} - path = path.replace("{"+"{{#lambda.titlecase}}{{paramName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); - {{/requiredParams}} - +{{>generate_uri}} Request request = new Request( HttpMethod.POST, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(),