diff --git a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb index 957169297..c069b93e2 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb @@ -153,8 +153,9 @@ def page(date_created: :unset, date_test: :unset, date_created_before: :unset, 'Page' => page_number, 'PageSize' => page_size, }) + headers = Twilio::Values.of({}) - response = @version.page('GET', @uri, params: params) + response = @version.page('GET', @uri, params: params, headers: headers) AccountPage.new(@version, response, @solution) end diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb index 8fc236a3b..c466053c0 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb @@ -95,8 +95,9 @@ def page(page_token: :unset, page_number: :unset, page_size: :unset) 'Page' => page_number, 'PageSize' => page_size, }) + headers = Twilio::Values.of({}) - response = @version.page('GET', @uri, params: params) + response = @version.page('GET', @uri, params: params, headers: headers) AwsPage.new(@version, response, @solution) end diff --git a/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb b/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb index 279b9a648..ea7d27c17 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb @@ -94,8 +94,9 @@ def page(page_token: :unset, page_number: :unset, page_size: :unset) 'Page' => page_number, 'PageSize' => page_size, }) + headers = Twilio::Values.of({}) - response = @version.page('GET', @uri, params: params) + response = @version.page('GET', @uri, params: params, headers: headers) AssistantPage.new(@version, response, @solution) end diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index 3861ae2c6..62ca8b3f2 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -21,7 +21,7 @@ generateForLanguages = { 'twilio_iam_organizations.json' : ['java', 'csharp'] } -dynamic_languages = ['node', 'python'] +dynamic_languages = ['node', 'python', 'ruby'] CLEANUP_IMPORT_LANGUAGES = ['java', 'php'] REMOVE_DUPLICATE_IMPORT_LANGUAGES = ['node'] CONFIG_FOLDER = 'tmp' diff --git a/src/main/java/com/twilio/oai/api/RubyApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/RubyApiResourceBuilder.java index bd0cb4b00..a06e15a38 100644 --- a/src/main/java/com/twilio/oai/api/RubyApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/RubyApiResourceBuilder.java @@ -387,4 +387,29 @@ private ApiResourceBuilder updateVersionData() { updateVersionResources(); return this; } + + protected void categorizeOperations() { + codegenOperationList.stream().filter(operation -> !operation.vendorExtensions.containsKey("x-ignore")).forEach(codegenOperation -> { + boolean isInstanceOperation = PathUtils.isInstanceOperation(codegenOperation); + if (!isInstanceOperation) { + listOperations.add(codegenOperation); + codegenOperation.vendorExtensions.put("listOperation", true); + metaAPIProperties.put("hasListOperation", true); + } else { + instanceOperations.add(codegenOperation); + codegenOperation.vendorExtensions.put("instanceOperation", true); + metaAPIProperties.put("hasInstanceOperation", true); + } + }); + codegenOperationList.stream().forEach(operation -> { + if (operation.hasProduces && operation.produces.size() > 1) + operation.vendorExtensions.put("multipleProduces", true); + else if(operation.hasProduces && operation.produces.get(0).containsKey("mediaType") && operation.produces.get(0).get("mediaType").equals("application/scim+json")) + operation.vendorExtensions.put("scimProduces", true); + }); + codegenOperationList.stream().forEach(operation -> { + if(operation.hasConsumes && operation.consumes.stream().anyMatch(consume -> consume.containsKey("mediaType") && consume.get("mediaType").equals("application/scim+json"))) + operation.vendorExtensions.put("scimConsumes", true); + }); + } } diff --git a/src/main/resources/twilio-ruby/contextMethodParams.mustache b/src/main/resources/twilio-ruby/contextMethodParams.mustache index 070fda2b5..d08400293 100644 --- a/src/main/resources/twilio-ruby/contextMethodParams.mustache +++ b/src/main/resources/twilio-ruby/contextMethodParams.mustache @@ -101,8 +101,12 @@ {{/vendorExtensions.x-prefixed-collapsible-map}}{{/isFormParam}}{{/optionalParams}} {{/formParams.0}} headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', {{#headerParams}}{{#required}}'{{baseName}}' => {{paramName}}, {{/required}}{{/headerParams}}{{#headerParams}}{{^required}}'{{baseName}}' => {{paramName}}, {{/required}}{{/headerParams}}}) - {{#bodyParams.0}}headers['Content-Type'] = 'application/json'{{/bodyParams.0}} + {{^vendorExtensions.scimConsumes}}{{#bodyParams.0}}headers['Content-Type'] = 'application/json'{{/bodyParams.0}}{{/vendorExtensions.scimConsumes}} + {{#vendorExtensions.scimConsumes}}headers['Content-Type'] = 'application/scim+json'{{/vendorExtensions.scimConsumes}} + {{#vendorExtensions.x-is-delete-operation}}{{#vendorExtensions.scimProduces}}headers['Accept'] = '*/*'{{/vendorExtensions.scimProduces}}{{/vendorExtensions.x-is-delete-operation}} {{^vendorExtensions.x-is-delete-operation}} + {{#vendorExtensions.scimProduces}}headers['Accept'] = 'application/scim+json'{{/vendorExtensions.scimProduces}} + {{#vendorExtensions.multipleProduces}} headers['Accept'] = '*/*'{{/vendorExtensions.multipleProduces}} payload = @version.{{#lambda.camelcase}}{{vendorExtensions.x-name}}{{/lambda.camelcase}}('{{httpMethod}}', @uri{{#queryParams.0}}, params: params{{/queryParams.0}}{{#formParams.0}}, data: data{{/formParams.0}}, headers: headers{{#bodyParams.0}}, data: {{paramName}}.to_json{{/bodyParams.0}}) {{apiName}}Instance.new( @version, diff --git a/src/main/resources/twilio-ruby/list.mustache b/src/main/resources/twilio-ruby/list.mustache index 913457f3a..6a208c26c 100644 --- a/src/main/resources/twilio-ruby/list.mustache +++ b/src/main/resources/twilio-ruby/list.mustache @@ -109,8 +109,11 @@ 'Page' => page_number, 'PageSize' => page_size, }) + headers = Twilio::Values.of({}) + {{#vendorExtensions.scimConsumes}}headers['Content-Type'] = 'application/scim+json'{{/vendorExtensions.scimConsumes}} + {{#vendorExtensions.scimProduces}}headers['Accept'] = 'application/scim+json'{{/vendorExtensions.scimProduces}} - response = @version.page('{{httpMethod}}', @uri, params: params) + response = @version.page('{{httpMethod}}', @uri, params: params, headers: headers) {{apiName}}Page.new(@version, response, @solution) end diff --git a/src/main/resources/twilio-ruby/methods.mustache b/src/main/resources/twilio-ruby/methods.mustache index 82424b436..a74bd8799 100644 --- a/src/main/resources/twilio-ruby/methods.mustache +++ b/src/main/resources/twilio-ruby/methods.mustache @@ -21,5 +21,5 @@ def {{#lambda.camelcase}}{{vendorExtensions.x-name}}{{/lambda.camelcase}}{{#hasParams}}({{#queryParams}} {{paramName}}: {{#required}}nil{{/required}}{{^required}}:unset{{/required}}{{^-last}}, {{/-last}}{{/queryParams}}{{#formParams.0}}{{#queryParams.0}}, {{/queryParams.0}}{{/formParams.0}}{{#formParams}} {{paramName}}: {{#required}}nil{{/required}}{{^required}}:unset{{/required}}{{^-last}}, {{/-last}}{{/formParams}}{{#headerParams.0}}{{#queryParams.0}}, {{/queryParams.0}}{{^queryParams.0}}{{#formParams.0}}, {{/formParams.0}}{{/queryParams.0}}{{/headerParams.0}}{{#headerParams}} - {{paramName}}: {{#required}}nil{{/required}}{{^required}}:unset{{/required}}{{^-last}}, {{/-last}}{{/headerParams}}{{#bodyParams}}{{paramName}}: {{#required}}nil{{/required}}{{^required}}:unset{{/required}}{{^-last}}, {{/-last}}{{/bodyParams}} + {{paramName}}: {{#required}}nil{{/required}}{{^required}}:unset{{/required}}{{^-last}}, {{/-last}}{{/headerParams}}{{#bodyParams}}{{#headerParams.0}},{{/headerParams.0}}{{paramName}}: {{#required}}nil{{/required}}{{^required}}:unset{{/required}}{{^-last}}, {{/-last}}{{/bodyParams}} ){{/hasParams}} diff --git a/src/main/resources/twilio-ruby/modelClasses.mustache b/src/main/resources/twilio-ruby/modelClasses.mustache index 510e1088b..ff8573f31 100644 --- a/src/main/resources/twilio-ruby/modelClasses.mustache +++ b/src/main/resources/twilio-ruby/modelClasses.mustache @@ -12,9 +12,9 @@ def to_json(options = {}) { {{#vars}} - {{name}}: @{{name}}, + "{{baseName}}": @{{name}}, {{/vars}} }.to_json(options) end end -{{/hasVars}}{{/vendorExtensions.part-of-response-model}}{{/models}} \ No newline at end of file +{{/hasVars}}{{/vendorExtensions.part-of-response-model}}{{/models}}