jamm 1.3.0 → 1.4.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/jamm/api/api/customer_api.rb +82 -52
  4. data/lib/jamm/api/api/healthcheck_api.rb +18 -15
  5. data/lib/jamm/api/api/payment_api.rb +113 -62
  6. data/lib/jamm/api/api/webhook_service_api.rb +41 -28
  7. data/lib/jamm/api/api_client.rb +74 -66
  8. data/lib/jamm/api/api_error.rb +16 -16
  9. data/lib/jamm/api/configuration.rb +42 -34
  10. data/lib/jamm/api/models/apiv1_error.rb +56 -44
  11. data/lib/jamm/api/models/apiv1_status.rb +57 -47
  12. data/lib/jamm/api/models/customer_service_update_customer_body.rb +107 -69
  13. data/lib/jamm/api/models/googlerpc_status.rb +61 -45
  14. data/lib/jamm/api/models/protobuf_any.rb +42 -35
  15. data/lib/jamm/api/models/v1_add_charge_request.rb +59 -44
  16. data/lib/jamm/api/models/v1_add_charge_response.rb +59 -44
  17. data/lib/jamm/api/models/v1_bank.rb +150 -95
  18. data/lib/jamm/api/models/v1_bank_assets.rb +60 -47
  19. data/lib/jamm/api/models/v1_bank_branch.rb +83 -56
  20. data/lib/jamm/api/models/v1_bank_information.rb +71 -51
  21. data/lib/jamm/api/models/v1_bank_quota.rb +99 -64
  22. data/lib/jamm/api/models/v1_bank_scheduled_maintenance_period.rb +75 -52
  23. data/lib/jamm/api/models/v1_buyer.rb +104 -76
  24. data/lib/jamm/api/models/v1_charge.rb +67 -52
  25. data/lib/jamm/api/models/v1_charge_message.rb +151 -93
  26. data/lib/jamm/api/models/v1_charge_message_status.rb +17 -18
  27. data/lib/jamm/api/models/v1_charge_result.rb +152 -93
  28. data/lib/jamm/api/models/v1_contract.rb +64 -52
  29. data/lib/jamm/api/models/v1_contract_message.rb +67 -48
  30. data/lib/jamm/api/models/v1_contract_status.rb +20 -21
  31. data/lib/jamm/api/models/v1_create_contract_with_charge_request.rb +59 -44
  32. data/lib/jamm/api/models/v1_create_contract_with_charge_response.rb +67 -48
  33. data/lib/jamm/api/models/v1_create_contract_without_charge_request.rb +51 -40
  34. data/lib/jamm/api/models/v1_create_contract_without_charge_response.rb +59 -44
  35. data/lib/jamm/api/models/v1_create_customer_request.rb +42 -35
  36. data/lib/jamm/api/models/v1_create_customer_response.rb +42 -35
  37. data/lib/jamm/api/models/v1_customer.rb +91 -60
  38. data/lib/jamm/api/models/v1_delete_customer_response.rb +42 -35
  39. data/lib/jamm/api/models/v1_deposit_type.rb +14 -15
  40. data/lib/jamm/api/models/v1_error_detail.rb +57 -44
  41. data/lib/jamm/api/models/v1_error_response.rb +46 -38
  42. data/lib/jamm/api/models/v1_error_type.rb +30 -31
  43. data/lib/jamm/api/models/v1_event_type.rb +20 -21
  44. data/lib/jamm/api/models/v1_get_bank_response.rb +42 -35
  45. data/lib/jamm/api/models/v1_get_branch_response.rb +42 -35
  46. data/lib/jamm/api/models/v1_get_branches_response.rb +44 -36
  47. data/lib/jamm/api/models/v1_get_charge_response.rb +51 -40
  48. data/lib/jamm/api/models/v1_get_charges_response.rb +60 -45
  49. data/lib/jamm/api/models/v1_get_contract_response.rb +51 -40
  50. data/lib/jamm/api/models/v1_get_customer_response.rb +42 -35
  51. data/lib/jamm/api/models/v1_get_major_banks_response.rb +59 -44
  52. data/lib/jamm/api/models/v1_initial_charge.rb +61 -48
  53. data/lib/jamm/api/models/v1_kyc_status.rb +16 -17
  54. data/lib/jamm/api/models/v1_merchant.rb +51 -40
  55. data/lib/jamm/api/models/v1_merchant_customer.rb +51 -40
  56. data/lib/jamm/api/models/v1_merchant_webhook_message.rb +75 -57
  57. data/lib/jamm/api/models/v1_message_response.rb +67 -48
  58. data/lib/jamm/api/models/v1_off_session_payment_request.rb +51 -40
  59. data/lib/jamm/api/models/v1_off_session_payment_response.rb +51 -40
  60. data/lib/jamm/api/models/v1_on_session_payment_data.rb +67 -48
  61. data/lib/jamm/api/models/v1_on_session_payment_error.rb +55 -45
  62. data/lib/jamm/api/models/v1_on_session_payment_error_code.rb +21 -22
  63. data/lib/jamm/api/models/v1_on_session_payment_request.rb +67 -48
  64. data/lib/jamm/api/models/v1_on_session_payment_response.rb +59 -44
  65. data/lib/jamm/api/models/v1_pagination.rb +51 -40
  66. data/lib/jamm/api/models/v1_payment_authorization_status.rb +14 -15
  67. data/lib/jamm/api/models/v1_payment_link.rb +57 -44
  68. data/lib/jamm/api/models/v1_ping_response.rb +42 -35
  69. data/lib/jamm/api/models/v1_search_banks_response.rb +44 -36
  70. data/lib/jamm/api/models/v1_search_branches_response.rb +44 -36
  71. data/lib/jamm/api/models/v1_update_customer_response.rb +42 -35
  72. data/lib/jamm/api/models/v1_url.rb +48 -39
  73. data/lib/jamm/api/models/v1_user_account_message.rb +67 -48
  74. data/lib/jamm/api/models/v1_withdraw_request.rb +51 -40
  75. data/lib/jamm/api/models/v1_withdraw_response.rb +51 -40
  76. data/lib/jamm/api/version.rb +11 -11
  77. data/lib/jamm/api.rb +10 -10
  78. data/lib/jamm/charge.rb +12 -0
  79. data/lib/jamm/deprecation.rb +13 -0
  80. data/lib/jamm/payment.rb +61 -0
  81. data/lib/jamm/version.rb +1 -1
  82. data/lib/jamm.rb +2 -0
  83. metadata +4 -2
