dropbox-sign 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +26 -24
- data/README.md +6 -4
- data/VERSION +1 -1
- data/docs/AccountResponse.md +1 -0
- data/docs/AccountResponseQuotas.md +1 -0
- data/docs/AccountResponseUsage.md +10 -0
- data/dropbox-sign.gemspec +2 -1
- data/lib/dropbox-sign/api/account_api.rb +1 -1
- data/lib/dropbox-sign/api/api_app_api.rb +3 -3
- data/lib/dropbox-sign/api/bulk_send_job_api.rb +5 -5
- data/lib/dropbox-sign/api/embedded_api.rb +1 -1
- data/lib/dropbox-sign/api/o_auth_api.rb +1 -1
- data/lib/dropbox-sign/api/report_api.rb +1 -1
- data/lib/dropbox-sign/api/signature_request_api.rb +5 -5
- data/lib/dropbox-sign/api/team_api.rb +5 -5
- data/lib/dropbox-sign/api/template_api.rb +4 -4
- data/lib/dropbox-sign/api/unclaimed_draft_api.rb +1 -1
- data/lib/dropbox-sign/api_client.rb +27 -24
- data/lib/dropbox-sign/api_error.rb +2 -1
- data/lib/dropbox-sign/configuration.rb +39 -9
- data/lib/dropbox-sign/event_callback_helper.rb +1 -1
- data/lib/dropbox-sign/models/account_create_request.rb +2 -4
- data/lib/dropbox-sign/models/account_create_response.rb +2 -4
- data/lib/dropbox-sign/models/account_get_response.rb +2 -4
- data/lib/dropbox-sign/models/account_response.rb +17 -9
- data/lib/dropbox-sign/models/account_response_quotas.rb +19 -9
- data/lib/dropbox-sign/models/account_response_usage.rb +251 -0
- data/lib/dropbox-sign/models/account_update_request.rb +2 -4
- data/lib/dropbox-sign/models/account_verify_request.rb +2 -4
- data/lib/dropbox-sign/models/account_verify_response.rb +2 -4
- data/lib/dropbox-sign/models/account_verify_response_account.rb +2 -4
- data/lib/dropbox-sign/models/api_app_create_request.rb +2 -4
- data/lib/dropbox-sign/models/api_app_get_response.rb +2 -4
- data/lib/dropbox-sign/models/api_app_list_response.rb +2 -4
- data/lib/dropbox-sign/models/api_app_response.rb +2 -4
- data/lib/dropbox-sign/models/api_app_response_o_auth.rb +2 -4
- data/lib/dropbox-sign/models/api_app_response_options.rb +2 -4
- data/lib/dropbox-sign/models/api_app_response_owner_account.rb +2 -4
- data/lib/dropbox-sign/models/api_app_response_white_labeling_options.rb +2 -4
- data/lib/dropbox-sign/models/api_app_update_request.rb +3 -5
- data/lib/dropbox-sign/models/bulk_send_job_get_response.rb +2 -4
- data/lib/dropbox-sign/models/bulk_send_job_get_response_signature_requests.rb +2 -4
- data/lib/dropbox-sign/models/bulk_send_job_list_response.rb +2 -4
- data/lib/dropbox-sign/models/bulk_send_job_response.rb +2 -4
- data/lib/dropbox-sign/models/bulk_send_job_send_response.rb +2 -4
- data/lib/dropbox-sign/models/embedded_edit_url_request.rb +2 -4
- data/lib/dropbox-sign/models/embedded_edit_url_response.rb +2 -4
- data/lib/dropbox-sign/models/embedded_edit_url_response_embedded.rb +2 -4
- data/lib/dropbox-sign/models/embedded_sign_url_response.rb +2 -4
- data/lib/dropbox-sign/models/embedded_sign_url_response_embedded.rb +2 -4
- data/lib/dropbox-sign/models/error_response.rb +2 -4
- data/lib/dropbox-sign/models/error_response_error.rb +2 -4
- data/lib/dropbox-sign/models/event_callback_request.rb +2 -4
- data/lib/dropbox-sign/models/event_callback_request_event.rb +2 -4
- data/lib/dropbox-sign/models/event_callback_request_event_metadata.rb +2 -4
- data/lib/dropbox-sign/models/file_response.rb +2 -4
- data/lib/dropbox-sign/models/file_response_data_uri.rb +2 -4
- data/lib/dropbox-sign/models/list_info_response.rb +2 -4
- data/lib/dropbox-sign/models/o_auth_token_generate_request.rb +2 -4
- data/lib/dropbox-sign/models/o_auth_token_refresh_request.rb +2 -4
- data/lib/dropbox-sign/models/o_auth_token_response.rb +2 -4
- data/lib/dropbox-sign/models/report_create_request.rb +2 -4
- data/lib/dropbox-sign/models/report_create_response.rb +2 -4
- data/lib/dropbox-sign/models/report_response.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_bulk_create_embedded_with_template_request.rb +5 -7
- data/lib/dropbox-sign/models/signature_request_bulk_send_with_template_request.rb +5 -7
- data/lib/dropbox-sign/models/signature_request_create_embedded_request.rb +5 -7
- data/lib/dropbox-sign/models/signature_request_create_embedded_with_template_request.rb +5 -7
- data/lib/dropbox-sign/models/signature_request_get_response.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_list_response.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_remind_request.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_attachment.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_custom_field_base.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_custom_field_checkbox.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_custom_field_text.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_custom_field_type_enum.rb +8 -4
- data/lib/dropbox-sign/models/signature_request_response_data_base.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_type_enum.rb +8 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_checkbox.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_checkbox_merge.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_date_signed.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_dropdown.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_initials.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_radio.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_signature.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_text.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_data_value_text_merge.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_response_signatures.rb +2 -4
- data/lib/dropbox-sign/models/signature_request_send_request.rb +5 -7
- data/lib/dropbox-sign/models/signature_request_send_with_template_request.rb +6 -7
- data/lib/dropbox-sign/models/signature_request_update_request.rb +2 -4
- data/lib/dropbox-sign/models/sub_attachment.rb +2 -4
- data/lib/dropbox-sign/models/sub_bulk_signer_list.rb +2 -4
- data/lib/dropbox-sign/models/sub_bulk_signer_list_custom_field.rb +2 -4
- data/lib/dropbox-sign/models/sub_cc.rb +2 -4
- data/lib/dropbox-sign/models/sub_custom_field.rb +2 -4
- data/lib/dropbox-sign/models/sub_editor_options.rb +2 -4
- data/lib/dropbox-sign/models/sub_field_options.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_field_group.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_field_rule.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_field_rule_action.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_field_rule_trigger.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_base.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_checkbox.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_checkbox_merge.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_date_signed.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_dropdown.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_font_enum.rb +8 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_hyperlink.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_initials.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_radio.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_signature.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_text.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_text_merge.rb +2 -4
- data/lib/dropbox-sign/models/sub_form_fields_per_document_type_enum.rb +8 -4
- data/lib/dropbox-sign/models/sub_merge_field.rb +2 -4
- data/lib/dropbox-sign/models/sub_o_auth.rb +2 -4
- data/lib/dropbox-sign/models/sub_options.rb +2 -4
- data/lib/dropbox-sign/models/sub_signature_request_grouped_signers.rb +2 -4
- data/lib/dropbox-sign/models/sub_signature_request_signer.rb +4 -6
- data/lib/dropbox-sign/models/sub_signature_request_template_signer.rb +4 -6
- data/lib/dropbox-sign/models/sub_signing_options.rb +2 -4
- data/lib/dropbox-sign/models/sub_team_response.rb +2 -4
- data/lib/dropbox-sign/models/sub_template_role.rb +2 -4
- data/lib/dropbox-sign/models/sub_unclaimed_draft_signer.rb +2 -4
- data/lib/dropbox-sign/models/sub_unclaimed_draft_template_signer.rb +2 -4
- data/lib/dropbox-sign/models/sub_white_labeling_options.rb +2 -4
- data/lib/dropbox-sign/models/team_add_member_request.rb +2 -4
- data/lib/dropbox-sign/models/team_create_request.rb +2 -4
- data/lib/dropbox-sign/models/team_get_info_response.rb +2 -4
- data/lib/dropbox-sign/models/team_get_response.rb +2 -4
- data/lib/dropbox-sign/models/team_info_response.rb +2 -4
- data/lib/dropbox-sign/models/team_invite_response.rb +2 -4
- data/lib/dropbox-sign/models/team_invites_response.rb +2 -4
- data/lib/dropbox-sign/models/team_member_response.rb +2 -4
- data/lib/dropbox-sign/models/team_members_response.rb +2 -4
- data/lib/dropbox-sign/models/team_parent_response.rb +2 -4
- data/lib/dropbox-sign/models/team_remove_member_request.rb +2 -4
- data/lib/dropbox-sign/models/team_response.rb +2 -4
- data/lib/dropbox-sign/models/team_sub_teams_response.rb +2 -4
- data/lib/dropbox-sign/models/team_update_request.rb +2 -4
- data/lib/dropbox-sign/models/template_add_user_request.rb +2 -4
- data/lib/dropbox-sign/models/template_create_embedded_draft_request.rb +4 -6
- data/lib/dropbox-sign/models/template_create_embedded_draft_response.rb +2 -4
- data/lib/dropbox-sign/models/template_create_embedded_draft_response_template.rb +2 -4
- data/lib/dropbox-sign/models/template_create_request.rb +4 -6
- data/lib/dropbox-sign/models/template_create_response.rb +2 -4
- data/lib/dropbox-sign/models/template_create_response_template.rb +2 -4
- data/lib/dropbox-sign/models/template_edit_response.rb +2 -4
- data/lib/dropbox-sign/models/template_get_response.rb +2 -4
- data/lib/dropbox-sign/models/template_list_response.rb +2 -4
- data/lib/dropbox-sign/models/template_remove_user_request.rb +2 -4
- data/lib/dropbox-sign/models/template_response.rb +2 -4
- data/lib/dropbox-sign/models/template_response_account.rb +2 -4
- data/lib/dropbox-sign/models/template_response_account_quota.rb +2 -4
- data/lib/dropbox-sign/models/template_response_cc_role.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_custom_field_base.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_custom_field_checkbox.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_custom_field_text.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_field_group.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_field_group_rule.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_base.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_checkbox.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_date_signed.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_dropdown.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_hyperlink.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_initials.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_radio.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_signature.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_form_field_text.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_base.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_checkbox.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_date_signed.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_dropdown.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_hyperlink.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_initials.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_radio.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_signature.rb +2 -4
- data/lib/dropbox-sign/models/template_response_document_static_field_text.rb +2 -4
- data/lib/dropbox-sign/models/template_response_field_avg_text_length.rb +2 -4
- data/lib/dropbox-sign/models/template_response_signer_role.rb +2 -4
- data/lib/dropbox-sign/models/template_update_files_request.rb +4 -6
- data/lib/dropbox-sign/models/template_update_files_response.rb +2 -4
- data/lib/dropbox-sign/models/template_update_files_response_template.rb +2 -4
- data/lib/dropbox-sign/models/unclaimed_draft_create_embedded_request.rb +5 -6
- data/lib/dropbox-sign/models/unclaimed_draft_create_embedded_with_template_request.rb +5 -7
- data/lib/dropbox-sign/models/unclaimed_draft_create_request.rb +5 -6
- data/lib/dropbox-sign/models/unclaimed_draft_create_response.rb +2 -4
- data/lib/dropbox-sign/models/unclaimed_draft_edit_and_resend_request.rb +2 -4
- data/lib/dropbox-sign/models/unclaimed_draft_response.rb +2 -4
- data/lib/dropbox-sign/models/warning_response.rb +2 -4
- data/lib/dropbox-sign/version.rb +2 -2
- data/lib/dropbox-sign.rb +2 -1
- data/openapi-config.yaml +1 -1
- data/openapi-sdk.yaml +84 -69
- data/run-build +1 -1
- data/spec/api_client_spec.rb +3 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/templates/README.mustache +1 -0
- data/templates/api.mustache +58 -12
- data/templates/api_client.mustache +16 -35
- data/templates/api_client_faraday_partial.mustache +102 -44
- data/templates/api_client_httpx_partial.mustache +134 -0
- data/templates/api_client_typhoeus_partial.mustache +23 -15
- data/templates/api_doc.mustache +1 -1
- data/templates/api_error.mustache +1 -0
- data/templates/api_info.mustache +1 -1
- data/templates/api_test.mustache +1 -1
- data/templates/base_object.mustache +1 -3
- data/templates/configuration.mustache +139 -33
- data/templates/configuration_faraday_partial.mustache +40 -0
- data/templates/configuration_httpx_partial.mustache +11 -0
- data/templates/configuration_typhoeus_partial.mustache +41 -0
- data/templates/gem.mustache +14 -0
- data/templates/gemspec.mustache +10 -4
- data/templates/model_test.mustache +3 -2
- data/templates/partial_model_enum_class.mustache +7 -4
- data/templates/partial_model_generic.mustache +7 -7
- data/templates/partial_oneof_module.mustache +4 -4
- data/templates/partial_oneof_module_doc.mustache +1 -0
- data/templates/travis.mustache +1 -4
- metadata +13 -7
data/templates/api.mustache
CHANGED
@@ -22,12 +22,30 @@ module {{moduleName}}
|
|
22
22
|
{{#notes}}
|
23
23
|
# {{{.}}}
|
24
24
|
{{/notes}}
|
25
|
-
{{#
|
26
|
-
|
27
|
-
{{#allParams}}
|
28
|
-
{{
|
29
|
-
|
30
|
-
|
25
|
+
{{#vendorExtensions.x-group-parameters}}
|
26
|
+
# @param [Hash] opts the parameters
|
27
|
+
{{#allParams}}
|
28
|
+
{{#required}}
|
29
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}} (required)
|
30
|
+
{{/required}}
|
31
|
+
{{/allParams}}
|
32
|
+
{{/vendorExtensions.x-group-parameters}}
|
33
|
+
{{^vendorExtensions.x-group-parameters}}
|
34
|
+
{{#allParams}}
|
35
|
+
{{#required}}
|
36
|
+
# @param {{paramName}} [{{{dataType}}}] {{description}}
|
37
|
+
{{/required}}
|
38
|
+
{{/allParams}}
|
39
|
+
# @param [Hash] opts the optional parameters
|
40
|
+
{{/vendorExtensions.x-group-parameters}}
|
41
|
+
{{#allParams}}
|
42
|
+
{{^required}}
|
43
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
44
|
+
{{/required}}
|
45
|
+
{{/allParams}}
|
46
|
+
# @return [{{{returnType}}}{{^returnType}}nil{{/returnType}}]
|
47
|
+
def {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}opts = {})
|
48
|
+
{{#returnType}}data, _status_code, _headers = {{/returnType}}{{operationId}}_with_http_info({{^vendorExtensions.x-group-parameters}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}opts)
|
31
49
|
{{#returnType}}data{{/returnType}}{{^returnType}}nil{{/returnType}}
|
32
50
|
end
|
33
51
|
|
@@ -37,14 +55,42 @@ module {{moduleName}}
|
|
37
55
|
{{#notes}}
|
38
56
|
# {{.}}
|
39
57
|
{{/notes}}
|
40
|
-
{{#
|
41
|
-
|
42
|
-
{{#allParams}}
|
43
|
-
{{
|
44
|
-
|
58
|
+
{{#vendorExtensions.x-group-parameters}}
|
59
|
+
# @param [Hash] opts the parameters
|
60
|
+
{{#allParams}}
|
61
|
+
{{#required}}
|
62
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}} (required)
|
63
|
+
{{/required}}
|
64
|
+
{{/allParams}}
|
65
|
+
{{/vendorExtensions.x-group-parameters}}
|
66
|
+
{{^vendorExtensions.x-group-parameters}}
|
67
|
+
{{#allParams}}
|
68
|
+
{{#required}}
|
69
|
+
# @param {{paramName}} [{{{dataType}}}] {{description}}
|
70
|
+
{{/required}}
|
71
|
+
{{/allParams}}
|
72
|
+
# @param [Hash] opts the optional parameters
|
73
|
+
{{/vendorExtensions.x-group-parameters}}
|
74
|
+
{{#allParams}}
|
75
|
+
{{^required}}
|
76
|
+
# @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
77
|
+
{{/required}}
|
78
|
+
{{/allParams}}
|
79
|
+
# @return [Array<({{{returnType}}}{{^returnType}}nil{{/returnType}}, Integer, Hash)>] {{#returnType}}{{{.}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers
|
80
|
+
def {{operationId}}_with_http_info({{^vendorExtensions.x-group-parameters}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}opts = {})
|
45
81
|
if @api_client.config.debugging
|
46
82
|
@api_client.config.logger.debug 'Calling API: {{classname}}.{{operationId}} ...'
|
47
83
|
end
|
84
|
+
{{#vendorExtensions.x-group-parameters}}
|
85
|
+
# unbox the parameters from the hash
|
86
|
+
{{#allParams}}
|
87
|
+
{{^isNullable}}
|
88
|
+
{{#required}}
|
89
|
+
{{{paramName}}} = opts[:'{{{paramName}}}']
|
90
|
+
{{/required}}
|
91
|
+
{{/isNullable}}
|
92
|
+
{{/allParams}}
|
93
|
+
{{/vendorExtensions.x-group-parameters}}
|
48
94
|
{{#allParams}}
|
49
95
|
{{^isNullable}}
|
50
96
|
{{#required}}
|
@@ -161,7 +207,7 @@ module {{moduleName}}
|
|
161
207
|
{{/headerParams}}
|
162
208
|
{{#headerParams}}
|
163
209
|
{{^required}}
|
164
|
-
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
210
|
+
header_params[{{#lambdaFixHeaderKey}}:'{{{baseName}}}'{{/lambdaFixHeaderKey}}] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
165
211
|
{{/required}}
|
166
212
|
{{/headerParams}}
|
167
213
|
|
@@ -7,12 +7,18 @@ require 'json'
|
|
7
7
|
require 'logger'
|
8
8
|
require 'tempfile'
|
9
9
|
require 'time'
|
10
|
-
{{
|
10
|
+
{{#isTyphoeus}}
|
11
11
|
require 'typhoeus'
|
12
|
-
{{/
|
12
|
+
{{/isTyphoeus}}
|
13
13
|
{{#isFaraday}}
|
14
14
|
require 'faraday'
|
15
|
+
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
16
|
+
require 'marcel'
|
15
17
|
{{/isFaraday}}
|
18
|
+
{{#isHttpx}}
|
19
|
+
require 'httpx'
|
20
|
+
require 'net/http/status'
|
21
|
+
{{/isHttpx}}
|
16
22
|
|
17
23
|
module Dropbox
|
18
24
|
end
|
@@ -42,12 +48,15 @@ module {{moduleName}}
|
|
42
48
|
@@default ||= ApiClient.new
|
43
49
|
end
|
44
50
|
|
45
|
-
{{
|
51
|
+
{{#isTyphoeus}}
|
46
52
|
{{> api_client_typhoeus_partial}}
|
47
|
-
{{/
|
53
|
+
{{/isTyphoeus}}
|
48
54
|
{{#isFaraday}}
|
49
55
|
{{> api_client_faraday_partial}}
|
50
56
|
{{/isFaraday}}
|
57
|
+
{{#isHttpx}}
|
58
|
+
{{> api_client_httpx_partial}}
|
59
|
+
{{/isHttpx}}
|
51
60
|
# Check if the given MIME is a JSON MIME.
|
52
61
|
# JSON MIME examples:
|
53
62
|
# application/json
|
@@ -57,7 +66,7 @@ module {{moduleName}}
|
|
57
66
|
# @param [String] mime MIME
|
58
67
|
# @return [Boolean] True if the MIME is application/json
|
59
68
|
def json_mime?(mime)
|
60
|
-
(mime == '*/*') || !(mime =~
|
69
|
+
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
|
61
70
|
end
|
62
71
|
|
63
72
|
# Deserialize the response to the given return type.
|
@@ -66,38 +75,10 @@ module {{moduleName}}
|
|
66
75
|
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
67
76
|
def deserialize(response, return_type)
|
68
77
|
body = response.body
|
69
|
-
|
70
|
-
# handle file downloading - return the File instance processed in request callbacks
|
71
|
-
# note that response body is empty when the file is written in chunks in request on_body callback
|
72
|
-
{{^isFaraday}}
|
73
|
-
return @tempfile if return_type == 'File'
|
74
|
-
{{/isFaraday}}
|
75
|
-
{{#isFaraday}}
|
76
|
-
if return_type == 'File'
|
77
|
-
content_disposition = response.headers['Content-Disposition']
|
78
|
-
if content_disposition && content_disposition =~ /filename=/i
|
79
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
80
|
-
prefix = sanitize_filename(filename)
|
81
|
-
else
|
82
|
-
prefix = 'download-'
|
83
|
-
end
|
84
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
85
|
-
encoding = body.encoding
|
86
|
-
@tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
87
|
-
@tempfile.write(@stream.join.force_encoding(encoding))
|
88
|
-
@tempfile.close
|
89
|
-
@config.logger.info "Temp file written to #{@tempfile.path}, please copy the file to a proper folder "\
|
90
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
91
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
92
|
-
"explicitly with `tempfile.delete`"
|
93
|
-
return @tempfile
|
94
|
-
end
|
95
|
-
{{/isFaraday}}
|
96
|
-
|
97
78
|
return nil if body.nil? || body.empty?
|
98
79
|
|
99
80
|
# return response body directly for String return type
|
100
|
-
return body if return_type == 'String'
|
81
|
+
return body.to_s if return_type == 'String'
|
101
82
|
|
102
83
|
# ensuring a default content type
|
103
84
|
content_type = response.headers['Content-Type'] || 'application/json'
|
@@ -164,7 +145,7 @@ module {{moduleName}}
|
|
164
145
|
# @param [String] filename the filename to be sanitized
|
165
146
|
# @return [String] the sanitized filename
|
166
147
|
def sanitize_filename(filename)
|
167
|
-
filename.
|
148
|
+
filename.split(/[\/\\]/).last
|
168
149
|
end
|
169
150
|
|
170
151
|
def build_request_url(path, opts = {})
|
@@ -3,50 +3,38 @@
|
|
3
3
|
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
4
4
|
# the data deserialized from response body (could be nil), response status code and response headers.
|
5
5
|
def call_api(http_method, path, opts = {})
|
6
|
-
|
7
|
-
:ca_file => @config.ssl_ca_file,
|
8
|
-
:verify => @config.ssl_verify,
|
9
|
-
:verify_mode => @config.ssl_verify_mode,
|
10
|
-
:client_cert => @config.ssl_client_cert,
|
11
|
-
:client_key => @config.ssl_client_key
|
12
|
-
}
|
13
|
-
|
14
|
-
connection = Faraday.new(:url => config.base_url, :ssl => ssl_options) do |conn|
|
15
|
-
conn.request(:basic_auth, config.username, config.password)
|
16
|
-
@config.configure_middleware(conn)
|
17
|
-
if opts[:header_params]["Content-Type"] == "multipart/form-data"
|
18
|
-
conn.request :multipart
|
19
|
-
conn.request :url_encoded
|
20
|
-
end
|
21
|
-
conn.adapter(Faraday.default_adapter)
|
22
|
-
end
|
23
|
-
|
6
|
+
stream = nil
|
24
7
|
begin
|
25
|
-
response = connection.public_send(http_method.to_sym.downcase) do |req|
|
26
|
-
build_request(http_method, path, req, opts)
|
8
|
+
response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
|
9
|
+
request = build_request(http_method, path, req, opts)
|
10
|
+
stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
27
11
|
end
|
28
12
|
|
29
|
-
if
|
30
|
-
|
13
|
+
if config.debugging
|
14
|
+
config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
31
15
|
end
|
32
16
|
|
33
17
|
unless response.success?
|
34
|
-
if response.status == 0
|
18
|
+
if response.status == 0 && response.respond_to?(:return_message)
|
35
19
|
# Errors from libcurl will be made visible here
|
36
|
-
fail ApiError.new(:
|
37
|
-
:
|
20
|
+
fail ApiError.new(code: 0,
|
21
|
+
message: response.return_message)
|
38
22
|
else
|
39
|
-
fail ApiError.new(:
|
40
|
-
:
|
41
|
-
:
|
23
|
+
fail ApiError.new(code: response.status,
|
24
|
+
response_headers: response.headers,
|
25
|
+
response_body: response.body),
|
42
26
|
response.reason_phrase
|
43
27
|
end
|
44
28
|
end
|
45
29
|
rescue Faraday::TimeoutError
|
46
30
|
fail ApiError.new('Connection timed out')
|
31
|
+
rescue Faraday::ConnectionFailed
|
32
|
+
fail ApiError.new('Connection failed')
|
47
33
|
end
|
48
34
|
|
49
|
-
if opts[:return_type]
|
35
|
+
if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
36
|
+
data = deserialize_file(response, stream)
|
37
|
+
elsif opts[:return_type]
|
50
38
|
data = deserialize(response, opts[:return_type])
|
51
39
|
else
|
52
40
|
data = nil
|
@@ -62,7 +50,7 @@
|
|
62
50
|
# @option opts [Hash] :query_params Query parameters
|
63
51
|
# @option opts [Hash] :form_params Query parameters
|
64
52
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
65
|
-
# @return [
|
53
|
+
# @return [Faraday::Request] A Faraday Request
|
66
54
|
def build_request(http_method, path, request, opts = {})
|
67
55
|
url = build_request_url(path, opts)
|
68
56
|
http_method = http_method.to_sym.downcase
|
@@ -73,24 +61,21 @@
|
|
73
61
|
|
74
62
|
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
75
63
|
|
76
|
-
req_opts = {
|
77
|
-
:params_encoding => @config.params_encoding,
|
78
|
-
:timeout => @config.timeout,
|
79
|
-
:verbose => @config.debugging
|
80
|
-
}
|
81
|
-
|
82
64
|
if [:post, :patch, :put, :delete].include?(http_method)
|
83
65
|
req_body = build_request_body(header_params, form_params, opts[:body])
|
84
|
-
if
|
85
|
-
|
66
|
+
if config.debugging
|
67
|
+
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
86
68
|
end
|
87
69
|
end
|
88
70
|
request.headers = header_params
|
89
71
|
request.body = req_body
|
90
|
-
|
72
|
+
|
73
|
+
# Overload default options only if provided
|
74
|
+
request.options.params_encoder = config.params_encoder if config.params_encoder
|
75
|
+
request.options.timeout = config.timeout if config.timeout
|
76
|
+
|
91
77
|
request.url url
|
92
78
|
request.params = query_params
|
93
|
-
download_file(request) if opts[:return_type] == 'File'
|
94
79
|
request
|
95
80
|
end
|
96
81
|
|
@@ -109,8 +94,7 @@
|
|
109
94
|
form_params.each do |key, value|
|
110
95
|
case value
|
111
96
|
when ::File, ::Tempfile
|
112
|
-
|
113
|
-
data[key] = Faraday::UploadIO.new(value.path, 'application/octet-stream', value.path)
|
97
|
+
data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
|
114
98
|
when ::Array, nil
|
115
99
|
# let Faraday handle Array and nil parameters
|
116
100
|
data[key] = value
|
@@ -127,10 +111,84 @@
|
|
127
111
|
end
|
128
112
|
|
129
113
|
def download_file(request)
|
130
|
-
|
114
|
+
stream = []
|
131
115
|
|
132
116
|
# handle streaming Responses
|
133
117
|
request.options.on_data = Proc.new do |chunk, overall_received_bytes|
|
134
|
-
|
118
|
+
stream << chunk
|
119
|
+
end
|
120
|
+
stream
|
121
|
+
end
|
122
|
+
|
123
|
+
def deserialize_file(response, stream)
|
124
|
+
body = response.body
|
125
|
+
if @config.return_binary_data == true
|
126
|
+
# return byte stream
|
127
|
+
encoding = body.encoding
|
128
|
+
stream.join.force_encoding(encoding)
|
129
|
+
else
|
130
|
+
# return file instead of binary data
|
131
|
+
content_disposition = response.headers['Content-Disposition']
|
132
|
+
if content_disposition && content_disposition =~ /filename=/i
|
133
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
134
|
+
prefix = sanitize_filename(filename)
|
135
|
+
else
|
136
|
+
prefix = 'download-'
|
137
|
+
end
|
138
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
139
|
+
encoding = body.encoding
|
140
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
141
|
+
tempfile.write(stream.join.force_encoding(encoding))
|
142
|
+
tempfile.close
|
143
|
+
config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
144
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
145
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
146
|
+
"explicitly with `tempfile.delete`"
|
147
|
+
tempfile
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def connection(opts)
|
152
|
+
opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
|
153
|
+
end
|
154
|
+
|
155
|
+
def connection_multipart
|
156
|
+
@connection_multipart ||= build_connection do |conn|
|
157
|
+
conn.request :multipart
|
158
|
+
conn.request :url_encoded
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def connection_regular
|
163
|
+
@connection_regular ||= build_connection
|
164
|
+
end
|
165
|
+
|
166
|
+
def build_connection
|
167
|
+
Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn|
|
168
|
+
basic_auth(conn)
|
169
|
+
config.configure_middleware(conn)
|
170
|
+
yield(conn) if block_given?
|
171
|
+
conn.adapter(Faraday.default_adapter)
|
172
|
+
config.configure_connection(conn)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def ssl_options
|
177
|
+
{
|
178
|
+
ca_file: config.ssl_ca_file,
|
179
|
+
verify: config.ssl_verify,
|
180
|
+
verify_mode: config.ssl_verify_mode,
|
181
|
+
client_cert: config.ssl_client_cert,
|
182
|
+
client_key: config.ssl_client_key
|
183
|
+
}
|
184
|
+
end
|
185
|
+
|
186
|
+
def basic_auth(conn)
|
187
|
+
if config.username && config.password
|
188
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
189
|
+
conn.request(:authorization, :basic, config.username, config.password)
|
190
|
+
else
|
191
|
+
conn.request(:basic_auth, config.username, config.password)
|
192
|
+
end
|
135
193
|
end
|
136
194
|
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# Call an API with given options.
|
2
|
+
#
|
3
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
4
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
5
|
+
def call_api(http_method, path, opts = {})
|
6
|
+
begin
|
7
|
+
response = build_request(http_method.to_s, path, opts)
|
8
|
+
|
9
|
+
if config.debugging
|
10
|
+
config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
response.raise_for_status
|
14
|
+
|
15
|
+
rescue HTTPX::HTTPError
|
16
|
+
fail ApiError.new(code: response.status,
|
17
|
+
response_headers: response.headers.to_h,
|
18
|
+
response_body: response.body.to_s),
|
19
|
+
Net::HTTP::STATUS_CODES.fetch(response.status, "HTTP Error (#{response.status})")
|
20
|
+
rescue HTTPX::TimeoutError
|
21
|
+
fail ApiError.new('Connection timed out')
|
22
|
+
rescue HTTPX::ConnectionError, HTTPX::ResolveError
|
23
|
+
fail ApiError.new('Connection failed')
|
24
|
+
end
|
25
|
+
|
26
|
+
if opts[:return_type] == 'File'
|
27
|
+
data = deserialize_file(response)
|
28
|
+
elsif opts[:return_type]
|
29
|
+
data = deserialize(response, opts[:return_type])
|
30
|
+
else
|
31
|
+
data = nil
|
32
|
+
end
|
33
|
+
return data, response.status, response.headers.to_h
|
34
|
+
end
|
35
|
+
|
36
|
+
# Builds the HTTP request
|
37
|
+
#
|
38
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
39
|
+
# @param [String] path URL path (e.g. /account/new)
|
40
|
+
# @option opts [Hash] :header_params Header parameters
|
41
|
+
# @option opts [Hash] :query_params Query parameters
|
42
|
+
# @option opts [Hash] :form_params Query parameters
|
43
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
44
|
+
# @return [HTTPX::Request] A Request object
|
45
|
+
def build_request(http_method, path, opts = {})
|
46
|
+
url = build_request_url(path, opts)
|
47
|
+
|
48
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
49
|
+
query_params = opts[:query_params] || {}
|
50
|
+
form_params = opts[:form_params] || {}
|
51
|
+
|
52
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
53
|
+
|
54
|
+
if %w[POST PATCH PUT DELETE].include?(http_method)
|
55
|
+
body_params = build_request_body(header_params, form_params, opts[:body])
|
56
|
+
if config.debugging
|
57
|
+
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
req_opts = {
|
61
|
+
:headers => HTTPX::Headers.new(header_params)
|
62
|
+
}
|
63
|
+
req_opts.merge!(body_params) if body_params
|
64
|
+
req_opts[:params] = query_params if query_params && !query_params.empty?
|
65
|
+
session.request(http_method, url, **req_opts)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Builds the HTTP request body
|
69
|
+
#
|
70
|
+
# @param [Hash] header_params Header parameters
|
71
|
+
# @param [Hash] form_params Query parameters
|
72
|
+
# @param [Object] body HTTP body (JSON/XML)
|
73
|
+
# @return [Hash{Symbol => Object}] body options as HTTPX handles them
|
74
|
+
def build_request_body(header_params, form_params, body)
|
75
|
+
# http form
|
76
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
77
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
78
|
+
header_params.delete('Content-Type') # httpx takes care of this
|
79
|
+
{ form: form_params }
|
80
|
+
elsif body
|
81
|
+
body.is_a?(String) ? { body: body } : { json: body }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def deserialize_file(response)
|
86
|
+
body = response.body
|
87
|
+
if @config.return_binary_data == true
|
88
|
+
# TODO: force response encoding
|
89
|
+
body.to_s
|
90
|
+
else
|
91
|
+
content_disposition = response.headers['content-disposition']
|
92
|
+
if content_disposition && content_disposition =~ /filename=/i
|
93
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
94
|
+
prefix = sanitize_filename(filename)
|
95
|
+
else
|
96
|
+
prefix = 'download-'
|
97
|
+
end
|
98
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
99
|
+
encoding = response.body.encoding
|
100
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
101
|
+
response.copy_to(tempfile)
|
102
|
+
tempfile.close
|
103
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
104
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
105
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
106
|
+
"explicitly with `tempfile.delete`"
|
107
|
+
|
108
|
+
tempfile
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def session
|
113
|
+
return @session if defined?(@session)
|
114
|
+
|
115
|
+
session = HTTPX.with(
|
116
|
+
ssl: @config.ssl,
|
117
|
+
timeout: ({ request_timeout: @config.timeout } if @config.timeout && @config.timeout.positive?),
|
118
|
+
origin: "#{@config.scheme}://#{@config.host}",
|
119
|
+
base_path: (@config.base_path.sub(/\/+\z/, '') if @config.base_path)
|
120
|
+
)
|
121
|
+
|
122
|
+
if @config.proxy
|
123
|
+
session = session.plugin(:proxy, proxy: @config.proxy)
|
124
|
+
end
|
125
|
+
|
126
|
+
if @config.username && @config.password
|
127
|
+
session = session.plugin(:basic_auth).basic_auth(@config.username, @config.password)
|
128
|
+
end
|
129
|
+
|
130
|
+
session = @config.configure(session)
|
131
|
+
|
132
|
+
@session = session
|
133
|
+
|
134
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# Call an API with given options.
|
2
2
|
#
|
3
3
|
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
4
|
-
# the data deserialized from response body (
|
4
|
+
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
|
5
5
|
def call_api(http_method, path, opts = {})
|
6
6
|
request = build_request(http_method, path, opts)
|
7
|
+
tempfile = download_file(request) if opts[:return_type] == 'File'
|
7
8
|
response = request.run
|
8
9
|
|
9
10
|
if @config.debugging
|
@@ -25,7 +26,9 @@
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
if opts[:return_type]
|
29
|
+
if opts[:return_type] == 'File'
|
30
|
+
data = tempfile
|
31
|
+
elsif opts[:return_type]
|
29
32
|
data = deserialize(response, opts[:return_type])
|
30
33
|
else
|
31
34
|
data = nil
|
@@ -49,6 +52,7 @@
|
|
49
52
|
header_params = @default_headers.merge(opts[:header_params] || {})
|
50
53
|
query_params = opts[:query_params] || {}
|
51
54
|
form_params = opts[:form_params] || {}
|
55
|
+
follow_location = opts[:follow_location] || true
|
52
56
|
|
53
57
|
{{#hasAuthMethods}}
|
54
58
|
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
@@ -67,7 +71,8 @@
|
|
67
71
|
:ssl_verifyhost => _verify_ssl_host,
|
68
72
|
:sslcert => @config.cert_file,
|
69
73
|
:sslkey => @config.key_file,
|
70
|
-
:verbose => @config.debugging
|
74
|
+
:verbose => @config.debugging,
|
75
|
+
:followlocation => follow_location
|
71
76
|
}
|
72
77
|
|
73
78
|
# set custom cert, if provided
|
@@ -81,9 +86,7 @@
|
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
84
|
-
|
85
|
-
download_file(request) if opts[:return_type] == 'File'
|
86
|
-
request
|
89
|
+
Typhoeus::Request.new(url, req_opts)
|
87
90
|
end
|
88
91
|
|
89
92
|
# Builds the HTTP request body
|
@@ -121,6 +124,8 @@
|
|
121
124
|
# process can use.
|
122
125
|
#
|
123
126
|
# @see Configuration#temp_folder_path
|
127
|
+
#
|
128
|
+
# @return [Tempfile] the tempfile generated
|
124
129
|
def download_file(request)
|
125
130
|
tempfile = nil
|
126
131
|
encoding = nil
|
@@ -135,19 +140,22 @@
|
|
135
140
|
prefix = prefix + '-' unless prefix.end_with?('-')
|
136
141
|
encoding = response.body.encoding
|
137
142
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
138
|
-
@tempfile = tempfile
|
139
143
|
end
|
140
144
|
request.on_body do |chunk|
|
141
145
|
chunk.force_encoding(encoding)
|
142
146
|
tempfile.write(chunk)
|
143
147
|
end
|
144
|
-
request
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
# run the request to ensure the tempfile is created successfully before returning it
|
149
|
+
request.run
|
150
|
+
if tempfile
|
151
|
+
tempfile.close
|
152
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
153
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
154
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
155
|
+
"explicitly with `tempfile.delete`"
|
156
|
+
else
|
157
|
+
fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
|
152
158
|
end
|
159
|
+
|
160
|
+
tempfile
|
153
161
|
end
|
data/templates/api_doc.mustache
CHANGED
@@ -38,7 +38,7 @@ This returns an Array which contains the response data{{^returnType}} (`nil` in
|
|
38
38
|
```ruby
|
39
39
|
begin
|
40
40
|
{{#summary}}# {{{.}}}{{/summary}}
|
41
|
-
data, status_code, headers = api_instance.{{{operationId}}}_with_http_info{{#hasParams}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}){{/hasParams}}
|
41
|
+
data, status_code, headers = api_instance.{{{operationId}}}_with_http_info{{#hasParams}}({{^vendorExtensions.x-group-parameters}}{{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}opts{{/vendorExtensions.x-group-parameters}}){{/hasParams}}
|
42
42
|
p status_code # => 2xx
|
43
43
|
p headers # => { ... }
|
44
44
|
p data # => {{#returnType}}{{#returnTypeIsPrimitive}}{{returnType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}<{{{returnType}}}>{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil{{/returnType}}
|
data/templates/api_info.mustache
CHANGED
data/templates/api_test.mustache
CHANGED
@@ -38,7 +38,7 @@ require 'json'
|
|
38
38
|
{{/required}}{{/allParams}} # @return [{{{returnType}}}{{^returnType}}nil{{/returnType}}]
|
39
39
|
describe '{{operationId}} test' do
|
40
40
|
it 'should work' do
|
41
|
-
# assertion here. ref: https://
|
41
|
+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -61,8 +61,6 @@
|
|
61
61
|
else
|
62
62
|
false
|
63
63
|
end
|
64
|
-
when :File
|
65
|
-
value
|
66
64
|
when :Object
|
67
65
|
# generic object (usually a Hash), return directly
|
68
66
|
value
|
@@ -80,7 +78,7 @@
|
|
80
78
|
else # model
|
81
79
|
# models (e.g. Pet)
|
82
80
|
klass = {{moduleName}}.const_get(type)
|
83
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
81
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
84
82
|
end
|
85
83
|
end
|
86
84
|
|