Skip to content
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

feat: orgs api #626

Merged
merged 4 commits into from
Dec 9, 2024
Merged
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
3 changes: 2 additions & 1 deletion examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_twilio_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/twilio/oai/api/RubyApiResourceBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
6 changes: 5 additions & 1 deletion src/main/resources/twilio-ruby/contextMethodParams.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/twilio-ruby/list.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/twilio-ruby/methods.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
4 changes: 2 additions & 2 deletions src/main/resources/twilio-ruby/modelClasses.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
{{/hasVars}}{{/vendorExtensions.part-of-response-model}}{{/models}}
Loading