@@ -1,14 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- # #Jamm API
4
- #
5
- # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
- #
7
- # The version of the OpenAPI document: 1.0
8
- #
9
- # Generated by: https://openapi-generator.tech
10
- # Generator version: 7.9.0
11
- #
1
+ =begin
2
+ #Jamm API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
12
 
13
13
  require 'date'
14
14
  require 'json'
@@ -17,6 +17,7 @@ require 'tempfile'
17
17
  require 'time'
18
18
  require 'typhoeus'
19
19
 
20
+
20
21
  module Api
21
22
  class ApiClient
22
23
  # The Configuration object holding settings to be used in the API client.
@@ -51,29 +52,33 @@ module Api
51
52
  tempfile = download_file(request) if opts[:return_type] == 'File'
52
53
  response = request.run
53
54
 
54
- @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" if @config.debugging
55
+ if @config.debugging
56
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
57
+ end
55
58
 
56
59
  unless response.success?
57
60
  if response.timed_out?
58
- raise ApiError, 'Connection timed out'
59
- elsif response.code.zero?
61
+ fail ApiError.new('Connection timed out')
62
+ elsif response.code == 0
60
63
  # Errors from libcurl will be made visible here
61
- raise ApiError.new(:code => 0,
62
- :message => response.return_message)
64
+ fail ApiError.new(:code => 0,
65
+ :message => response.return_message)
63
66
  else
