jamm 1.2.1 → 1.3.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/jamm/api/api/payment_api.rb +61 -0
  4. data/lib/jamm/api/api/webhook_service_api.rb +59 -0
  5. data/lib/jamm/api/models/{v1_error.rb → apiv1_error.rb} +18 -9
  6. data/lib/jamm/api/models/v1_bank.rb +295 -0
  7. data/lib/jamm/api/models/v1_bank_assets.rb +231 -0
  8. data/lib/jamm/api/models/v1_bank_branch.rb +232 -0
  9. data/lib/jamm/api/models/v1_bank_information.rb +35 -7
  10. data/lib/jamm/api/models/v1_bank_quota.rb +243 -0
  11. data/lib/jamm/api/models/v1_bank_scheduled_maintenance_period.rb +227 -0
  12. data/lib/jamm/api/models/v1_charge_message.rb +1 -1
  13. data/lib/jamm/api/models/v1_deposit_type.rb +42 -0
  14. data/lib/jamm/api/models/v1_error_detail.rb +220 -0
  15. data/lib/jamm/api/models/v1_error_response.rb +230 -0
  16. data/lib/jamm/api/models/v1_error_type.rb +58 -0
  17. data/lib/jamm/api/models/v1_event_type.rb +2 -1
  18. data/lib/jamm/api/models/v1_get_bank_response.rb +207 -0
  19. data/lib/jamm/api/models/v1_get_branch_response.rb +207 -0
  20. data/lib/jamm/api/models/v1_get_branches_response.rb +208 -0
  21. data/lib/jamm/api/models/v1_get_major_banks_response.rb +217 -0
  22. data/lib/jamm/api/models/v1_message_response.rb +12 -7
  23. data/lib/jamm/api/models/v1_on_session_payment_data.rb +222 -0
  24. data/lib/jamm/api/models/v1_on_session_payment_error.rb +237 -0
  25. data/lib/jamm/api/models/v1_on_session_payment_error_code.rb +49 -0
  26. data/lib/jamm/api/models/v1_on_session_payment_request.rb +223 -0
  27. data/lib/jamm/api/models/v1_on_session_payment_response.rb +218 -0
  28. data/lib/jamm/api/models/v1_search_banks_response.rb +208 -0
  29. data/lib/jamm/api/models/v1_search_branches_response.rb +208 -0
  30. data/lib/jamm/api/models/v1_user_account_message.rb +223 -0
  31. data/lib/jamm/api.rb +22 -1
  32. data/lib/jamm/customer.rb +0 -2
  33. data/lib/jamm/errors.rb +27 -1
  34. data/lib/jamm/version.rb +1 -1
  35. metadata +24 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afa7b2f5a3762d463b26345bff77488597b3941dceb65ee6f9a0fa16638c02a8
4
- data.tar.gz: 02be4ae94c06829f9932630417ee6151c1bcc89313582fc73cb1d3b87b0c8997
3
+ metadata.gz: 6a423a794eba976458fa7a8d228a076e9a0c072c533bd4065f5d4ee577c97adb
4
+ data.tar.gz: 7e5ec327e98cd761e98d28a039c0133655cda76581f18a50d7d6a85cebb2ef9d
5
5
  SHA512:
6
- metadata.gz: eee877ac3ebff328de9ca1f5d05befe67ecd982a8e8a4c3bfa6cdd1e3827f5b42e822be23e90839674e8909c5a62afe56ebb11a176e02c74643147e6791fde67
7
- data.tar.gz: 18fabb3a90d641390efbfb12c4d4e4022e69ee828ef5f9dc6bbd6398de69c67bfc4bee3f50e5b1a5115477d1b417fdd17c05d2f3bf6cb64a5269cbd706f72eb6
6
+ metadata.gz: 37a0dea3f792eceb212e665d46f6803db7a3ab3a672c70a2ec92f38f99213fcbd919804b3b68e360af3dd6937e4704b21891376f9bb735133f7cf0f4046235cd
7
+ data.tar.gz: 439ef09ced775b1655f9c4dd1139d6dd4bbcd28183ff7c99af148edd2a796a35c2fb52768b78526b814116501890d054afdd782e2e8be5bc28b9e0678b29a557
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jamm (1.2.1)
4
+ jamm (1.3.0)
5
5
  rest-client (~> 2.0)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
@@ -386,6 +386,67 @@ module Api
386
386
  [data, status_code, headers]
387
387
  end
388
388
 
