bandwidth-sdk 17.0.1 → 17.1.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.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +18 -0
  4. data/bandwidth-sdk.gemspec +1 -2
  5. data/bandwidth.yml +7 -0
  6. data/coverage/.last_run.json +1 -1
  7. data/coverage/.resultset.json +198 -387
  8. data/coverage/index.html +5842 -7703
  9. data/custom_templates/README.mustache +4 -1
  10. data/custom_templates/api_client.mustache +254 -0
  11. data/custom_templates/configuration.mustache +545 -0
  12. data/custom_templates/gem.mustache +2 -0
  13. data/docs/CallsApi.md +20 -5
  14. data/docs/ConferencesApi.md +36 -9
  15. data/docs/MFAApi.md +12 -3
  16. data/docs/MediaApi.md +16 -4
  17. data/docs/MessagesApi.md +8 -2
  18. data/docs/MultiChannelApi.md +4 -1
  19. data/docs/PhoneNumberLookupApi.md +12 -3
  20. data/docs/RecordingsApi.md +40 -10
  21. data/docs/StatisticsApi.md +4 -1
  22. data/docs/TollFreeVerificationApi.md +36 -9
  23. data/docs/TranscriptionsApi.md +12 -3
  24. data/lib/bandwidth-sdk/api/calls_api.rb +6 -6
  25. data/lib/bandwidth-sdk/api/conferences_api.rb +10 -10
  26. data/lib/bandwidth-sdk/api/media_api.rb +5 -5
  27. data/lib/bandwidth-sdk/api/messages_api.rb +3 -3
  28. data/lib/bandwidth-sdk/api/mfa_api.rb +4 -4
  29. data/lib/bandwidth-sdk/api/multi_channel_api.rb +2 -2
  30. data/lib/bandwidth-sdk/api/phone_number_lookup_api.rb +4 -4
  31. data/lib/bandwidth-sdk/api/recordings_api.rb +11 -11
  32. data/lib/bandwidth-sdk/api/statistics_api.rb +2 -2
  33. data/lib/bandwidth-sdk/api/toll_free_verification_api.rb +13 -13
  34. data/lib/bandwidth-sdk/api/transcriptions_api.rb +4 -4
  35. data/lib/bandwidth-sdk/api_client.rb +9 -5
  36. data/lib/bandwidth-sdk/api_error.rb +1 -1
  37. data/lib/bandwidth-sdk/api_model_base.rb +88 -0
  38. data/lib/bandwidth-sdk/configuration.rb +50 -1
  39. data/lib/bandwidth-sdk/models/account_statistics.rb +11 -78
  40. data/lib/bandwidth-sdk/models/additional_denial_reason.rb +41 -78
  41. data/lib/bandwidth-sdk/models/address.rb +23 -90
  42. data/lib/bandwidth-sdk/models/answer_callback.rb +11 -78
  43. data/lib/bandwidth-sdk/models/async_lookup_request.rb +11 -78
  44. data/lib/bandwidth-sdk/models/blocked_webhook.rb +13 -80
  45. data/lib/bandwidth-sdk/models/bridge_complete_callback.rb +11 -78
  46. data/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb +11 -78
  47. data/lib/bandwidth-sdk/models/business_entity_type_enum.rb +1 -1
  48. data/lib/bandwidth-sdk/models/business_registration_type_enum.rb +1 -1
  49. data/lib/bandwidth-sdk/models/call_direction_enum.rb +1 -1
  50. data/lib/bandwidth-sdk/models/call_recording_metadata.rb +11 -78
  51. data/lib/bandwidth-sdk/models/call_state.rb +11 -78
  52. data/lib/bandwidth-sdk/models/call_state_enum.rb +1 -1
  53. data/lib/bandwidth-sdk/models/call_transcription.rb +11 -78
  54. data/lib/bandwidth-sdk/models/call_transcription_detected_language_enum.rb +1 -1
  55. data/lib/bandwidth-sdk/models/call_transcription_metadata.rb +11 -78
  56. data/lib/bandwidth-sdk/models/call_transcription_response.rb +11 -78
  57. data/lib/bandwidth-sdk/models/call_transcription_track_enum.rb +1 -1
  58. data/lib/bandwidth-sdk/models/callback.rb +1 -1
  59. data/lib/bandwidth-sdk/models/callback_method_enum.rb +1 -1
  60. data/lib/bandwidth-sdk/models/card_width_enum.rb +1 -1
  61. data/lib/bandwidth-sdk/models/code_request.rb +11 -78
  62. data/lib/bandwidth-sdk/models/completed_lookup_status_enum.rb +1 -1
  63. data/lib/bandwidth-sdk/models/conference.rb +11 -78
  64. data/lib/bandwidth-sdk/models/conference_completed_callback.rb +11 -78
  65. data/lib/bandwidth-sdk/models/conference_created_callback.rb +11 -78
  66. data/lib/bandwidth-sdk/models/conference_member.rb +11 -78
  67. data/lib/bandwidth-sdk/models/conference_member_exit_callback.rb +11 -78
  68. data/lib/bandwidth-sdk/models/conference_member_join_callback.rb +11 -78
  69. data/lib/bandwidth-sdk/models/conference_recording_available_callback.rb +11 -78
  70. data/lib/bandwidth-sdk/models/conference_recording_metadata.rb +11 -78
  71. data/lib/bandwidth-sdk/models/conference_redirect_callback.rb +11 -78
  72. data/lib/bandwidth-sdk/models/conference_state_enum.rb +1 -1
  73. data/lib/bandwidth-sdk/models/contact.rb +19 -86
  74. data/lib/bandwidth-sdk/models/create_async_bulk_lookup_response.rb +11 -78
  75. data/lib/bandwidth-sdk/models/create_async_bulk_lookup_response_data.rb +11 -78
  76. data/lib/bandwidth-sdk/models/create_call.rb +41 -78
  77. data/lib/bandwidth-sdk/models/create_call_response.rb +81 -78
  78. data/lib/bandwidth-sdk/models/create_message_request_error.rb +31 -78
  79. data/lib/bandwidth-sdk/models/create_multi_channel_message_response.rb +11 -78
  80. data/lib/bandwidth-sdk/models/create_sync_lookup_response.rb +11 -78
  81. data/lib/bandwidth-sdk/models/create_sync_lookup_response_data.rb +11 -78
  82. data/lib/bandwidth-sdk/models/deactivation_event_enum.rb +1 -1
  83. data/lib/bandwidth-sdk/models/disconnect_callback.rb +11 -78
  84. data/lib/bandwidth-sdk/models/diversion.rb +11 -78
  85. data/lib/bandwidth-sdk/models/dtmf_callback.rb +11 -78
  86. data/lib/bandwidth-sdk/models/error.rb +11 -78
  87. data/lib/bandwidth-sdk/models/error_object.rb +41 -78
  88. data/lib/bandwidth-sdk/models/error_source.rb +11 -78
  89. data/lib/bandwidth-sdk/models/failure_webhook.rb +13 -80
  90. data/lib/bandwidth-sdk/models/field_error.rb +11 -78
  91. data/lib/bandwidth-sdk/models/file_format_enum.rb +1 -1
  92. data/lib/bandwidth-sdk/models/gather_callback.rb +11 -78
  93. data/lib/bandwidth-sdk/models/get_async_bulk_lookup_response.rb +11 -78
  94. data/lib/bandwidth-sdk/models/get_async_bulk_lookup_response_data.rb +11 -78
  95. data/lib/bandwidth-sdk/models/in_progress_lookup_status_enum.rb +1 -1
  96. data/lib/bandwidth-sdk/models/inbound_callback.rb +61 -78
  97. data/lib/bandwidth-sdk/models/inbound_callback_message.rb +81 -78
  98. data/lib/bandwidth-sdk/models/inbound_callback_type_enum.rb +1 -1
  99. data/lib/bandwidth-sdk/models/initiate_callback.rb +11 -78
  100. data/lib/bandwidth-sdk/models/latest_message_delivery_status_enum.rb +1 -1
  101. data/lib/bandwidth-sdk/models/line_type_enum.rb +1 -1
  102. data/lib/bandwidth-sdk/models/link.rb +11 -78
  103. data/lib/bandwidth-sdk/models/link_schema.rb +11 -78
  104. data/lib/bandwidth-sdk/models/links_object.rb +11 -78
  105. data/lib/bandwidth-sdk/models/list_message_direction_enum.rb +1 -1
  106. data/lib/bandwidth-sdk/models/list_message_item.rb +11 -78
  107. data/lib/bandwidth-sdk/models/lookup_error_response.rb +11 -78
  108. data/lib/bandwidth-sdk/models/lookup_error_schema.rb +11 -78
  109. data/lib/bandwidth-sdk/models/lookup_error_schema_meta.rb +11 -78
  110. data/lib/bandwidth-sdk/models/lookup_result.rb +11 -78
  111. data/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb +11 -78
  112. data/lib/bandwidth-sdk/models/machine_detection_configuration.rb +11 -78
  113. data/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb +1 -1
  114. data/lib/bandwidth-sdk/models/machine_detection_result.rb +11 -78
  115. data/lib/bandwidth-sdk/models/media.rb +11 -78
  116. data/lib/bandwidth-sdk/models/message.rb +11 -78
  117. data/lib/bandwidth-sdk/models/message_direction_enum.rb +1 -1
  118. data/lib/bandwidth-sdk/models/message_request.rb +31 -78
  119. data/lib/bandwidth-sdk/models/message_status_enum.rb +1 -1
  120. data/lib/bandwidth-sdk/models/message_type_enum.rb +1 -1
  121. data/lib/bandwidth-sdk/models/messages_list.rb +11 -78
  122. data/lib/bandwidth-sdk/models/messaging_code_response.rb +11 -78
  123. data/lib/bandwidth-sdk/models/messaging_request_error.rb +31 -78
  124. data/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb +11 -78
  125. data/lib/bandwidth-sdk/models/mfa_request_error.rb +11 -78
  126. data/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb +11 -78
  127. data/lib/bandwidth-sdk/models/mms_message_content.rb +11 -78
  128. data/lib/bandwidth-sdk/models/mms_message_content_file.rb +11 -78
  129. data/lib/bandwidth-sdk/models/multi_channel_action.rb +3 -4
  130. data/lib/bandwidth-sdk/models/multi_channel_action_calendar_event.rb +41 -78
  131. data/lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb +51 -78
  132. data/lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb +61 -78
  133. data/lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb +41 -78
  134. data/lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb +21 -78
  135. data/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb +51 -78
  136. data/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb +3 -4
  137. data/lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb +61 -78
  138. data/lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb +3 -4
  139. data/lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb +3 -4
  140. data/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb +51 -78
  141. data/lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb +61 -78
  142. data/lib/bandwidth-sdk/models/multi_channel_error.rb +11 -78
  143. data/lib/bandwidth-sdk/models/multi_channel_message_channel_enum.rb +1 -1
  144. data/lib/bandwidth-sdk/models/multi_channel_message_content.rb +11 -78
  145. data/lib/bandwidth-sdk/models/multi_channel_message_request.rb +21 -78
  146. data/lib/bandwidth-sdk/models/multi_channel_message_response_data.rb +41 -78
  147. data/lib/bandwidth-sdk/models/opt_in_workflow.rb +25 -82
  148. data/lib/bandwidth-sdk/models/page_info.rb +11 -78
  149. data/lib/bandwidth-sdk/models/priority_enum.rb +1 -1
  150. data/lib/bandwidth-sdk/models/product_type_enum.rb +1 -1
  151. data/lib/bandwidth-sdk/models/rbm_action_base.rb +21 -78
  152. data/lib/bandwidth-sdk/models/rbm_action_dial.rb +31 -78
  153. data/lib/bandwidth-sdk/models/rbm_action_open_url.rb +21 -78
  154. data/lib/bandwidth-sdk/models/rbm_action_type_enum.rb +1 -1
  155. data/lib/bandwidth-sdk/models/rbm_action_view_location.rb +41 -78
  156. data/lib/bandwidth-sdk/models/rbm_card_content.rb +11 -78
  157. data/lib/bandwidth-sdk/models/rbm_card_content_media.rb +21 -78
  158. data/lib/bandwidth-sdk/models/rbm_location_response.rb +11 -78
  159. data/lib/bandwidth-sdk/models/rbm_media_height_enum.rb +1 -1
  160. data/lib/bandwidth-sdk/models/rbm_message_carousel_card.rb +21 -78
  161. data/lib/bandwidth-sdk/models/rbm_message_content_file.rb +11 -78
  162. data/lib/bandwidth-sdk/models/rbm_message_content_rich_card.rb +3 -4
  163. data/lib/bandwidth-sdk/models/rbm_message_content_text.rb +11 -78
  164. data/lib/bandwidth-sdk/models/rbm_message_media.rb +21 -78
  165. data/lib/bandwidth-sdk/models/rbm_standalone_card.rb +41 -78
  166. data/lib/bandwidth-sdk/models/rbm_suggestion_response.rb +11 -78
  167. data/lib/bandwidth-sdk/models/recording_available_callback.rb +11 -78
  168. data/lib/bandwidth-sdk/models/recording_complete_callback.rb +11 -78
  169. data/lib/bandwidth-sdk/models/recording_state_enum.rb +1 -1
  170. data/lib/bandwidth-sdk/models/recording_transcription_metadata.rb +11 -78
  171. data/lib/bandwidth-sdk/models/recording_transcriptions.rb +11 -78
  172. data/lib/bandwidth-sdk/models/redirect_callback.rb +11 -78
  173. data/lib/bandwidth-sdk/models/redirect_method_enum.rb +1 -1
  174. data/lib/bandwidth-sdk/models/sms_message_content.rb +11 -78
  175. data/lib/bandwidth-sdk/models/standalone_card_orientation_enum.rb +1 -1
  176. data/lib/bandwidth-sdk/models/status_callback.rb +61 -78
  177. data/lib/bandwidth-sdk/models/status_callback_message.rb +81 -78
  178. data/lib/bandwidth-sdk/models/status_callback_type_enum.rb +6 -6
  179. data/lib/bandwidth-sdk/models/stir_shaken.rb +11 -78
  180. data/lib/bandwidth-sdk/models/sync_lookup_request.rb +11 -78
  181. data/lib/bandwidth-sdk/models/telephone_number.rb +11 -78
  182. data/lib/bandwidth-sdk/models/tfv_basic_authentication.rb +11 -78
  183. data/lib/bandwidth-sdk/models/tfv_callback_status_enum.rb +1 -1
  184. data/lib/bandwidth-sdk/models/tfv_error.rb +11 -78
  185. data/lib/bandwidth-sdk/models/tfv_status.rb +13 -80
  186. data/lib/bandwidth-sdk/models/tfv_status_enum.rb +1 -1
  187. data/lib/bandwidth-sdk/models/tfv_submission_info.rb +21 -88
  188. data/lib/bandwidth-sdk/models/tfv_submission_wrapper.rb +11 -78
  189. data/lib/bandwidth-sdk/models/thumbnail_alignment_enum.rb +1 -1
  190. data/lib/bandwidth-sdk/models/transcribe_recording.rb +11 -78
  191. data/lib/bandwidth-sdk/models/transcription.rb +11 -78
  192. data/lib/bandwidth-sdk/models/transcription_available_callback.rb +11 -78
  193. data/lib/bandwidth-sdk/models/transfer_answer_callback.rb +11 -78
  194. data/lib/bandwidth-sdk/models/transfer_complete_callback.rb +11 -78
  195. data/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb +11 -78
  196. data/lib/bandwidth-sdk/models/update_call.rb +11 -78
  197. data/lib/bandwidth-sdk/models/update_call_recording.rb +21 -78
  198. data/lib/bandwidth-sdk/models/update_conference.rb +11 -78
  199. data/lib/bandwidth-sdk/models/update_conference_member.rb +11 -78
  200. data/lib/bandwidth-sdk/models/verification_denial_webhook.rb +13 -80
  201. data/lib/bandwidth-sdk/models/verification_request.rb +51 -88
  202. data/lib/bandwidth-sdk/models/verification_update_request.rb +51 -88
  203. data/lib/bandwidth-sdk/models/verification_webhook.rb +13 -80
  204. data/lib/bandwidth-sdk/models/verify_code_request.rb +13 -80
  205. data/lib/bandwidth-sdk/models/verify_code_response.rb +11 -78
  206. data/lib/bandwidth-sdk/models/voice_api_error.rb +11 -78
  207. data/lib/bandwidth-sdk/models/voice_code_response.rb +11 -78
  208. data/lib/bandwidth-sdk/models/webhook_subscription.rb +13 -80
  209. data/lib/bandwidth-sdk/models/webhook_subscription_basic_authentication.rb +11 -78
  210. data/lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb +15 -82
  211. data/lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb +1 -1
  212. data/lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb +21 -78
  213. data/lib/bandwidth-sdk/version.rb +2 -2
  214. data/lib/bandwidth-sdk.rb +2 -1
  215. data/openapitools.json +1 -1
  216. data/spec/smoke/calls_api_spec.rb +50 -76
  217. data/spec/smoke/conferences_api_spec.rb +7 -5
  218. data/spec/smoke/media_api_spec.rb +4 -2
  219. data/spec/smoke/messages_api_spec.rb +9 -4
  220. data/spec/smoke/mfa_api_spec.rb +9 -4
  221. data/spec/smoke/multi_channel_api_spec.rb +4 -2
  222. data/spec/smoke/phone_number_lookup_api_spec.rb +6 -4
  223. data/spec/smoke/recordings_api_spec.rb +7 -33
  224. data/spec/smoke/statistics_api_spec.rb +16 -8
  225. data/spec/smoke/toll_free_verification_api_spec.rb +6 -4
  226. data/spec/smoke/transcriptions_api_spec.rb +7 -5
  227. data/spec/spec_helper.rb +2 -0
  228. data/spec/unit/models/verify_code_request_spec.rb +1 -1
  229. metadata +5 -2