64
- raise ApiError.new(:code => response.code,
65
- :response_headers => response.headers,
66
- :response_body => response.body),
67
- response.status_message
67
+ fail ApiError.new(:code => response.code,
68
+ :response_headers => response.headers,
69
+ :response_body => response.body),
70
+ response.status_message
68
71
  end
69
72
  end
70
73
 
71
- data = if opts[:return_type] == 'File'
72
- tempfile
73
- elsif opts[:return_type]
74
- deserialize(response, opts[:return_type])
75
- end
76
- [data, response.code, response.headers]
74
+ if opts[:return_type] == 'File'
75
+ data = tempfile
76
+ elsif opts[:return_type]
77
+ data = deserialize(response, opts[:return_type])
78
+ else
79
+ data = nil
80
+ end
81
+ return data, response.code, response.headers
77
82
  end
78
83
 
79
84
  # Builds the HTTP request
@@ -94,6 +99,7 @@ module Api
94
99
  form_params = opts[:form_params] || {}
95
100
  follow_location = opts[:follow_location] || true
96
101
 
102
+
97
103
  # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
98
104
  _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
99
105
 
@@ -114,10 +120,12 @@ module Api
114
120
  # set custom cert, if provided
115
121
  req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
116
122
 
117
- if %i[post patch put delete].include?(http_method)
123
+ if [:post, :patch, :put, :delete].include?(http_method)
118
124
  req_body = build_request_body(header_params, form_params, opts[:body])
119
125
  req_opts.update :body => req_body
120
- @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" if @config.debugging
126
+ if @config.debugging
127
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
128
+ end
121
129
  end
122
130
 
123
131
  Typhoeus::Request.new(url, req_opts)
@@ -132,16 +140,16 @@ module Api
132
140
  def build_request_body(header_params, form_params, body)
133
141
  # http form
134
142
  if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
135
- header_params['Content-Type'] == 'multipart/form-data'
143
+ header_params['Content-Type'] == 'multipart/form-data'
136
144
  data = {}
137
145
  form_params.each do |key, value|
138
- data[key] = case value
139
- when ::File, ::Array, nil
140
- # let typhoeus handle File, Array and nil parameters
141
- value
142
- else
143
- value.to_s
144
- end
146
+ case value
147
+ when ::File, ::Array, nil
148
+ # let typhoeus handle File, Array and nil parameters
149
+ data[key] = value
150
+ else
151
+ data[key] = value.to_s
152
+ end
145
153
  end
146
154
  elsif body
147
155
  data = body.is_a?(String) ? body : body.to_json
@@ -171,7 +179,7 @@ module Api
171
179
  else
172
180
  prefix = 'download-'
173
181
  end
174
- prefix += '-' unless prefix.end_with?('-')
182
+ prefix = prefix + '-' unless prefix.end_with?('-')
175
183
  encoding = response.body.encoding
176
184
  tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
177
185
  end
@@ -181,13 +189,15 @@ module Api
181
189
  end
182
190
  # run the request to ensure the tempfile is created successfully before returning it
183
191
  request.run
184
- raise ApiError, "Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}" unless tempfile
185
-
186
- tempfile.close
187
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
188
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
189
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
190
- 'explicitly with `tempfile.delete`'
192
+ if tempfile
193
+ tempfile.close
194
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
195
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
196
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
197
+ "explicitly with `tempfile.delete`"
198
+ else
199
+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
200
+ end
191
201
 
192
202
  tempfile
193
203
  end
@@ -201,7 +211,7 @@ module Api
201
211
  # @param [String] mime MIME
202
212
  # @return [Boolean] True if the MIME is application/json
203
213
  def json_mime?(mime)
