Skip to content

chore: handle free form objects correctly #652

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ private void addPostParams(final Request request) {

}
}

private void addHeaderParams(final Request request) {
if (xTwilioWebhookEnabled != null) {
request.addHeaderParam("X-Twilio-Webhook-Enabled", xTwilioWebhookEnabled.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public class NewCredentials extends Resource {
public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Float testNumberFloat){
return new NewCredentialsCreator(testString, testInteger, testNumberFloat);
}
public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Map<String, Object> testObject){
public static NewCredentialsCreator creator(final String testString, final Integer testInteger, final Object testObject){
return new NewCredentialsCreator(testString, testInteger, testObject);
}
public static NewCredentialsCreator creator(final String testString, final LocalDate testDate, final Float testNumberFloat){
return new NewCredentialsCreator(testString, testDate, testNumberFloat);
}
public static NewCredentialsCreator creator(final String testString, final LocalDate testDate, final Map<String, Object> testObject){
public static NewCredentialsCreator creator(final String testString, final LocalDate testDate, final Object testObject){
return new NewCredentialsCreator(testString, testDate, testObject);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public class NewCredentialsCreator extends Creator<NewCredentials>{
private Double testNumberDouble;
private BigDecimal testNumberInt32;
private Long testNumberInt64;
private Map<String, Object> testObject;
private Object testObject;
private ZonedDateTime testDateTime;
private LocalDate testDate;
private NewCredentials.Status testEnum;
private List<Map<String, Object>> testObjectArray;
private Map<String, Object> testAnyType;
private List<Map<String, Object>> testAnyArray;
private List<Object> testObjectArray;
private Object testAnyType;
private List<Object> testAnyArray;
private List<NewCredentials.Permissions> permissions;
private String someA2PThing;

Expand All @@ -77,7 +77,7 @@ public NewCredentialsCreator(final String testString, final Integer testInteger,
this.testInteger = testInteger;
this.testNumberFloat = testNumberFloat;
}
public NewCredentialsCreator(final String testString, final Integer testInteger, final Map<String, Object> testObject) {
public NewCredentialsCreator(final String testString, final Integer testInteger, final Object testObject) {
this.testString = testString;
this.testInteger = testInteger;
this.testObject = testObject;
Expand All @@ -87,7 +87,7 @@ public NewCredentialsCreator(final String testString, final LocalDate testDate,
this.testDate = testDate;
this.testNumberFloat = testNumberFloat;
}
public NewCredentialsCreator(final String testString, final LocalDate testDate, final Map<String, Object> testObject) {
public NewCredentialsCreator(final String testString, final LocalDate testDate, final Object testObject) {
this.testString = testString;
this.testDate = testDate;
this.testObject = testObject;
Expand Down Expand Up @@ -125,7 +125,7 @@ public NewCredentialsCreator setTestNumberInt64(final Long testNumberInt64){
this.testNumberInt64 = testNumberInt64;
return this;
}
public NewCredentialsCreator setTestObject(final Map<String, Object> testObject){
public NewCredentialsCreator setTestObject(final Object testObject){
this.testObject = testObject;
return this;
}
Expand All @@ -141,22 +141,22 @@ public NewCredentialsCreator setTestEnum(final NewCredentials.Status testEnum){
this.testEnum = testEnum;
return this;
}
public NewCredentialsCreator setTestObjectArray(final List<Map<String, Object>> testObjectArray){
public NewCredentialsCreator setTestObjectArray(final List<Object> testObjectArray){
this.testObjectArray = testObjectArray;
return this;
}
public NewCredentialsCreator setTestObjectArray(final Map<String, Object> testObjectArray){
public NewCredentialsCreator setTestObjectArray(final Object testObjectArray){
return setTestObjectArray(Promoter.listOfOne(testObjectArray));
}
public NewCredentialsCreator setTestAnyType(final Map<String, Object> testAnyType){
public NewCredentialsCreator setTestAnyType(final Object testAnyType){
this.testAnyType = testAnyType;
return this;
}
public NewCredentialsCreator setTestAnyArray(final List<Map<String, Object>> testAnyArray){
public NewCredentialsCreator setTestAnyArray(final List<Object> testAnyArray){
this.testAnyArray = testAnyArray;
return this;
}
public NewCredentialsCreator setTestAnyArray(final Map<String, Object> testAnyArray){
public NewCredentialsCreator setTestAnyArray(final Object testAnyArray){
return setTestAnyArray(Promoter.listOfOne(testAnyArray));
}
public NewCredentialsCreator setPermissions(final List<NewCredentials.Permissions> permissions){
Expand Down Expand Up @@ -247,7 +247,7 @@ private void addPostParams(final Request request) {

}
if (testObjectArray != null) {
for (Map<String, Object> prop : testObjectArray) {
for (Object prop : testObjectArray) {
request.addPostParam("TestObjectArray", Converter.mapToJson(prop));
}

Expand All @@ -257,7 +257,7 @@ private void addPostParams(final Request request) {

}
if (testAnyArray != null) {
for (Map<String, Object> prop : testAnyArray) {
for (Object prop : testAnyArray) {
request.addPostParam("TestAnyArray", Converter.mapToJson(prop));
}

Expand All @@ -273,4 +273,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class ApiKey extends Resource {
private static final long serialVersionUID = 99197666922652L;
private static final long serialVersionUID = 33828408490571L;



Expand Down Expand Up @@ -134,7 +134,7 @@ public static ApiKey fromJson(final InputStream json, final ObjectMapper objectM
private final String friendlyName;
private final ZonedDateTime dateCreated;
private final ZonedDateTime dateUpdated;
private final Map<String, Object> policy;
private final Object policy;

@JsonCreator
private ApiKey(
Expand All @@ -151,7 +151,7 @@ private ApiKey(
final String dateUpdated,

@JsonProperty("policy")
final Map<String, Object> policy
final Object policy
) {
this.sid = sid;
this.friendlyName = friendlyName;
Expand All @@ -172,7 +172,7 @@ public final ZonedDateTime getDateCreated() {
public final ZonedDateTime getDateUpdated() {
return this.dateUpdated;
}
public final Map<String, Object> getPolicy() {
public final Object getPolicy() {
return this.policy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
public class ApiKeyUpdater extends Updater<ApiKey>{
private String pathSid;
private String friendlyName;
private Map<String, Object> policy;
private Object policy;

public ApiKeyUpdater(final String pathSid){
this.pathSid = pathSid;
Expand All @@ -61,7 +61,7 @@ public ApiKeyUpdater setFriendlyName(final String friendlyName){
this.friendlyName = friendlyName;
return this;
}
public ApiKeyUpdater setPolicy(final Map<String, Object> policy){
public ApiKeyUpdater setPolicy(final Object policy){
this.policy = policy;
return this;
}
Expand Down Expand Up @@ -103,4 +103,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString
public class NewApiKey extends Resource {
private static final long serialVersionUID = 217181042856619L;
private static final long serialVersionUID = 58775637028152L;



Expand Down Expand Up @@ -127,7 +127,7 @@ public static NewApiKey fromJson(final InputStream json, final ObjectMapper obje
private final ZonedDateTime dateCreated;
private final ZonedDateTime dateUpdated;
private final String secret;
private final Map<String, Object> policy;
private final Object policy;

@JsonCreator
private NewApiKey(
Expand All @@ -147,7 +147,7 @@ private NewApiKey(
final String secret,

@JsonProperty("policy")
final Map<String, Object> policy
final Object policy
) {
this.sid = sid;
this.friendlyName = friendlyName;
Expand All @@ -172,7 +172,7 @@ public final ZonedDateTime getDateUpdated() {
public final String getSecret() {
return this.secret;
}
public final Map<String, Object> getPolicy() {
public final Object getPolicy() {
return this.policy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class NewApiKeyCreator extends Creator<NewApiKey>{
private String accountSid;
private String friendlyName;
private NewApiKey.Keytype keyType;
private Map<String, Object> policy;
private Object policy;

public NewApiKeyCreator(final String accountSid) {
this.accountSid = accountSid;
Expand All @@ -75,7 +75,7 @@ public NewApiKeyCreator setKeyType(final NewApiKey.Keytype keyType){
this.keyType = keyType;
return this;
}
public NewApiKeyCreator setPolicy(final Map<String, Object> policy){
public NewApiKeyCreator setPolicy(final Object policy){
this.policy = policy;
return this;
}
Expand Down Expand Up @@ -124,4 +124,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,5 @@ private void addPostParams(final NoAuthRequest request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,5 @@ private void addPostParams(final NoAuthRequest request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ private void addPostParams(final Request request) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface NewCredentialsListInstanceCreateOptions {
/** */
testNumberInt64?: number;
/** */
testObject?: Record<string, object>;
testObject?: Record<string, any>;
/** */
testDateTime?: Date;
/** */
Expand Down
4 changes: 2 additions & 2 deletions examples/node/src/rest/iam/v1/apiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ interface ApiKeyResource {
friendly_name: string;
date_created: Date;
date_updated: Date;
policy: Record<string, object>;
policy: Record<string, any>;
}

export class ApiKeyInstance {
Expand Down Expand Up @@ -253,7 +253,7 @@ export class ApiKeyInstance {
/**
* The \\`Policy\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys).
*/
policy: Record<string, object>;
policy: Record<string, any>;

private get _proxy(): ApiKeyContext {
this._context =
Expand Down
4 changes: 2 additions & 2 deletions examples/node/src/rest/iam/v1/newApiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ interface NewApiKeyResource {
date_created: Date;
date_updated: Date;
secret: string;
policy: Record<string, object>;
policy: Record<string, any>;
}

export class NewApiKeyInstance {
Expand Down Expand Up @@ -173,7 +173,7 @@ export class NewApiKeyInstance {
/**
* Collection of allow assertions.
*/
policy: Record<string, object>;
policy: Record<string, any>;

/**
* Provide a user-friendly representation
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/java.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"inbound_sms_price": "InboundSmsPrice",
"integer": "Integer",
"long": "Long",
"object": "Map<String, Object>",
"object": "Object",
"outbound_call_price": "OutboundCallPrice",
"outbound_call_price_with_origin": "OutboundCallPriceWithOrigin",
"outbound_prefix_price": "OutboundPrefixPrice",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/node.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"boolean": "boolean",
"integer": "number",
"long": "number",
"object": "Record<string, object>",
"object": "Record<string, any>",
"phone_number_capabilities": "PhoneNumberCapabilities",
"prefixed_collapsible_map": "Record<string, object>",
"string_map": "Record<string, string>",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/twilio-java/postParams.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if ({{paramName}} != null) {
{{#isFreeFormObject}}
{{#isArray}}
for (Map<String, Object> prop : {{paramName}}) {
for (Object prop : {{paramName}}) {
request.addPostParam("{{baseName}}", Converter.mapToJson(prop));
}
{{/isArray}}
Expand Down Expand Up @@ -45,4 +45,4 @@
{{>dateParams}}
}
{{/formParams}}
}
}
Loading