389
+ # Process payment with optional redirect
390
+ # Unified interface for creating payments - supports existing customers, new customers with charges, and contract-only creation.
391
+ # @param body [OnSessionPaymentRequest] Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters.
392
+ # @param [Hash] opts the optional parameters
393
+ # @return [OnSessionPaymentResponse]
394
+ def on_session_payment(body, opts = {})
395
+ data, _status_code, _headers = on_session_payment_with_http_info(body, opts)
396
+ data
397
+ end
398
+
399
+ # Process payment with optional redirect
400
+ # Unified interface for creating payments - supports existing customers, new customers with charges, and contract-only creation.
401
+ # @param body [OnSessionPaymentRequest] Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters.
402
+ # @param [Hash] opts the optional parameters
403
+ # @return [Array<(OnSessionPaymentResponse, Integer, Hash)>] OnSessionPaymentResponse data, response status code and response headers
404
+ def on_session_payment_with_http_info(body, opts = {})
405
+ @api_client.config.logger.debug 'Calling API: PaymentApi.on_session_payment ...' if @api_client.config.debugging
406
+ # verify the required parameter 'body' is set
407
+ raise ArgumentError, "Missing the required parameter 'body' when calling PaymentApi.on_session_payment" if @api_client.config.client_side_validation && body.nil?
408
+
409
+ # resource path
410
+ local_var_path = '/v1/payments/on-session'
411
+
412
+ # query parameters
413
+ query_params = opts[:query_params] || {}
414
+
415
+ # header parameters
416
+ header_params = opts[:header_params] || {}
417
+ # HTTP header 'Accept' (if needed)
418
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
419
+ # HTTP header 'Content-Type'
420
+ content_type = @api_client.select_header_content_type(['application/json'])
421
+ header_params['Content-Type'] = content_type unless content_type.nil?
422
+
423
+ # form parameters
424
+ form_params = opts[:form_params] || {}
425
+
426
+ # http body (model)
427
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
428
+
429
+ # return_type
430
+ return_type = opts[:debug_return_type] || 'OnSessionPaymentResponse'
431
+
432
+ # auth_names
433
+ auth_names = opts[:debug_auth_names] || []
434
+
435
+ new_options = opts.merge(
436
+ :operation => :"PaymentApi.on_session_payment",
437
+ :header_params => header_params,
438
+ :query_params => query_params,
439
+ :form_params => form_params,
440
+ :body => post_body,
441
+ :auth_names => auth_names,
442
+ :return_type => return_type
443
+ )
444
+
445
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
446
+ @api_client.config.logger.debug "API called: PaymentApi#on_session_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" if @api_client.config.debugging
447
+ [data, status_code, headers]
448
+ end
449
+
389
450
  # Withdraw money from customer immediately, without redirect
390
451
  # This call is synchronous. The money will be withdrawn immediately.
391
452
  # @param body [WithdrawRequest] This message represents a request to withdraw money from a customer. It contains the customer ID and the amount to withdraw.
@@ -20,6 +20,65 @@ module Api
20
20
  @api_client = api_client
21
21
  end
22
22
 