204
- (mime == '*/*') || !(mime =~ %r{^Application/.*json(?!p)(;.*)?}i).nil?
214
+ (mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
205
215
  end
206
216
 
207
217
  # Deserialize the response to the given return type.
@@ -218,14 +228,16 @@ module Api
218
228
  # ensuring a default content type
219
229
  content_type = response.headers['Content-Type'] || 'application/json'
220
230
 
221
- raise "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
231
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
222
232
 
223
233
  begin
224
234
  data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
225
235
  rescue JSON::ParserError => e
226
- raise e unless %w[String Date Time].include?(return_type)
227
-
228
- data = body
236
+ if %w(String Date Time).include?(return_type)
237
+ data = body
238
+ else
239
+ raise e
240
+ end
229
241
  end
230
242
 
231
243
  convert_to_type data, return_type
@@ -237,7 +249,6 @@ module Api
237
249
  # @return [Mixed] Data in a particular type
238
250
  def convert_to_type(data, return_type)
239
251
  return nil if data.nil?
240
-
241
252
  case return_type
242
253
  when 'String'
243
254
  data.to_s
@@ -258,11 +269,11 @@ module Api
258
269
  data
259
270
  when /\AArray<(.+)>\z/
260
271
  # e.g. Array<Pet>
261
- sub_type = ::Regexp.last_match(1)
272
+ sub_type = $1
262
273
  data.map { |item| convert_to_type(item, sub_type) }
263
- when /\AHash<String, (.+)>\z/
274
+ when /\AHash\<String, (.+)\>\z/
264
275
  # e.g. Hash<String, Integer>
265
- sub_type = ::Regexp.last_match(1)
276
+ sub_type = $1
266
277
  {}.tap do |hash|
267
278
  data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
268
279
  end
@@ -279,12 +290,12 @@ module Api
279
290
  # @param [String] filename the filename to be sanitized
280
291
  # @return [String] the sanitized filename
281
292
  def sanitize_filename(filename)
282
- filename.split(%r{[/\\]}).last
293
+ filename.split(/[\/\\]/).last
283
294
  end
284
295
 
285
296
  def build_request_url(path, opts = {})
286
297
  # Add leading and trailing slashes to path
287
- path = "/#{path}".gsub(%r{/+}, '/')
298
+ path = "/#{path}".gsub(/\/+/, '/')
288
299
  @config.base_url(opts[:operation]) + path
289
300
  end
290
301
 
@@ -297,11 +308,10 @@ module Api
297
308
  Array(auth_names).each do |auth_name|
298
309
  auth_setting = @config.auth_settings[auth_name]
299
310
  next unless auth_setting
300
-
301
311
  case auth_setting[:in]
302
312
  when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
303
313
  when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
304
- else raise ArgumentError, 'Authentication token must be in `query` or `header`'
314
+ else fail ArgumentError, 'Authentication token must be in `query` or `header`'
305
315
  end
306
316
  end
307
317
  end
@@ -319,7 +329,6 @@ module Api
319
329
  # @return [String] the Accept header (e.g. application/json)
320
330
  def select_header_accept(accepts)
321
331
  return nil if accepts.nil? || accepts.empty?
322
-
323
332
  # use JSON when present, otherwise use all of the provided
324
333
  json_accept = accepts.find { |s| json_mime?(s) }
325
334
  json_accept || accepts.join(',')
@@ -331,7 +340,6 @@ module Api
331
340
  def select_header_content_type(content_types)
332
341
  # return nil by default
333
342
  return if content_types.nil? || content_types.empty?
334
-
335
343
  # use JSON when present, otherwise use the first one
336
344
  json_content_type = content_types.find { |s| json_mime?(s) }
337
345
  json_content_type || content_types.first
@@ -342,12 +350,12 @@ module Api
342
350
  # @return [String] JSON string representation of the object
343
351
  def object_to_http_body(model)
344
352
  return model if model.nil? || model.is_a?(String)
345
-
346
- local_body = if model.is_a?(Array)
347
- model.map { |m| object_to_hash(m) }
348
- else
349
- object_to_hash(model)
350
- end
353
+ local_body = nil
354
+ if model.is_a?(Array)
355
+ local_body = model.map { |m| object_to_hash(m) }
356
+ else
357
+ local_body = object_to_hash(model)
358
+ end
351
359
  local_body.to_json
352
360
  end
353
361
 
@@ -378,7 +386,7 @@ module Api
378
386
  # return the array directly as typhoeus will handle it as expected
379
387
  param
380
388
  else
381
- raise "unknown collection format: #{collection_format.inspect}"
389
+ fail "unknown collection format: #{collection_format.inspect}"
382
390
  end
383
391
  end
384
392
  end
@@ -1,14 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- # #Jamm API
4
- #
5
- # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
- #
7
- # The version of the OpenAPI document: 1.0
8
- #
9
- # Generated by: https://openapi-generator.tech
10
- # Generator version: 7.9.0
11
- #
1
+ =begin
2
+ #Jamm API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
12
 
13
13
  module Api
14
14
  class ApiError < StandardError
@@ -42,11 +42,11 @@ module Api
42
42
  end
43
43
 
44
44
  def message
45
- msg = if @message.nil?
46
- 'Error message: the server returns an error'
47
- else
48
- @message
49
- end
45
+ if @message.nil?
46
+ msg = "Error message: the server returns an error"
47
+ else
48
+ msg = @message
49
+ end
50
50
 
51
51
  msg += "\nHTTP status code: #{code}" if code
52
52
  msg += "\nResponse headers: #{response_headers}" if response_headers
@@ -1,14 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- # #Jamm API
4
- #
5
- # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
- #
7
- # The version of the OpenAPI document: 1.0
8
- #
9
- # Generated by: https://openapi-generator.tech
10
- # Generator version: 7.9.0
11
- #
1
+ =begin
2
+ #Jamm API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
12
 
13
13
  module Api
14
14
  class Configuration
@@ -151,7 +151,10 @@ module Api
151
151
  # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
152
152
  attr_accessor :params_encoding
153
153
 
154
- attr_accessor :inject_format, :force_ending_format
154
+
155
+ attr_accessor :inject_format
156
+
157
+ attr_accessor :force_ending_format
155
158
 
156
159
  def initialize
157
160
  @scheme = 'http'
@@ -174,7 +177,7 @@ module Api
174
177
  @ignore_operation_servers = false
175
178
  @inject_format = false
176
179
  @force_ending_format = false
177
- @logger = defined?(Rails) ? Rails.logger : Logger.new($stdout)
180
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
178
181
 
179
182
  yield(self) if block_given?
180
183
  end
@@ -190,29 +193,28 @@ module Api
190
193
 
191
194
  def scheme=(scheme)
192
195
  # remove :// from scheme
193
- @scheme = scheme.sub(%r{://}, '')
196
+ @scheme = scheme.sub(/:\/\//, '')
194
197
  end
195
198
 
196
199
  def host=(host)
197
200
  # remove http(s):// and anything after a slash
198
- @host = host.sub(%r{https?://}, '').split('/').first
201
+ @host = host.sub(/https?:\/\//, '').split('/').first
199
202
  end
200
203
 
201
204
  def base_path=(base_path)
202
205
  # Add leading and trailing slashes to base_path
203
- @base_path = "/#{base_path}".gsub(%r{/+}, '/')
206
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
204
207
  @base_path = '' if @base_path == '/'
205
208
  end
206
209
 
207
210
  # Returns base URL for specified operation based on server settings
208
211
  def base_url(operation = nil)
209
- return "#{scheme}://#{[host, base_path].join('/').gsub(%r{/+}, '/')}".sub(%r{/+\z}, '') if ignore_operation_servers
210
-
211
- if operation_server_settings.key?(operation)
212
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
213
+ if operation_server_settings.key?(operation) then
212
214
  index = server_operation_index.fetch(operation, server_index)
213
215
  server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
214
216
  else
215
- server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(%r{/+}, '/')}".sub(%r{/+\z}, '') : server_url(server_index, server_variables, nil)
217
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
216
218
  end
217
219
  end
218
220
 
@@ -231,32 +233,33 @@ module Api
231
233
  # Gets access_token using access_token_getter or uses the static access_token
232
234
  def access_token_with_refresh
233
235
  return access_token if access_token_getter.nil?
234
-
235
236
  access_token_getter.call
236
237
  end
237
238
 
238
239
  # Gets Basic Auth token string
239
240
  def basic_auth_token
240
- "Basic #{["#{username}:#{password}"].pack('m').delete("\r\n")}"
241
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
241
242
  end
242
243
 
243
244
  # Returns Auth Settings hash for api client.
244
245
  def auth_settings
245
- {}
246
+ {
247
+ }
246
248
  end
247
249
 
248
250
  # Returns an array of Server setting
249
251
  def server_settings
250
252
  [
251
253
  {
252
- url: '',
253
- description: 'No description provided'
254
+ url: "",
255
+ description: "No description provided",
254
256
  }
255
257
  ]
256
258
  end
257
259
 
258
260
  def operation_server_settings
259
- {}
261
+ {
262
+ }
260
263
  end
261
264
 
262
265
  # Returns URL based on server settings
@@ -264,10 +267,12 @@ module Api
264
267
  # @param index array index of the server settings
265
268
  # @param variables hash of variable and the corresponding value
266
269
  def server_url(index, variables = {}, servers = nil)
267
- servers = server_settings if servers.nil?
270
+ servers = server_settings if servers == nil
268
271
 
269
272
  # check array index out of bound
270
- raise ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}" if index.nil? || index.negative? || index >= servers.size
273
+ if (index.nil? || index < 0 || index >= servers.size)
274
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
275
+ end
271
276
 
272
277
  server = servers[index]
273
278
  url = server[:url]
@@ -275,19 +280,22 @@ module Api
275
280
  return url unless server.key? :variables
276
281
 
277
282
  # go through variable and assign a value
278
- server[:variables].each_key do |name|
283
+ server[:variables].each do |name, variable|
279
284
  if variables.key?(name)
280
- raise ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}." unless !server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name])
281
-
282
- url.gsub! "{#{name}}", variables[name]
283
-
285
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
286
+ url.gsub! "{" + name.to_s + "}", variables[name]
287
+ else
288
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
289
+ end
284
290
  else
285
291
  # use default value
286
- url.gsub! "{#{name}}", server[:variables][name][:default_value]
292
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
287
293
  end
288
294
  end
289
295
 
290
296
  url
291
297
  end
298
+
299
+
292
300
  end
293
301
  end
@@ -1,14 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- # #Jamm API
4
- #
5
- # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
- #
7
- # The version of the OpenAPI document: 1.0
8
- #
9
- # Generated by: https://openapi-generator.tech
10
- # Generator version: 7.9.0
11
- #
1
+ =begin
2
+ #Jamm API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
12
 
13
13
  require 'date'
14
14
  require 'time'
@@ -28,9 +28,9 @@ module Api
28
28
  # Attribute mapping from ruby-style variable name to JSON key.
29
29
  def self.attribute_map
30
30
  {
31
- :code => :code,
32
- :message => :message,
33
- :details => :details
31
+ :'code' => :'code',
32
+ :'message' => :'message',
33
+ :'details' => :'details'
34
34
  }
35
35
  end
36
36
 
@@ -42,44 +42,54 @@ module Api
42
42
  # Attribute type mapping.
43
43
  def self.openapi_types
44
44
  {
45
- :code => :String,
46
- :message => :String,
47
- :details => :'Array<ErrorDetail>'
45
+ :'code' => :'String',
46
+ :'message' => :'String',
47
+ :'details' => :'Array<ErrorDetail>'
48
48
  }
49
49
  end
50
50
 
51
51
  # List of attributes with nullable: true
52
52
  def self.openapi_nullable
53
- Set.new([])
53
+ Set.new([
54
+ ])
54
55
  end
55
56
 
56
57
  # Initializes the object
57
58
  # @param [Hash] attributes Model attributes in the form of hash
58
59
  def initialize(attributes = {})
59
- raise ArgumentError, 'The input argument (attributes) must be a hash in `Api::Apiv1Error` initialize method' unless attributes.is_a?(Hash)
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Api::Apiv1Error` initialize method"
62
+ end
60
63
 
61
64
  # check to see if the attribute exists and convert string to symbol for hash key
62
- attributes = attributes.each_with_object({}) do |(k, v), h|
63
- raise ArgumentError, "`#{k}` is not a valid attribute in `Api::Apiv1Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect unless self.class.attribute_map.key?(k.to_sym)
64
-
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Api::Apiv1Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
65
69
  h[k.to_sym] = v
66
- end
67
-
68
- self.code = attributes[:code] if attributes.key?(:code)
70
+ }
69
71
 
70
- self.message = attributes[:message] if attributes.key?(:message)
72
+ if attributes.key?(:'code')
73
+ self.code = attributes[:'code']
74
+ end
71
75
 
72
- return unless attributes.key?(:details)
73
- return unless (value = attributes[:details]).is_a?(Array)
76
+ if attributes.key?(:'message')
77
+ self.message = attributes[:'message']
78
+ end
74
79
 
75
- self.details = value
80
+ if attributes.key?(:'details')
81
+ if (value = attributes[:'details']).is_a?(Array)
82
+ self.details = value
83
+ end
84
+ end
76
85
  end
77
86
 
78
87
  # Show invalid properties with the reasons. Usually used together with valid?
79
88
  # @return Array for valid properties with the reasons
80
89
  def list_invalid_properties
81
90
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
- []
91
+ invalid_properties = Array.new
92
+ invalid_properties
83
93
  end
84
94
 
85
95
  # Check to see if the all the properties in the model are valid
@@ -91,19 +101,18 @@ module Api
91
101
 
92
102
  # Checks equality by comparing each attribute.
93
103
  # @param [Object] Object to be compared
94
- def ==(other)
95
- return true if equal?(other)
96
-
97
- self.class == other.class &&
98
- code == other.code &&
99
- message == other.message &&
100
- details == other.details
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ code == o.code &&
108
+ message == o.message &&
109
+ details == o.details
101
110
  end
102
111
 
103
112
  # @see the `==` method
104
113
  # @param [Object] Object to be compared
105
- def eql?(other)
106
- self == other
114
+ def eql?(o)
115
+ self == o
107
116
  end
108
117
 
109
118
  # Calculates hash code according to all attributes.
@@ -117,18 +126,19 @@ module Api
117
126
  # @return [Object] Returns the model itself
118
127
  def self.build_from_hash(attributes)
119
128
  return nil unless attributes.is_a?(Hash)
120
-
121
129
  attributes = attributes.transform_keys(&:to_sym)
122
130
  transformed_hash = {}
123
131
  openapi_types.each_pair do |key, type|
124
132
  if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
125
- transformed_hash[key.to_s] = nil
133
+ transformed_hash["#{key}"] = nil
126
134
  elsif type =~ /\AArray<(.*)>/i
127
135
  # check to ensure the input is an array given that the attribute
128
136
  # is documented as an array but the input is not
129
- transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) } if attributes[attribute_map[key]].is_a?(Array)
137
+ if attributes[attribute_map[key]].is_a?(Array)
138
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
139
+ end
130
140
  elsif !attributes[attribute_map[key]].nil?
131
- transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
141
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
132
142
  end
133
143
  end
134
144
  new(transformed_hash)
@@ -194,7 +204,7 @@ module Api
194
204
  def to_hash
195
205
  hash = {}
196
206
  self.class.attribute_map.each_pair do |attr, param|
197
- value = send(attr)
207
+ value = self.send(attr)
198
208
  if value.nil?
199
209
  is_nullable = self.class.openapi_nullable.include?(attr)
200
210
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
@@ -222,5 +232,7 @@ module Api
222
232
  value
223
233
  end
224
234
  end
235
+
225
236
  end
237
+
226
238
  end