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 d6597f199..0076bc9d7 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 @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -73,7 +70,6 @@ @ToString public class Account extends Resource { private static final long serialVersionUID = 13844008145741L; - public static AccountCreator creator(){ return new AccountCreator(); } @@ -92,17 +88,19 @@ public static AccountFetcher fetcher(final String pathSid){ return new AccountFetcher(pathSid); } + + public static AccountReader reader(){ return new AccountReader(); } + public static AccountUpdater updater(final Account.Status status){ return new AccountUpdater(status); } public static AccountUpdater updater(final String pathSid, final Account.Status status){ return new AccountUpdater(pathSid, status); } - /** * Converts a JSON String into a Account object using the provided ObjectMapper. * @@ -153,6 +151,7 @@ private Status(final String value) { this.value = value; } + @Override public String toString() { return value; } @@ -172,6 +171,7 @@ private XTwilioWebhookEnabled(final String value) { this.value = value; } + @Override public String toString() { return value; } 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 7ac305201..fb58124f6 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 @@ -26,19 +26,14 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; import java.time.LocalDate; import com.twilio.converter.Converter; import java.time.ZonedDateTime; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; -import java.net.URI; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -46,7 +41,6 @@ import java.util.Objects; import lombok.ToString; - import java.net.URI; public class AccountCreator extends Creator{ @@ -88,7 +82,7 @@ public AccountCreator setTwiml(final String twiml){ @Override public Account create(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts.json"; + String path = String.format("%s", "/2010-04-01/Accounts.json"); Request request = new Request( @@ -112,25 +106,20 @@ public Account create(final TwilioRestClient client){ return Account.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (recordingStatusCallback != null) { - request.addPostParam("RecordingStatusCallback", recordingStatusCallback.toString()); + request.addPostParam("RecordingStatusCallback", String.valueOf(recordingStatusCallback)); - } if (recordingStatusCallbackEvent != null) { for (String prop : recordingStatusCallbackEvent) { request.addPostParam("RecordingStatusCallbackEvent", prop); } - } - if (twiml != null) { - request.addPostParam("Twiml", twiml.toString()); - } + request.addPostParam("Twiml", String.valueOf(twiml)); + } - private void addHeaderParams(final Request request) { - if (xTwilioWebhookEnabled != null) { - request.addHeaderParam("X-Twilio-Webhook-Enabled", xTwilioWebhookEnabled.toString()); - } + private void addHeaderParams(final Request request) { + request.addHeaderParam("X-Twilio-Webhook-Enabled", String.valueOf(xTwilioWebhookEnabled)); } + } 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 aaf61ee2d..cbd792014 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 @@ -55,10 +55,10 @@ public AccountDeleter(final String pathSid){ @Override public boolean delete(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{Sid}.json"; + String path = String.format("%s", "/2010-04-01/Accounts/{Sid}.json"); this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid; - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid); Request request = new Request( HttpMethod.DELETE, 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 83c84d91b..0c8b34a4c 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 @@ -56,10 +56,10 @@ public AccountFetcher(final String pathSid){ @Override public Account fetch(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{Sid}.json"; + String path = String.format("%s", "/2010-04-01/Accounts/{Sid}.json"); this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid; - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid); Request request = new Request( HttpMethod.GET, 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 e6b022a91..03a36ca6e 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 @@ -154,10 +154,8 @@ else if (dateCreatedAfter != null || dateCreatedBefore != null) { request.addQueryParam("Date.Test", DateConverter.dateStringFromLocalDate(dateTest)); } - if (pageSize != null) { - request.addQueryParam("PageSize", pageSize.toString()); - } + request.addQueryParam("PageSize", String.valueOf(pageSize)); if(getPageSize() != null) { request.addQueryParam("PageSize", Integer.toString(getPageSize())); 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 b87516db2..9394de497 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 @@ -68,12 +68,13 @@ public AccountUpdater setPauseBehavior(final String pauseBehavior){ @Override public Account update(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts/{Sid}.json"; + String path = String.format("%s", "/2010-04-01/Accounts/{Sid}.json"); this.pathSid = this.pathSid == null ? client.getAccountSid() : this.pathSid; - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"Sid"+"}", this.pathSid); path = path.replace("{"+"Status"+"}", this.status.toString()); + Request request = new Request( HttpMethod.POST, Domains.API.toString(), @@ -94,13 +95,10 @@ public Account update(final TwilioRestClient client){ return Account.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (pauseBehavior != null) { - request.addPostParam("PauseBehavior", pauseBehavior); + request.addPostParam("PauseBehavior", String.valueOf(pauseBehavior)); - } - if (status != null) { - request.addPostParam("Status", status.toString()); + request.addPostParam("Status", String.valueOf(status)); - } } + } 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 ae4e102c4..3cab23a9e 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 @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -73,7 +70,6 @@ @ToString public class Call extends Resource { private static final long serialVersionUID = 22261732607075L; - public static CallCreator creator(final String requiredStringProperty, final HttpMethod testMethod){ return new CallCreator(requiredStringProperty, testMethod); } @@ -95,6 +91,7 @@ public static CallFetcher fetcher(final String pathAccountSid, final Integer pat return new CallFetcher(pathAccountSid, pathTestInteger); } + /** * Converts a JSON String into a Call object using the provided ObjectMapper. * @@ -145,6 +142,7 @@ private Status(final String value) { this.value = value; } + @Override public String toString() { return value; } 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 28d30a521..f6406921a 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 @@ -26,19 +26,14 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; import java.time.LocalDate; import com.twilio.converter.Converter; import java.time.ZonedDateTime; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; -import java.net.URI; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -46,7 +41,6 @@ import java.util.Objects; import lombok.ToString; - import java.net.URI; public class CallCreator extends Creator{ @@ -95,13 +89,15 @@ public CallCreator setTestArrayOfUri(final String testArrayOfUri){ @Override public Call create(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts/{AccountSid}/Calls.json"; + String path = String.format("%s", "/2010-04-01/Accounts/{AccountSid}/Calls.json"); this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; - path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); - path = path.replace("{"+"RequiredStringProperty"+"}", this.requiredStringProperty.toString()); + path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid); + path = path.replace("{"+"RequiredStringProperty"+"}", this.requiredStringProperty); + path = path.replace("{"+"TestMethod"+"}", this.testMethod.toString()); + Request request = new Request( HttpMethod.POST, Domains.API.toString(), @@ -122,25 +118,22 @@ public Call create(final TwilioRestClient client){ return Call.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (requiredStringProperty != null) { - request.addPostParam("RequiredStringProperty", requiredStringProperty); + request.addPostParam("RequiredStringProperty", String.valueOf(requiredStringProperty)); - } if (testArrayOfStrings != null) { for (String prop : testArrayOfStrings) { request.addPostParam("TestArrayOfStrings", prop); } - } + if (testArrayOfUri != null) { for (URI prop : testArrayOfUri) { - request.addPostParam("TestArrayOfUri", prop.toString()); + request.addPostParam("TestArrayOfUri", String.valueOf(prop)); } - } - if (testMethod != null) { - request.addPostParam("TestMethod", testMethod.toString()); - } + request.addPostParam("TestMethod", String.valueOf(testMethod)); + } + } 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 1f5b3edee..2e6210eb2 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 @@ -58,12 +58,13 @@ public CallDeleter(final String pathAccountSid, final Integer pathTestInteger){ @Override public boolean delete(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"; + String path = String.format("%s", "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"); this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; - path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); + path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid); path = path.replace("{"+"TestInteger"+"}", this.pathTestInteger.toString()); + Request request = new Request( HttpMethod.DELETE, Domains.API.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 676bdd4ad..6001e1493 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 @@ -59,12 +59,13 @@ public CallFetcher(final String pathAccountSid, final Integer pathTestInteger){ @Override public Call fetch(final TwilioRestClient client) { - String path = "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"; + String path = String.format("%s", "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"); this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; - path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); + path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid); path = path.replace("{"+"TestInteger"+"}", this.pathTestInteger.toString()); + Request request = new Request( HttpMethod.GET, Domains.API.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 1be348a6a..a88066e55 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 @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -80,7 +77,6 @@ public static FeedbackCallSummaryUpdater updater(final String pathSid, final Loc public static FeedbackCallSummaryUpdater updater(final String pathAccountSid, final String pathSid, final LocalDate endDate, final LocalDate startDate){ return new FeedbackCallSummaryUpdater(pathAccountSid, pathSid, endDate, startDate); } - /** * Converts a JSON String into a FeedbackCallSummary object using the provided ObjectMapper. * @@ -131,6 +127,7 @@ private Status(final String value) { this.value = value; } + @Override public String toString() { return value; } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java index 2c691b957..2105dc1dd 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java @@ -78,14 +78,17 @@ public FeedbackCallSummaryUpdater setAccountSid(final String accountSid){ @Override public FeedbackCallSummary update(final TwilioRestClient client){ - String path = "/2010-04-01/Accounts/{AccountSid}/Calls/Feedback/Summary/{Sid}.json"; + String path = String.format("%s", "/2010-04-01/Accounts/{AccountSid}/Calls/Feedback/Summary/{Sid}.json"); this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid; - path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid.toString()); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); + path = path.replace("{"+"AccountSid"+"}", this.pathAccountSid); + path = path.replace("{"+"Sid"+"}", this.pathSid); + path = path.replace("{"+"EndDate"+"}", this.endDate.toString()); + path = path.replace("{"+"StartDate"+"}", this.startDate.toString()); + Request request = new Request( HttpMethod.POST, Domains.API.toString(), @@ -106,17 +109,16 @@ public FeedbackCallSummary update(final TwilioRestClient client){ return FeedbackCallSummary.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (accountSid != null) { - request.addPostParam("AccountSid", accountSid); + request.addPostParam("AccountSid", String.valueOf(accountSid)); - } if (endDate != null) { request.addPostParam("EndDate", DateConverter.dateStringFromLocalDate(endDate)); - } + if (startDate != null) { request.addPostParam("StartDate", DateConverter.dateStringFromLocalDate(startDate)); - } + } + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java index a75951b10..5ea565ccb 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/Call.java @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -77,7 +74,6 @@ public class Call extends Resource { public static CallUpdater updater(final String pathSid){ return new CallUpdater(pathSid); } - /** * Converts a JSON String into a Call object using the provided ObjectMapper. * diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java index e021fd1bb..ed3c0f175 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java @@ -54,9 +54,10 @@ public CallUpdater(final String pathSid){ @Override public Call update(final TwilioRestClient client){ - String path = "/v1/Voice/{Sid}"; + String path = String.format("%s", "/v1/Voice/{Sid}"); + + path = path.replace("{"+"Sid"+"}", this.pathSid); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); Request request = new Request( HttpMethod.POST, diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java index f08bc0b30..2fb0bc58f 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/Aws.java @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -73,7 +70,6 @@ @ToString public class Aws extends Resource { private static final long serialVersionUID = 234000032744450L; - public static AwsDeleter deleter(final String pathSid){ return new AwsDeleter(pathSid); } @@ -82,14 +78,16 @@ public static AwsFetcher fetcher(final String pathSid){ return new AwsFetcher(pathSid); } + + public static AwsReader reader(){ return new AwsReader(); } + public static AwsUpdater updater(final String pathSid){ return new AwsUpdater(pathSid); } - /** * Converts a JSON String into a Aws object using the provided ObjectMapper. * diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java index 53a1a5e67..06e3efba1 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java @@ -53,9 +53,10 @@ public AwsDeleter(final String pathSid){ @Override public boolean delete(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}"; + String path = String.format("%s", "/v1/Credentials/AWS/{Sid}"); + + path = path.replace("{"+"Sid"+"}", this.pathSid); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); Request request = new Request( HttpMethod.DELETE, diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java index 01af8dffe..b2f43f90c 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java @@ -54,9 +54,10 @@ public AwsFetcher(final String pathSid){ @Override public Aws fetch(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}"; + String path = String.format("%s", "/v1/Credentials/AWS/{Sid}"); + + path = path.replace("{"+"Sid"+"}", this.pathSid); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); Request request = new Request( HttpMethod.GET, diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java index 79819197e..ca308f783 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java @@ -124,10 +124,8 @@ public Page getPage(final String targetUrl, final TwilioRestClient client) return pageForRequest(client, request); } private void addQueryParams(final Request request) { - if (pageSize != null) { - request.addQueryParam("PageSize", pageSize.toString()); - } + request.addQueryParam("PageSize", String.valueOf(pageSize)); if(getPageSize() != null) { request.addQueryParam("PageSize", Integer.toString(getPageSize())); diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java index 54998f688..ff48ad36c 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java @@ -64,9 +64,10 @@ public AwsUpdater setTestBoolean(final Boolean testBoolean){ @Override public Aws update(final TwilioRestClient client){ - String path = "/v1/Credentials/AWS/{Sid}"; + String path = String.format("%s", "/v1/Credentials/AWS/{Sid}"); + + path = path.replace("{"+"Sid"+"}", this.pathSid); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); Request request = new Request( HttpMethod.POST, @@ -88,13 +89,10 @@ public Aws update(final TwilioRestClient client){ return Aws.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (testString != null) { - request.addPostParam("TestString", testString); + request.addPostParam("TestString", String.valueOf(testString)); - } - if (testBoolean != null) { - request.addPostParam("TestBoolean", testBoolean.toString()); + request.addPostParam("TestBoolean", String.valueOf(testBoolean)); - } } + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java index 914865ef7..1066d3284 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentials.java @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -73,7 +70,6 @@ @ToString public class NewCredentials extends Resource { private static final long serialVersionUID = 234000032744450L; - public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Float testNumberFloat){ return new NewCredentialsCreator(testString, testInteger, testNumberFloat); } @@ -133,6 +129,7 @@ private Permissions(final String value) { this.value = value; } + @Override public String toString() { return value; } @@ -156,6 +153,7 @@ private Status(final String value) { this.value = value; } + @Override public String toString() { return value; } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java index 6a00e3093..f05596295 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java @@ -26,19 +26,14 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; import java.time.LocalDate; import com.twilio.converter.Converter; import java.time.ZonedDateTime; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; -import java.net.URI; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -46,7 +41,6 @@ import java.util.Objects; import lombok.ToString; - import java.net.URI; public class NewCredentialsCreator extends Creator{ @@ -169,9 +163,10 @@ public NewCredentialsCreator setSomeA2PThing(final String someA2PThing){ @Override public NewCredentials create(final TwilioRestClient client){ - String path = "/v1/Credentials/AWS"; + String path = String.format("%s", "/v1/Credentials/AWS"); + + path = path.replace("{"+"TestString"+"}", this.testString); - path = path.replace("{"+"TestString"+"}", this.testString.toString()); Request request = new Request( HttpMethod.POST, @@ -193,79 +188,60 @@ public NewCredentials create(final TwilioRestClient client){ return NewCredentials.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (testString != null) { - request.addPostParam("TestString", testString); + request.addPostParam("TestString", String.valueOf(testString)); - } - if (testBoolean != null) { - request.addPostParam("TestBoolean", testBoolean.toString()); + request.addPostParam("TestBoolean", String.valueOf(testBoolean)); - } - if (testInteger != null) { - request.addPostParam("TestInteger", testInteger.toString()); + request.addPostParam("TestInteger", String.valueOf(testInteger)); - } - if (testNumber != null) { - request.addPostParam("TestNumber", testNumber.toString()); + request.addPostParam("TestNumber", String.valueOf(testNumber)); - } - if (testNumberFloat != null) { - request.addPostParam("TestNumberFloat", testNumberFloat.toString()); + request.addPostParam("TestNumberFloat", String.valueOf(testNumberFloat)); - } - if (testNumberDouble != null) { - request.addPostParam("TestNumberDouble", testNumberDouble.toString()); + request.addPostParam("TestNumberDouble", String.valueOf(testNumberDouble)); - } - if (testNumberInt32 != null) { - request.addPostParam("TestNumberInt32", testNumberInt32.toString()); + request.addPostParam("TestNumberInt32", String.valueOf(testNumberInt32)); - } - if (testNumberInt64 != null) { - request.addPostParam("TestNumberInt64", testNumberInt64.toString()); + request.addPostParam("TestNumberInt64", String.valueOf(testNumberInt64)); - } if (testObject != null) { request.addPostParam("TestObject", Converter.mapToJson(testObject)); - } + if (testDateTime != null) { request.addPostParam("TestDateTime", testDateTime.toInstant().toString()); - } + if (testDate != null) { request.addPostParam("TestDate", DateConverter.dateStringFromLocalDate(testDate)); - } - if (testEnum != null) { - request.addPostParam("TestEnum", testEnum.toString()); + + request.addPostParam("TestEnum", String.valueOf(testEnum)); - } if (testObjectArray != null) { for (Map prop : testObjectArray) { request.addPostParam("TestObjectArray", Converter.mapToJson(prop)); } - } + if (testAnyType != null) { request.addPostParam("TestAnyType", Converter.mapToJson(testAnyType)); - } + if (testAnyArray != null) { for (Map prop : testAnyArray) { request.addPostParam("TestAnyArray", Converter.mapToJson(prop)); } - } + if (permissions != null) { for (NewCredentials.Permissions prop : permissions) { - request.addPostParam("Permissions", prop.toString()); + request.addPostParam("Permissions", String.valueOf(prop)); } - } - if (someA2PThing != null) { - request.addPostParam("SomeA2PThing", someA2PThing); - } + request.addPostParam("SomeA2PThing", String.valueOf(someA2PThing)); + } + } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java index eecf452b2..0e82f5862 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/History.java @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -73,11 +70,11 @@ @ToString public class History extends Resource { private static final long serialVersionUID = 234000032744450L; - public static HistoryFetcher fetcher(final String pathSid){ return new HistoryFetcher(pathSid); } + /** * Converts a JSON String into a History object using the provided ObjectMapper. * diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java index faa0e074e..7cb6e5dde 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java @@ -59,9 +59,10 @@ public HistoryFetcher setAddOnsData(final Map addOnsData){ @Override public History fetch(final TwilioRestClient client) { - String path = "/v1/Credentials/AWS/{Sid}/History"; + String path = String.format("%s", "/v1/Credentials/AWS/{Sid}/History"); + + path = path.replace("{"+"Sid"+"}", this.pathSid); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); Request request = new Request( HttpMethod.GET, diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java index 0278a4065..a9fa69600 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/Fleet.java @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -73,7 +70,6 @@ @ToString public class Fleet extends Resource { private static final long serialVersionUID = 163787776958144L; - public static FleetCreator creator(){ return new FleetCreator(); } @@ -82,6 +78,7 @@ public static FleetFetcher fetcher(final String pathSid){ return new FleetFetcher(pathSid); } + /** * Converts a JSON String into a Fleet object using the provided ObjectMapper. * diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java index a92b6eab0..5e95fd183 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java @@ -26,19 +26,14 @@ import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; import java.time.LocalDate; import com.twilio.converter.Converter; import java.time.ZonedDateTime; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; -import java.net.URI; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -46,7 +41,6 @@ import java.util.Objects; import lombok.ToString; - import java.net.URI; public class FleetCreator extends Creator{ @@ -62,7 +56,7 @@ public FleetCreator setName(final String name){ @Override public Fleet create(final TwilioRestClient client){ - String path = "/DeployedDevices/Fleets"; + String path = String.format("%s", "/DeployedDevices/Fleets"); Request request = new Request( @@ -85,9 +79,8 @@ public Fleet create(final TwilioRestClient client){ return Fleet.fromJson(response.getStream(), client.getObjectMapper()); } private void addPostParams(final Request request) { - if (name != null) { - request.addPostParam("Name", name); + request.addPostParam("Name", String.valueOf(name)); - } } + } diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java index 820aba961..5b1665858 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java @@ -54,9 +54,10 @@ public FleetFetcher(final String pathSid){ @Override public Fleet fetch(final TwilioRestClient client) { - String path = "/DeployedDevices/Fleets/{Sid}"; + String path = String.format("%s", "/DeployedDevices/Fleets/{Sid}"); + + path = path.replace("{"+"Sid"+"}", this.pathSid); - path = path.replace("{"+"Sid"+"}", this.pathSid.toString()); Request request = new Request( HttpMethod.GET, diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java b/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java index ffe062c33..5b74ab2cf 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/understand/Assistant.java @@ -48,10 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java index 13a9bf5a0..4be08005e 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java @@ -124,10 +124,8 @@ public Page getPage(final String targetUrl, final TwilioRestClient cl return pageForRequest(client, request); } private void addQueryParams(final Request request) { - if (pageSize != null) { - request.addQueryParam("PageSize", pageSize.toString()); - } + request.addQueryParam("PageSize", String.valueOf(pageSize)); if(getPageSize() != null) { request.addQueryParam("PageSize", Integer.toString(getPageSize())); diff --git a/src/main/java/com/twilio/oai/TwilioJavaGenerator.java b/src/main/java/com/twilio/oai/TwilioJavaGenerator.java index 0b380055e..1f977c1ad 100644 --- a/src/main/java/com/twilio/oai/TwilioJavaGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioJavaGenerator.java @@ -75,11 +75,13 @@ public void postProcessParameter(final CodegenParameter parameter) { String lastValue = value[value.length-1]; parameter.dataType = LIST_START+lastValue; parameter.baseType = lastValue.substring(0, lastValue.length()-1); + parameter.isString = false; } else if(parameter.dataType.contains("Enum")) { - parameter.vendorExtensions.put(REF_ENUM_EXTENSION_NAME, true); + parameter.vendorExtensions.put(REF_ENUM_EXTENSION_NAME, true); String[] value = parameter.dataType.split("Enum"); parameter.dataType = value[value.length-1]; parameter.baseType = value[value.length-1]; + parameter.isString = false; } else if (parameter.isEnum) { parameter.enumName = parameter.paramName; diff --git a/src/main/java/com/twilio/oai/resolver/common/CodegenParameterContainerDataTypeResolver.java b/src/main/java/com/twilio/oai/resolver/common/CodegenParameterContainerDataTypeResolver.java index b2e021542..574000841 100644 --- a/src/main/java/com/twilio/oai/resolver/common/CodegenParameterContainerDataTypeResolver.java +++ b/src/main/java/com/twilio/oai/resolver/common/CodegenParameterContainerDataTypeResolver.java @@ -18,6 +18,7 @@ public CodegenParameter resolve(CodegenParameter parameter) { String unwrappedContainer = unwrapContainerType(parameter); codegenParameterDataTypeResolver.resolve(parameter); rewrapContainerType(parameter, unwrappedContainer); + parameter.isString = false; return parameter; } diff --git a/src/main/java/com/twilio/oai/resolver/common/CodegenParameterDataTypeResolver.java b/src/main/java/com/twilio/oai/resolver/common/CodegenParameterDataTypeResolver.java index 0fb36ea09..b3aeb5e18 100644 --- a/src/main/java/com/twilio/oai/resolver/common/CodegenParameterDataTypeResolver.java +++ b/src/main/java/com/twilio/oai/resolver/common/CodegenParameterDataTypeResolver.java @@ -23,6 +23,6 @@ private void assignDataType(CodegenParameter parameter) { .properties() .getString(parameter.dataFormat) .or(() -> mapper.properties().getString(parameter.dataType)) - .ifPresent(dataType -> parameter.dataType = dataType); + .ifPresent(dataType -> {parameter.dataType = dataType; parameter.isString = false;}); } } diff --git a/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java b/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java index 61d6fcc8c..3f4b435bd 100644 --- a/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java +++ b/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java @@ -24,11 +24,11 @@ public CodegenParameter resolveEnumParameter(CodegenParameter parameter, String } 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.isString = false; parameter.enumName = parameter.baseType; parameter._enum = (List) parameter.items.allowableValues.get(VALUES); parameter.dataType = LIST_START + resourceName + "." + parameter.baseType + LIST_END; @@ -37,6 +37,7 @@ public CodegenParameter resolveEnumParameter(CodegenParameter parameter, String } if (parameter.allowableValues != null && parameter.allowableValues.containsKey(ENUM_VARS)) { parameter.isEnum = true; + parameter.isString = false; parameter._enum = (List) parameter.allowableValues.get(VALUES); parameter.enumName = parameter.dataType; parameter.dataType = resourceName + "." + parameter.dataType; diff --git a/src/main/java/com/twilio/oai/resolver/java/JavaParameterResolver.java b/src/main/java/com/twilio/oai/resolver/java/JavaParameterResolver.java index 9433fd8c8..598a4fa5a 100644 --- a/src/main/java/com/twilio/oai/resolver/java/JavaParameterResolver.java +++ b/src/main/java/com/twilio/oai/resolver/java/JavaParameterResolver.java @@ -36,6 +36,7 @@ public void resolveProperties(CodegenParameter parameter) { } parameter.isFreeFormObject = true; + parameter.isString = false; } mapper.promotions().getMap(parameter.dataFormat).ifPresent(promotions -> { diff --git a/src/main/resources/twilio-java/api.mustache b/src/main/resources/twilio-java/api.mustache index 58253849b..95ded2d26 100644 --- a/src/main/resources/twilio-java/api.mustache +++ b/src/main/resources/twilio-java/api.mustache @@ -33,15 +33,10 @@ import java.io.InputStream; import java.net.URI; import java.time.ZonedDateTime; -{{^fullJavaUtil}} import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; -{{/fullJavaUtil}} - - import java.util.Map; import java.time.LocalDate; import java.math.BigDecimal; @@ -63,7 +58,6 @@ import com.twilio.type.SubscribeRule; @ToString public class {{apiName}} extends Resource { private static final long serialVersionUID = {{serialVersionUID}}L; - {{#apiOperations}} {{#vendorExtensions.x-is-create-operation}} {{#vendorExtensions.x-signature-list}} @@ -71,7 +65,6 @@ public class {{apiName}} extends Resource { return new {{apiName}}Creator({{#.}}{{{paramName}}}{{^-last}}, {{/-last}}{{/.}}); } {{/vendorExtensions.x-signature-list}} - {{/vendorExtensions.x-is-create-operation}} {{#vendorExtensions.x-is-fetch-operation}} {{#vendorExtensions.x-signature-list}} @@ -87,8 +80,8 @@ public class {{apiName}} extends Resource { return new {{apiName}}Deleter({{#.}}{{{paramName}}}{{^-last}}, {{/-last}}{{/.}}); } {{/vendorExtensions.x-signature-list}} - {{/vendorExtensions.x-is-delete-operation}} + {{#vendorExtensions.x-is-read-operation}} {{#vendorExtensions.x-signature-list}} public static {{apiName}}Reader reader({{#.}}final {{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/.}}){ @@ -103,7 +96,6 @@ public class {{apiName}} extends Resource { return new {{apiName}}Updater({{#.}}{{{paramName}}}{{^-last}}, {{/-last}}{{/.}}); } {{/vendorExtensions.x-signature-list}} - {{/vendorExtensions.x-is-update-operation}} {{/apiOperations}} /** diff --git a/src/main/resources/twilio-java/creator.mustache b/src/main/resources/twilio-java/creator.mustache index 571153b6d..f91badc7d 100644 --- a/src/main/resources/twilio-java/creator.mustache +++ b/src/main/resources/twilio-java/creator.mustache @@ -14,29 +14,21 @@ import com.twilio.http.Request; import com.twilio.http.Response; import com.twilio.http.TwilioRestClient; import com.twilio.rest.Domains; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; import java.time.LocalDate; import com.twilio.converter.Converter; import java.time.ZonedDateTime; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; -import java.net.URI; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; - -{{^fullJavaUtil}} import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -{{/fullJavaUtil}} import lombok.ToString; - import java.net.URI; {{#apiOperations}} diff --git a/src/main/resources/twilio-java/dateParams.mustache b/src/main/resources/twilio-java/dateParams.mustache index c9964a0fb..df2c562e1 100644 --- a/src/main/resources/twilio-java/dateParams.mustache +++ b/src/main/resources/twilio-java/dateParams.mustache @@ -1,18 +1,24 @@ {{#isDate}} {{#isFormParam}} - request.addPostParam("{{baseName}}", DateConverter.dateStringFromLocalDate({{paramName}})); + if ({{paramName}} != null) { + request.addPostParam("{{baseName}}", DateConverter.dateStringFromLocalDate({{paramName}})); + } {{/isFormParam}} {{^isFormParam}} - request.addQueryParam("{{baseName}}", DateConverter.dateStringFromLocalDate({{paramName}})); + if ({{paramName}} != null) { + request.addQueryParam("{{baseName}}", DateConverter.dateStringFromLocalDate({{paramName}})); } {{/isFormParam}} {{/isDate}} {{#isDateTime}} {{#isFormParam}} - request.addPostParam("{{baseName}}", {{paramName}}.toInstant().toString()); + if ({{paramName}} != null) { + request.addPostParam("{{baseName}}", {{paramName}}.toInstant().toString()); + } {{/isFormParam}} {{^isFormParam}} - request.addQueryParam("{{baseName}}", {{paramName}}.toInstant().toString()); + if ({{paramName}} != null) { + request.addQueryParam("{{baseName}}", {{paramName}}.toInstant().toString()); } {{/isFormParam}} -{{/isDateTime}} \ No newline at end of file +{{/isDateTime}} diff --git a/src/main/resources/twilio-java/deleter.mustache b/src/main/resources/twilio-java/deleter.mustache index 4292ad91f..333132c8e 100644 --- a/src/main/resources/twilio-java/deleter.mustache +++ b/src/main/resources/twilio-java/deleter.mustache @@ -23,13 +23,11 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; -{{^fullJavaUtil}} import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -{{/fullJavaUtil}} import lombok.ToString; diff --git a/src/main/resources/twilio-java/fetcher.mustache b/src/main/resources/twilio-java/fetcher.mustache index 463711373..8cd3afc0b 100644 --- a/src/main/resources/twilio-java/fetcher.mustache +++ b/src/main/resources/twilio-java/fetcher.mustache @@ -24,13 +24,11 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; -{{^fullJavaUtil}} import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -{{/fullJavaUtil}} import lombok.ToString; diff --git a/src/main/resources/twilio-java/generate_uri.mustache b/src/main/resources/twilio-java/generate_uri.mustache index 9fbfaa9d5..b6d7179f7 100644 --- a/src/main/resources/twilio-java/generate_uri.mustache +++ b/src/main/resources/twilio-java/generate_uri.mustache @@ -1,14 +1,19 @@ {{#vendorExtensions.parentUrl}} - String path = "{{{vendorExtensions.parentUrl}}}"; + String path = String.format("%s", "{{{vendorExtensions.parentUrl}}}"); {{/vendorExtensions.parentUrl}} {{^vendorExtensions.parentUrl}} - String path = "{{{path}}}"; + String path = String.format("%s", "{{{path}}}"); {{/vendorExtensions.parentUrl}} {{#allParams}} {{#vendorExtensions.x-is-account-sid}} this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; + {{#isString}} + path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}); + {{/isString}} + {{^isString}} path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); + {{/isString}} {{/vendorExtensions.x-is-account-sid}} {{/allParams}} {{#requiredParams}} @@ -16,6 +21,12 @@ path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.encode("utf-8")); {{/vendorExtensions.x-is-phone-number-format}} {{^vendorExtensions.x-is-phone-number-format}} + {{#isString}} + path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}); + {{/isString}} + {{^isString}} path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); + {{/isString}} + {{/vendorExtensions.x-is-phone-number-format}} {{/requiredParams}} diff --git a/src/main/resources/twilio-java/headerParams.mustache b/src/main/resources/twilio-java/headerParams.mustache index bb423155a..ba5acb7de 100644 --- a/src/main/resources/twilio-java/headerParams.mustache +++ b/src/main/resources/twilio-java/headerParams.mustache @@ -1,23 +1,20 @@ private void addHeaderParams(final Request request) { {{#headerParams}} - if ({{paramName}} != null) { {{#vendorExtensions.x-is-other-data-type}} - request.addHeaderParam("{{baseName}}", {{paramName}}.toString()); + request.addHeaderParam("{{baseName}}", String.valueOf({{paramName}})); {{/vendorExtensions.x-is-other-data-type}} {{^vendorExtensions.x-is-other-data-type}} {{#isEnum}} - request.addHeaderParam("{{baseName}}", {{paramName}}.toString()); + request.addHeaderParam("{{baseName}}", String.valueOf({{paramName}})); {{/isEnum}} {{^isEnum}} {{#isString}} - request.addHeaderParam("{{baseName}}", {{paramName}}); + request.addHeaderParam("{{baseName}}", String.valueOf({{paramName}})); {{/isString}} {{^isString}} - request.addHeaderParam("{{baseName}}", {{paramName}}.toString()); + request.addHeaderParam("{{baseName}}", String.valueOf({{paramName}})); {{/isString}} {{/isEnum}} - {{/vendorExtensions.x-is-other-data-type}} - } {{/headerParams}} - } \ No newline at end of file + } diff --git a/src/main/resources/twilio-java/postParams.mustache b/src/main/resources/twilio-java/postParams.mustache index 5dbfeb544..9c27339dc 100644 --- a/src/main/resources/twilio-java/postParams.mustache +++ b/src/main/resources/twilio-java/postParams.mustache @@ -1,48 +1,56 @@ private void addPostParams(final Request request) { {{#formParams}} - if ({{paramName}} != null) { {{#isFreeFormObject}} {{#isArray}} + if ({{paramName}} != null) { for (Map prop : {{paramName}}) { request.addPostParam("{{baseName}}", Converter.mapToJson(prop)); } + } {{/isArray}} {{^isArray}} + if ({{paramName}} != null) { request.addPostParam("{{baseName}}", Converter.mapToJson({{paramName}})); + } {{/isArray}} {{/isFreeFormObject}} {{^isFreeFormObject}} {{#isArray}} {{#isEnum}} + if ({{paramName}} != null) { for ({{baseType}} prop : {{paramName}}) { - request.addPostParam("{{{baseName}}}", prop.toString()); + request.addPostParam("{{{baseName}}}", String.valueOf(prop)); } + } {{/isEnum}} {{^isEnum}} {{#vendorExtensions.x-is-string-array}} + if ({{paramName}} != null) { for ({{baseType}} prop : {{paramName}}) { request.addPostParam("{{baseName}}", prop); } + } {{/vendorExtensions.x-is-string-array}} {{^vendorExtensions.x-is-string-array}} + if ({{paramName}} != null) { for ({{baseType}} prop : {{paramName}}) { - request.addPostParam("{{baseName}}", prop.toString()); + request.addPostParam("{{baseName}}", String.valueOf(prop)); } + } {{/vendorExtensions.x-is-string-array}} {{/isEnum}} {{/isArray}} {{^isArray}} {{#vendorExtensions.x-is-other-data-type}} - request.addPostParam("{{{baseName}}}", {{paramName}}.toString()); + request.addPostParam("{{{baseName}}}", String.valueOf({{paramName}})); {{/vendorExtensions.x-is-other-data-type}} {{^vendorExtensions.x-is-other-data-type}} {{#isString}} - request.addPostParam("{{baseName}}", {{paramName}}); + request.addPostParam("{{baseName}}", String.valueOf({{paramName}})); {{/isString}} {{/vendorExtensions.x-is-other-data-type}} {{/isArray}} {{/isFreeFormObject}} {{>dateParams}} - } {{/formParams}} - } \ No newline at end of file + } diff --git a/src/main/resources/twilio-java/queryParams.mustache b/src/main/resources/twilio-java/queryParams.mustache index 219c3803a..822a79d05 100644 --- a/src/main/resources/twilio-java/queryParams.mustache +++ b/src/main/resources/twilio-java/queryParams.mustache @@ -7,24 +7,26 @@ {{>prefixedCollapsibleMapQParams}} {{/vendorExtensions.x-prefixed-collapsible-map}} {{^vendorExtensions.x-prefixed-collapsible-map}} - if ({{paramName}} != null) { {{#isArray}} {{#isEnum}} + if ({{paramName}} != null) { for ({{baseType}} prop : {{paramName}}) { - request.addQueryParam("{{baseName}}", prop.toString()); + request.addQueryParam("{{baseName}}", String.valueOf(prop)); } } {{/isEnum}} {{^isEnum}} {{#vendorExtensions.x-is-string-array}} + if ({{paramName}} != null) { for ({{baseType}} prop : {{paramName}}) { request.addQueryParam("{{baseName}}", prop); } } {{/vendorExtensions.x-is-string-array}} {{^vendorExtensions.x-is-string-array}} + if ({{paramName}} != null) { for ({{baseType}} prop : {{paramName}}) { - request.addQueryParam("{{baseName}}", prop.toString()); + request.addQueryParam("{{baseName}}", String.valueOf(prop)); } } {{/vendorExtensions.x-is-string-array}} @@ -33,13 +35,11 @@ {{^isArray}} {{>dateParams}} {{#vendorExtensions.x-is-other-data-type}} - request.addQueryParam("{{baseName}}", {{paramName}}.toString()); - } + request.addQueryParam("{{baseName}}", String.valueOf({{paramName}})); {{/vendorExtensions.x-is-other-data-type}} {{^vendorExtensions.x-is-other-data-type}} {{#isString}} - request.addQueryParam("{{baseName}}", {{paramName}}); - } + request.addQueryParam("{{baseName}}", String.valueOf({{paramName}})); {{/isString}} {{/vendorExtensions.x-is-other-data-type}} {{/isArray}} diff --git a/src/main/resources/twilio-java/reader.mustache b/src/main/resources/twilio-java/reader.mustache index 28a6e15db..ca33712b0 100644 --- a/src/main/resources/twilio-java/reader.mustache +++ b/src/main/resources/twilio-java/reader.mustache @@ -25,13 +25,11 @@ import java.net.URI; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; -{{^fullJavaUtil}} import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -{{/fullJavaUtil}} import lombok.ToString; diff --git a/src/main/resources/twilio-java/responseModel.mustache b/src/main/resources/twilio-java/responseModel.mustache index b19f2bffc..3fdd4b3a9 100644 --- a/src/main/resources/twilio-java/responseModel.mustache +++ b/src/main/resources/twilio-java/responseModel.mustache @@ -14,6 +14,7 @@ this.value = value; } + @Override public String toString() { return value; } diff --git a/src/main/resources/twilio-java/updater.mustache b/src/main/resources/twilio-java/updater.mustache index e12a78547..4b51df79e 100644 --- a/src/main/resources/twilio-java/updater.mustache +++ b/src/main/resources/twilio-java/updater.mustache @@ -24,13 +24,11 @@ import java.net.URI; import java.time.ZonedDateTime; import java.time.LocalDate; -{{^fullJavaUtil}} import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -{{/fullJavaUtil}} import lombok.ToString;