23
+ # Error placeholder. This method is not implemented on Jamm backend.
24
+ # @param body [Object]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [ErrorResponse]
27
+ def webhook_service_error(body, opts = {})
28
+ data, _status_code, _headers = webhook_service_error_with_http_info(body, opts)
29
+ data
30
+ end
31
+
32
+ # Error placeholder. This method is not implemented on Jamm backend.
33
+ # @param body [Object]
34
+ # @param [Hash] opts the optional parameters
35
+ # @return [Array<(ErrorResponse, Integer, Hash)>] ErrorResponse data, response status code and response headers
36
+ def webhook_service_error_with_http_info(body, opts = {})
37
+ @api_client.config.logger.debug 'Calling API: WebhookServiceApi.webhook_service_error ...' if @api_client.config.debugging
38
+ # verify the required parameter 'body' is set
39
+ raise ArgumentError, "Missing the required parameter 'body' when calling WebhookServiceApi.webhook_service_error" if @api_client.config.client_side_validation && body.nil?
40
+
41
+ # resource path
42
+ local_var_path = '/errors'
43
+
44
+ # query parameters
45
+ query_params = opts[:query_params] || {}
46
+
47
+ # header parameters
48
+ header_params = opts[:header_params] || {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
51
+ # HTTP header 'Content-Type'
52
+ content_type = @api_client.select_header_content_type(['application/json'])
53
+ header_params['Content-Type'] = content_type unless content_type.nil?
54
+
55
+ # form parameters
56
+ form_params = opts[:form_params] || {}
57
+
58
+ # http body (model)
59
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
60
+
61
+ # return_type
62
+ return_type = opts[:debug_return_type] || 'ErrorResponse'
63
+
64
+ # auth_names
65
+ auth_names = opts[:debug_auth_names] || []
66
+
67
+ new_options = opts.merge(
68
+ :operation => :"WebhookServiceApi.webhook_service_error",
69
+ :header_params => header_params,
70
+ :query_params => query_params,
71
+ :form_params => form_params,
72
+ :body => post_body,
73
+ :auth_names => auth_names,
74
+ :return_type => return_type
75
+ )
76
+
77
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
78
+ @api_client.config.logger.debug "API called: WebhookServiceApi#webhook_service_error\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" if @api_client.config.debugging
79
+ [data, status_code, headers]
80
+ end
81
+
23
82
  # Message placeholder. This method is not implemented on Jamm backend.
24
83
  # @param body [Object]
25
84
  # @param [Hash] opts the optional parameters
@@ -15,18 +15,22 @@ require 'time'
15
15
 
16
16
  module Api
17
17
  # Generic error type.
18
- class Error
18
+ class Apiv1Error
19
19
  # Jamm defined error code.
20
20
  attr_accessor :code
21
21
 
22
22
  # Human readable error message.
23
23
  attr_accessor :message
24
24
 
25
+ # ConnectRPC error details.
26
+ attr_accessor :details
27
+
25
28
  # Attribute mapping from ruby-style variable name to JSON key.
26
29
  def self.attribute_map
27
30
  {
28
31
  :code => :code,
29
- :message => :message
32
+ :message => :message,
33
+ :details => :details
30
34
  }
31
35
  end
32
36
 
@@ -39,7 +43,8 @@ module Api
39
43
  def self.openapi_types
40
44
  {
41
45
  :code => :String,
42
- :message => :String
46
+ :message => :String,
47
+ :details => :'Array<ErrorDetail>'
43
48
  }
44
49
  end
45
50
 
@@ -51,20 +56,23 @@ module Api
51
56
  # Initializes the object
52
57
  # @param [Hash] attributes Model attributes in the form of hash
53
58
  def initialize(attributes = {})
54
- raise ArgumentError, 'The input argument (attributes) must be a hash in `Api::Error` initialize method' unless attributes.is_a?(Hash)
59
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Api::Apiv1Error` initialize method' unless attributes.is_a?(Hash)
55
60
 
56
61
  # check to see if the attribute exists and convert string to symbol for hash key
57
62
  attributes = attributes.each_with_object({}) do |(k, v), h|
58
- raise ArgumentError, "`#{k}` is not a valid attribute in `Api::Error`. 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)
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)
59
64
 
60
65
  h[k.to_sym] = v
61
66
  end
62
67
 
63
68
  self.code = attributes[:code] if attributes.key?(:code)
64
69
 
65
- return unless attributes.key?(:message)
70
+ self.message = attributes[:message] if attributes.key?(:message)
71
+
72
+ return unless attributes.key?(:details)
73
+ return unless (value = attributes[:details]).is_a?(Array)
66
74
 
67
- self.message = attributes[:message]
75
+ self.details = value
68
76
  end
69
77
 
70
78
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -88,7 +96,8 @@ module Api
88
96
 
89
97
  self.class == other.class &&
90
98
  code == other.code &&
91
- message == other.message
99
+ message == other.message &&
100
+ details == other.details
92
101
  end
93
102
 
94
103
  # @see the `==` method
@@ -100,7 +109,7 @@ module Api
100
109
  # Calculates hash code according to all attributes.
101
110
  # @return [Integer] Hash code
102
111
  def hash
103
- [code, message].hash
112
+ [code, message, details].hash
104
113
  end
105
114
 
106
115
  # Builds the object from hash