@@ -0,0 +1,545 @@
1
+ =begin
2
+ {{> api_info}}
3
+
4
+ =end
5
+
6
+ module {{moduleName}}
7
+ class Configuration
8
+ # Defines url scheme
9
+ attr_accessor :scheme
10
+
11
+ # Defines url host
12
+ attr_accessor :host
13
+
14
+ # Defines url base path
15
+ attr_accessor :base_path
16
+
17
+ # Define server configuration index
18
+ attr_accessor :server_index
19
+
20
+ # Define server operation configuration index
21
+ attr_accessor :server_operation_index
22
+
23
+ # Default server variables
24
+ attr_accessor :server_variables
25
+
26
+ # Default server operation variables
27
+ attr_accessor :server_operation_variables
28
+
29
+ # Defines API keys used with API Key authentications.
30
+ #
31
+ # @return [Hash] key: parameter name, value: parameter value (API key)
32
+ #
33
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
34
+ # config.api_key['api_key'] = 'xxx'
35
+ attr_accessor :api_key
36
+
37
+ # Defines API key prefixes used with API Key authentications.
38
+ #
39
+ # @return [Hash] key: parameter name, value: API key prefix
40
+ #
41
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
42
+ # config.api_key_prefix['api_key'] = 'Token'
43
+ attr_accessor :api_key_prefix
44
+
45
+ # Defines the username used with HTTP basic authentication.
46
+ #
47
+ # @return [String]
48
+ attr_accessor :username
49
+
50
+ # Defines the password used with HTTP basic authentication.
51
+ #
52
+ # @return [String]
53
+ attr_accessor :password
54
+
55
+ # Defines the client ID used with OAuth2.
56
+ #
57
+ # @return [String]
58
+ attr_accessor :client_id
59
+
60
+ # Defines the client secret used with OAuth2.
61
+ #
62
+ # @return [String]
63
+ attr_accessor :client_secret
64
+
65
+ # Defines the access token (Bearer) used with OAuth2.
66
+ attr_accessor :access_token
67
+
68
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
69
+ # Overrides the access_token if set
70
+ # @return [Proc]
71
+ attr_accessor :access_token_getter
72
+
73
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
74
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
75
+ # Default to false.
76
+ attr_accessor :return_binary_data
77
+
78
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
79
+ # details will be logged with `logger.debug` (see the `logger` attribute).
80
+ # Default to false.
81
+ #
82
+ # @return [true, false]
83
+ attr_accessor :debugging
84
+
85
+ # Set this to ignore operation servers for the API client. This is useful when you need to
86
+ # send requests to a different server than the one specified in the OpenAPI document.
87
+ # Will default to the base url defined in the spec but can be overridden by setting
88
+ # `scheme`, `host`, `base_path` directly.
89
+ # Default to false.
90
+ # @return [true, false]
91
+ attr_accessor :ignore_operation_servers
92
+
93
+ # Defines the logger used for debugging.
94
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
95
+ #
96
+ # @return [#debug]
97
+ attr_accessor :logger
98
+
99
+ # Defines the temporary folder to store downloaded files
100
+ # (for API endpoints that have file response).
101
+ # Default to use `Tempfile`.
102
+ #
103
+ # @return [String]
104
+ attr_accessor :temp_folder_path
105
+
106
+ # The time limit for HTTP request in seconds.
107
+ # Default to 0 (never times out).
108
+ attr_accessor :timeout
109
+
110
+ # Set this to false to skip client side validation in the operation.
111
+ # Default to true.
112
+ # @return [true, false]
113
+ attr_accessor :client_side_validation
114
+
115
+ {{#isTyphoeus}}
116
+ {{> configuration_typhoeus_partial}}
117
+
118
+ {{/isTyphoeus}}
119
+ {{#isFaraday}}
120
+ {{> configuration_faraday_partial}}
121
+
122
+ {{/isFaraday}}
123
+ {{#isHttpx}}
124
+ {{> configuration_httpx_partial}}
125
+
126
+ {{/isHttpx}}
127
+
128
+ attr_accessor :inject_format
129
+
130
+ attr_accessor :force_ending_format
131
+
132
+ def initialize
133
+ @scheme = '{{scheme}}'
134
+ @host = '{{host}}{{#port}}:{{{.}}}{{/port}}'
135
+ @base_path = '{{contextPath}}'
136
+ @server_index = nil
137
+ @server_operation_index = {}
138
+ @server_variables = {}
139
+ @server_operation_variables = {}
140
+ @api_key = {}
141
+ @api_key_prefix = {}
142
+ @client_side_validation = true
143
+ {{#isFaraday}}
144
+ @ssl_verify = true
145
+ @ssl_verify_mode = nil
146
+ @ssl_ca_file = nil
147
+ @ssl_client_cert = nil
148
+ @ssl_client_key = nil
149
+ @middlewares = Hash.new { |h, k| h[k] = [] }
150
+ @configure_connection_blocks = []
151
+ @timeout = 60
152
+ # return data as binary instead of file
153
+ @return_binary_data = false
154
+ @params_encoder = nil
155
+ {{/isFaraday}}
156
+ {{#isTyphoeus}}
157
+ @verify_ssl = true
158
+ @verify_ssl_host = true
159
+ @cert_file = nil
160
+ @key_file = nil
161
+ @timeout = 0
162
+ @params_encoding = nil
163
+ {{/isTyphoeus}}
164
+ {{#isHttpx}}
165
+ @ssl = nil
166
+ @proxy = nil
167
+ @timeout = 60
168
+ @configure_session_blocks = []
169
+ {{/isHttpx}}
170
+ @debugging = false
171
+ @ignore_operation_servers = false
172
+ @inject_format = false
173
+ @force_ending_format = false
174
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
175
+ {{#authMethods}}
176
+ {{#isOAuth}}
177
+ @access_token_expiration = nil
178
+ @access_token_getter = Proc.new {
179
+ access_token_valid = @access_token && (@access_token_expiration.nil? || @access_token_expiration > Time.now + 60)
180
+ next @access_token if access_token_valid
181
+ next unless @client_id && @client_secret
182
+
183
+ puts "Refreshing access token..." if @debugging
184
+ # obtain new access token using client credentials
185
+ token_url = '{{tokenUrl}}'
186
+ auth_header = 'Basic ' + ["#{@client_id}:#{@client_secret}"].pack('m').delete("\r\n")
187
+ conn = Faraday.new(url: token_url) do |faraday|
188
+ faraday.request :url_encoded
189
+ faraday.adapter Faraday.default_adapter
190
+ end
191
+ response = conn.post do |req|
192
+ req.headers['Authorization'] = auth_header
193
+ req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
194
+ req.body = 'grant_type=client_credentials'
195
+ end
196
+ if response.status != 200
197
+ raise "Failed to obtain access token: #{response.status} #{response.body}"
198
+ end
199
+ body = JSON.parse(response.body)
200
+ @access_token = body['access_token']
201
+ @access_token_expiration = Time.now + body['expires_in']
202
+ }
203
+ {{/isOAuth}}
204
+ {{/authMethods}}
205
+
206
+ yield(self) if block_given?
207
+ end
208
+
209
+ # The default Configuration object.
210
+ def self.default
211
+ @@default ||= Configuration.new
212
+ end
213
+
214
+ def configure
215
+ yield(self) if block_given?
216
+ end
217
+
218
+ def scheme=(scheme)
219
+ # remove :// from scheme
220
+ @scheme = scheme.sub(/:\/\//, '')
221
+ end
222
+
223
+ def host=(host)
224
+ # remove http(s):// and anything after a slash
225
+ @host = host.sub(/https?:\/\//, '').split('/').first
226
+ end
227
+
228
+ def base_path=(base_path)
229
+ # Add leading and trailing slashes to base_path
230
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
231
+ @base_path = '' if @base_path == '/'
232
+ end
233
+
234
+ # Returns base URL for specified operation based on server settings
235
+ def base_url(operation = nil)
236
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
237
+ if operation_server_settings.key?(operation) then
238
+ index = server_operation_index.fetch(operation, server_index)
239
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
240
+ else
241
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
242
+ end
243
+ end
244
+
245
+ # Gets API key (with prefix if set).
246
+ # @param [String] param_name the parameter name of API key auth
247
+ def api_key_with_prefix(param_name, param_alias = nil)
248
+ key = @api_key[param_name]
249
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
250
+ if @api_key_prefix[param_name]
251
+ "#{@api_key_prefix[param_name]} #{key}"
252
+ else
253
+ key
254
+ end
255
+ end
256
+
257
+ # Gets access_token using access_token_getter or uses the static access_token
258
+ def access_token_with_refresh
259
+ return access_token if access_token_getter.nil?
260
+ access_token_getter.call
261
+ end
262
+
263
+ # Gets Basic Auth token string
264
+ def basic_auth_token
265
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
266
+ end
267
+
268
+ {{#authMethods}}
269
+ {{#isOAuth}}
270
+ # Gets Bearer auth token string
271
+ def oauth_bearer_token
272
+ "Bearer #{access_token_with_refresh}" unless access_token_with_refresh.nil?
273
+ end
274
+
275
+ {{/isOAuth}}
276
+ {{/authMethods}}
277
+
278
+ # Returns Auth Settings hash for api client.
279
+ def auth_settings
280
+ {
281
+ {{#authMethods}}
282
+ {{#isApiKey}}
283
+ '{{name}}' =>
284
+ {
285
+ type: 'api_key',
286
+ in: {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}},
287
+ key: '{{keyParamName}}',
288
+ value: api_key_with_prefix('{{keyParamName}}'{{#vendorExtensions.x-auth-id-alias}}, '{{.}}'{{/vendorExtensions.x-auth-id-alias}})
289
+ },
290
+ {{/isApiKey}}
291
+ {{#isBasic}}
292
+ {{#isBasicBasic}}
293
+ '{{name}}' =>
294
+ {
295
+ type: 'basic',
296
+ in: 'header',
297
+ key: 'Authorization',
298
+ value: basic_auth_token
299
+ },
300
+ {{/isBasicBasic}}
301
+ {{#isBasicBearer}}
302
+ '{{name}}' =>
303
+ {
304
+ type: 'bearer',
305
+ in: 'header',
306
+ {{#bearerFormat}}
307
+ format: '{{{.}}}',
308
+ {{/bearerFormat}}
309
+ key: 'Authorization',
310
+ value: "Bearer #{access_token_with_refresh}"
311
+ },
312
+ {{/isBasicBearer}}
313
+ {{/isBasic}}
314
+ {{#isOAuth}}
315
+ '{{name}}' =>
316
+ {
317
+ type: 'oauth2',
318
+ in: 'header',
319
+ key: 'Authorization',
320
+ value: oauth_bearer_token
321
+ },
322
+ {{/isOAuth}}
323
+ {{/authMethods}}
324
+ }
325
+ end
326
+
327
+ # Returns an array of Server setting
328
+ def server_settings
329
+ [
330
+ {{#servers}}
331
+ {
332
+ url: "{{{url}}}",
333
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
334
+ {{#variables}}
335
+ {{#-first}}
336
+ variables: {
337
+ {{/-first}}
338
+ {{{name}}}: {
339
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
340
+ default_value: "{{{defaultValue}}}",
341
+ {{#enumValues}}
342
+ {{#-first}}
343
+ enum_values: [
344
+ {{/-first}}
345
+ "{{{.}}}"{{^-last}},{{/-last}}
346
+ {{#-last}}
347
+ ]
348
+ {{/-last}}
349
+ {{/enumValues}}
350
+ }{{^-last}},{{/-last}}
351
+ {{#-last}}
352
+ }
353
+ {{/-last}}
354
+ {{/variables}}
355
+ }{{^-last}},{{/-last}}
356
+ {{/servers}}
357
+ ]
358
+ end
359
+
360
+ def operation_server_settings
361
+ {
362
+ {{#apiInfo}}
363
+ {{#apis}}
364
+ {{#operations}}
365
+ {{#operation}}
366
+ {{#servers}}
367
+ {{#-first}}
368
+ "{{{classname}}}.{{{nickname}}}": [
369
+ {{/-first}}
370
+ {
371
+ url: "{{{url}}}",
372
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
373
+ {{#variables}}
374
+ {{#-first}}
375
+ variables: {
376
+ {{/-first}}
377
+ {{{name}}}: {
378
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
379
+ default_value: "{{{defaultValue}}}",
380
+ {{#enumValues}}
381
+ {{#-first}}
382
+ enum_values: [
383
+ {{/-first}}
384
+ "{{{.}}}"{{^-last}},{{/-last}}
385
+ {{#-last}}
386
+ ]
387
+ {{/-last}}
388
+ {{/enumValues}}
389
+ }{{^-last}},{{/-last}}
390
+ {{#-last}}
391
+ }
392
+ {{/-last}}
393
+ {{/variables}}
394
+ }{{^-last}},{{/-last}}
395
+ {{#-last}}
396
+ ],
397
+ {{/-last}}
398
+ {{/servers}}
399
+ {{/operation}}
400
+ {{/operations}}
401
+ {{/apis}}
402
+ {{/apiInfo}}
403
+ }
404
+ end
405
+
406
+ # Returns URL based on server settings
407
+ #
408
+ # @param index array index of the server settings
409
+ # @param variables hash of variable and the corresponding value
410
+ def server_url(index, variables = {}, servers = nil)
411
+ servers = server_settings if servers == nil
412
+
413
+ # check array index out of bound
414
+ if (index.nil? || index < 0 || index >= servers.size)
415
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
416
+ end
417
+
418
+ server = servers[index]
419
+ url = server[:url]
420
+
421
+ return url unless server.key? :variables
422
+
423
+ # go through variable and assign a value
424
+ server[:variables].each do |name, variable|
425
+ if variables.key?(name)
426
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
427
+ url.gsub! "{" + name.to_s + "}", variables[name]
428
+ else
429
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
430
+ end
431
+ else
432
+ # use default value
433
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
434
+ end
435
+ end
436
+
437
+ url
438
+ end
439
+
440
+ {{#isFaraday}}
441
+ # Configure Faraday connection directly.
442
+ #
443
+ # ```
444
+ # c.configure_faraday_connection do |conn|
445
+ # conn.use Faraday::HttpCache, shared_cache: false, logger: logger
446
+ # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
447
+ # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
448
+ # end
449
+ # end
450
+ #
451
+ # c.configure_faraday_connection do |conn|
452
+ # conn.adapter :typhoeus
453
+ # end
454
+ # ```
455
+ #
456
+ # @param block [Proc] `#call`able object that takes one arg, the connection
457
+ def configure_faraday_connection(&block)
458
+ @configure_connection_blocks << block
459
+ end
460
+
461
+ def configure_connection(conn)
462
+ @configure_connection_blocks.each do |block|
463
+ block.call(conn)
464
+ end
465
+ end
466
+
467
+ # Adds middleware to the stack
468
+ def use(*middleware)
469
+ set_faraday_middleware(:use, *middleware)
470
+ end
471
+
472
+ # Adds request middleware to the stack
473
+ def request(*middleware)
474
+ set_faraday_middleware(:request, *middleware)
475
+ end
476
+
477
+ # Adds response middleware to the stack
478
+ def response(*middleware)
479
+ set_faraday_middleware(:response, *middleware)
480
+ end
481
+
482
+ # Adds Faraday middleware setting information to the stack
483
+ #
484
+ # @example Use the `set_faraday_middleware` method to set middleware information
485
+ # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
486
+ # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
487
+ # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
488
+ # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
489
+ # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
490
+ # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
491
+ #
492
+ # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
493
+ def set_faraday_middleware(operation, key, *args, &block)
494
+ unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
495
+ fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
496
+ " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
497
+ end
498
+
499
+ @middlewares[operation] << [key, args, block]
500
+ end
501
+ ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
502
+
503
+ # Set up middleware on the connection
504
+ def configure_middleware(connection)
505
+ return if @middlewares.empty?
506
+
507
+ [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
508
+ next unless @middlewares.key?(operation)
509
+
510
+ @middlewares[operation].each do |key, args, block|
511
+ connection.builder.send(operation, key, *args, &block)
512
+ end
513
+ end
514
+
515
+ if @middlewares.key?(:delete)
516
+ @middlewares[:delete].each do |key, _args, _block|
517
+ connection.builder.delete(key)
518
+ end
519
+ end
520
+ end
521
+ {{/isFaraday}}
522
+
523
+ {{#isHttpx}}
524
+ # Configure Httpx session directly.
525
+ #
526
+ # ```
527
+ # c.configure_session do |http|
528
+ # http.plugin(:follow_redirects).with(debug: STDOUT, debug_level: 1)
529
+ # end
530
+ # ```
531
+ #
532
+ # @param block [Proc] `#call`able object that takes one arg, the connection
533
+ def configure_session(&block)
534
+ @configure_session_blocks << block
535
+ end
536
+
537
+
538
+ def configure(session)
539
+ @configure_session_blocks.reduce(session) do |configured_sess, block|
540
+ block.call(configured_sess)
541
+ end
542
+ end
543
+ {{/isHttpx}}
544
+ end
545
+ end
@@ -1,10 +1,12 @@
1
1
  =begin
2
2
  {{> api_info}}
3
+
3
4
  =end
4
5
 
5
6
  # Common files
6
7
  require '{{gemName}}/api_client'
7
8
  require '{{gemName}}/api_error'
9
+ require '{{gemName}}/api_model_base'
8
10
  require '{{gemName}}/version'
9
11
  require '{{gemName}}/configuration'
10
12
 
data/docs/CallsApi.md CHANGED
@@ -29,6 +29,9 @@ Bandwidth.configure do |config|
29
29
  # Configure HTTP basic authorization: Basic
30
30
  config.username = 'YOUR USERNAME'
31
31
  config.password = 'YOUR PASSWORD'
32
+
33
+ # Configure OAuth2 access token for authorization: OAuth2
34
+ config.access_token = 'YOUR ACCESS TOKEN'
32
35
  end
33
36
 
34
37
  api_instance = Bandwidth::CallsApi.new
@@ -75,7 +78,7 @@ end
75
78
 
76
79
  ### Authorization
77
80
 
78
- [Basic](../README.md#Basic)
81
+ [Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
79
82
 
80
83
  ### HTTP request headers
81
84
 
@@ -101,6 +104,9 @@ Bandwidth.configure do |config|
101
104
  # Configure HTTP basic authorization: Basic
102
105
  config.username = 'YOUR USERNAME'
103
106
  config.password = 'YOUR PASSWORD'
107
+
108
+ # Configure OAuth2 access token for authorization: OAuth2
109
+ config.access_token = 'YOUR ACCESS TOKEN'
104
110
  end
105
111
 
106
112
  api_instance = Bandwidth::CallsApi.new
@@ -147,7 +153,7 @@ end
147
153
 
148
154
  ### Authorization
149
155
 
150
- [Basic](../README.md#Basic)
156
+ [Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
151
157
 
152
158
  ### HTTP request headers
153
159
 
@@ -173,6 +179,9 @@ Bandwidth.configure do |config|
173
179
  # Configure HTTP basic authorization: Basic
174
180
  config.username = 'YOUR USERNAME'
175
181
  config.password = 'YOUR PASSWORD'
182
+
183
+ # Configure OAuth2 access token for authorization: OAuth2
184
+ config.access_token = 'YOUR ACCESS TOKEN'
176
185
  end
177
186
 
178
187
  api_instance = Bandwidth::CallsApi.new
@@ -233,7 +242,7 @@ end
233
242
 
234
243
  ### Authorization
235
244
 
236
- [Basic](../README.md#Basic)
245
+ [Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
237
246
 
238
247
  ### HTTP request headers
239
248
 
@@ -259,6 +268,9 @@ Bandwidth.configure do |config|
259
268
  # Configure HTTP basic authorization: Basic
260
269
  config.username = 'YOUR USERNAME'
261
270
  config.password = 'YOUR PASSWORD'
271
+
272
+ # Configure OAuth2 access token for authorization: OAuth2
273
+ config.access_token = 'YOUR ACCESS TOKEN'
262
274
  end
263
275
 
264
276
  api_instance = Bandwidth::CallsApi.new
@@ -306,7 +318,7 @@ nil (empty response body)
306
318
 
307
319
  ### Authorization
308
320
 
309
- [Basic](../README.md#Basic)
321
+ [Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
310
322
 
311
323
  ### HTTP request headers
312
324
 
@@ -332,6 +344,9 @@ Bandwidth.configure do |config|
332
344
  # Configure HTTP basic authorization: Basic
333
345
  config.username = 'YOUR USERNAME'
334
346
  config.password = 'YOUR PASSWORD'
347
+
348
+ # Configure OAuth2 access token for authorization: OAuth2
349
+ config.access_token = 'YOUR ACCESS TOKEN'
335
350
  end
336
351
 
337
352
  api_instance = Bandwidth::CallsApi.new
@@ -382,7 +397,7 @@ nil (empty response body)
382
397
 
383
398
  ### Authorization
384
399
 
385
- [Basic](../README.md#Basic)
400
+ [Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
386
401
 
387
402
  ### HTTP request headers
388
403