@@ -0,0 +1,295 @@
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
+ #
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Api
17
+ class Bank
18
+ attr_accessor :code, :name, :name_katakana, :name_hiragana, :name_alphabet, :assets, :quota, :opening_hours, :bankpay_scheduled_maintenances, :bank_scheduled_maintenances, :registration_scheduled_maintenances
19
+
20
+ # True when Bankpay is currently available.
21
+ attr_accessor :bankpay_available
22
+
23
+ # True when Bank is currently available.
24
+ attr_accessor :bank_available
25
+
26
+ # True when registration is currently available.
27
+ attr_accessor :registration_available
28
+
29
+ # True when bank is operating, false when its not. Core UI is expected to navigate user to out-of-service page when this flag is set to false. See Figma for more information: https://www.figma.com/design/7cabcqjzvKl9IwzvJCuQEW/Jamm-%CE%B2-UI-design?node-id=304-11253&t=oyEUrdVtFOMV9xut-4
30
+ attr_accessor :operating
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :code => :code,
36
+ :name => :name,
37
+ :name_katakana => :nameKatakana,
38
+ :name_hiragana => :nameHiragana,
39
+ :name_alphabet => :nameAlphabet,
40
+ :assets => :assets,
41
+ :quota => :quota,
42
+ :opening_hours => :openingHours,
43
+ :bankpay_scheduled_maintenances => :bankpayScheduledMaintenances,
44
+ :bank_scheduled_maintenances => :bankScheduledMaintenances,
45
+ :registration_scheduled_maintenances => :registrationScheduledMaintenances,
46
+ :bankpay_available => :bankpayAvailable,
47
+ :bank_available => :bankAvailable,
48
+ :registration_available => :registrationAvailable,
49
+ :operating => :operating
50
+ }
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :code => :String,
62
+ :name => :String,
63
+ :name_katakana => :String,
64
+ :name_hiragana => :String,
65
+ :name_alphabet => :String,
66
+ :assets => :BankAssets,
67
+ :quota => :BankQuota,
68
+ :opening_hours => :String,
69
+ :bankpay_scheduled_maintenances => :'Array<BankScheduledMaintenancePeriod>',
70
+ :bank_scheduled_maintenances => :'Array<BankScheduledMaintenancePeriod>',
71
+ :registration_scheduled_maintenances => :'Array<BankScheduledMaintenancePeriod>',
72
+ :bankpay_available => :Boolean,
73
+ :bank_available => :Boolean,
74
+ :registration_available => :Boolean,
75
+ :operating => :Boolean
76
+ }
77
+ end
78
+
79
+ # List of attributes with nullable: true
80
+ def self.openapi_nullable
81
+ Set.new([])
82
+ end
83
+
84
+ # Initializes the object
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ def initialize(attributes = {})
87
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Api::Bank` initialize method' unless attributes.is_a?(Hash)
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) do |(k, v), h|
91
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Api::Bank`. 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)
92
+
93
+ h[k.to_sym] = v
94
+ end
95
+
96
+ self.code = attributes[:code] if attributes.key?(:code)
97
+
98
+ self.name = attributes[:name] if attributes.key?(:name)
99
+
100
+ self.name_katakana = attributes[:name_katakana] if attributes.key?(:name_katakana)
101
+
102
+ self.name_hiragana = attributes[:name_hiragana] if attributes.key?(:name_hiragana)
103
+
104
+ self.name_alphabet = attributes[:name_alphabet] if attributes.key?(:name_alphabet)
105
+
106
+ self.assets = attributes[:assets] if attributes.key?(:assets)
107
+
108
+ self.quota = attributes[:quota] if attributes.key?(:quota)
109
+
110
+ self.opening_hours = attributes[:opening_hours] if attributes.key?(:opening_hours)
111
+
112
+ if attributes.key?(:bankpay_scheduled_maintenances) && (value = attributes[:bankpay_scheduled_maintenances]).is_a?(Array)
113
+ self.bankpay_scheduled_maintenances = value
114
+ end
115
+
116
+ if attributes.key?(:bank_scheduled_maintenances) && (value = attributes[:bank_scheduled_maintenances]).is_a?(Array)
117
+ self.bank_scheduled_maintenances = value
118
+ end
119
+
120
+ if attributes.key?(:registration_scheduled_maintenances) && (value = attributes[:registration_scheduled_maintenances]).is_a?(Array)
121
+ self.registration_scheduled_maintenances = value
122
+ end
123
+
124
+ self.bankpay_available = attributes[:bankpay_available] if attributes.key?(:bankpay_available)
125
+
126
+ self.bank_available = attributes[:bank_available] if attributes.key?(:bank_available)
127
+
128
+ self.registration_available = attributes[:registration_available] if attributes.key?(:registration_available)
129
+
130
+ return unless attributes.key?(:operating)
131
+
132
+ self.operating = attributes[:operating]
133
+ end
134
+
135
+ # Show invalid properties with the reasons. Usually used together with valid?
136
+ # @return Array for valid properties with the reasons
137
+ def list_invalid_properties
138
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
139
+ []
140
+ end
141
+
142
+ # Check to see if the all the properties in the model are valid
143
+ # @return true if the model is valid
144
+ def valid?
145
+ warn '[DEPRECATED] the `valid?` method is obsolete'
146
+ true
147
+ end
148
+
149
+ # Checks equality by comparing each attribute.
150
+ # @param [Object] Object to be compared
151
+ def ==(other)
152
+ return true if equal?(other)
153
+
154
+ self.class == other.class &&
155
+ code == other.code &&
156
+ name == other.name &&
157
+ name_katakana == other.name_katakana &&
158
+ name_hiragana == other.name_hiragana &&
159
+ name_alphabet == other.name_alphabet &&
160
+ assets == other.assets &&
161
+ quota == other.quota &&
162
+ opening_hours == other.opening_hours &&
163
+ bankpay_scheduled_maintenances == other.bankpay_scheduled_maintenances &&
164
+ bank_scheduled_maintenances == other.bank_scheduled_maintenances &&
165
+ registration_scheduled_maintenances == other.registration_scheduled_maintenances &&
166
+ bankpay_available == other.bankpay_available &&
167
+ bank_available == other.bank_available &&
168
+ registration_available == other.registration_available &&
169
+ operating == other.operating
170
+ end
171
+
172
+ # @see the `==` method
173
+ # @param [Object] Object to be compared
174
+ def eql?(other)
175
+ self == other
176
+ end
177
+
178
+ # Calculates hash code according to all attributes.
179
+ # @return [Integer] Hash code
180
+ def hash
181
+ [code, name, name_katakana, name_hiragana, name_alphabet, assets, quota, opening_hours, bankpay_scheduled_maintenances, bank_scheduled_maintenances, registration_scheduled_maintenances, bankpay_available, bank_available, registration_available, operating].hash
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def self.build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+
190
+ attributes = attributes.transform_keys(&:to_sym)
191
+ transformed_hash = {}
192
+ openapi_types.each_pair do |key, type|
193
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
194
+ transformed_hash[key.to_s] = nil
195
+ elsif type =~ /\AArray<(.*)>/i
196
+ # check to ensure the input is an array given that the attribute
197
+ # is documented as an array but the input is not
198
+ 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)
199
+ elsif !attributes[attribute_map[key]].nil?
200
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
201
+ end
202
+ end
203
+ new(transformed_hash)
204
+ end
205
+
206
+ # Deserializes the data based on type
207
+ # @param string type Data type
208
+ # @param string value Value to be deserialized
209
+ # @return [Object] Deserialized data
210
+ def self._deserialize(type, value)
211
+ case type.to_sym
212
+ when :Time
213
+ Time.parse(value)
214
+ when :Date
215
+ Date.parse(value)
216
+ when :String
217
+ value.to_s
218
+ when :Integer
219
+ value.to_i
220
+ when :Float
221
+ value.to_f
222
+ when :Boolean
223
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
224
+ true
225
+ else
226
+ false
227
+ end
228
+ when :Object
229
+ # generic object (usually a Hash), return directly
230
+ value
231
+ when /\AArray<(?<inner_type>.+)>\z/
232
+ inner_type = Regexp.last_match[:inner_type]
233
+ value.map { |v| _deserialize(inner_type, v) }
234
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
235
+ k_type = Regexp.last_match[:k_type]
236
+ v_type = Regexp.last_match[:v_type]
237
+ {}.tap do |hash|
238
+ value.each do |k, v|
239
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
240
+ end
241
+ end
242
+ else # model
243
+ # models (e.g. Pet) or oneOf
244
+ klass = Api.const_get(type)
245
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
246
+ end
247
+ end
248
+
249
+ # Returns the string representation of the object
250
+ # @return [String] String presentation of the object
251
+ def to_s
252
+ to_hash.to_s
253
+ end
254
+
255
+ # to_body is an alias to to_hash (backward compatibility)
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_body
258
+ to_hash
259
+ end
260
+
261
+ # Returns the object in the form of hash
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_hash
264
+ hash = {}
265
+ self.class.attribute_map.each_pair do |attr, param|
266
+ value = send(attr)
267
+ if value.nil?
268
+ is_nullable = self.class.openapi_nullable.include?(attr)
269
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
270
+ end
271
+
272
+ hash[param] = _to_hash(value)
273
+ end
274
+ hash
275
+ end
276
+
277
+ # Outputs non-array value in the form of hash
278
+ # For object, use to_hash. Otherwise, just return the value
279
+ # @param [Object] value Any valid value
280
+ # @return [Hash] Returns the value in the form of hash
281
+ def _to_hash(value)
282
+ if value.is_a?(Array)
283
+ value.compact.map { |v| _to_hash(v) }
284
+ elsif value.is_a?(Hash)
285
+ {}.tap do |hash|
286
+ value.each { |k, v| hash[k] = _to_hash(v) }
287
+ end
288
+ elsif value.respond_to? :to_hash
289
+ value.to_hash
290
+ else
291
+ value
292
+ end
293
+ end
294
+ end
295
+ end