jamm 1.0.8 → 1.0.10

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +9 -1
  4. data/Rakefile +5 -0
  5. data/lib/jamm/api/api/customer_api.rb +68 -10
  6. data/lib/jamm/api/api/healthcheck_api.rb +2 -2
  7. data/lib/jamm/api/api/payment_api.rb +145 -20
  8. data/lib/jamm/api/api/webhook_service_api.rb +82 -0
  9. data/lib/jamm/api/api_client.rb +2 -2
  10. data/lib/jamm/api/api_error.rb +2 -2
  11. data/lib/jamm/api/configuration.rb +2 -2
  12. data/lib/jamm/api/models/customer_service_update_customer_body.rb +9 -4
  13. data/lib/jamm/api/models/{rpc_status.rb → googlerpc_status.rb} +5 -5
  14. data/lib/jamm/api/models/protobuf_any.rb +2 -2
  15. data/lib/jamm/api/models/v1_add_charge_request.rb +2 -2
  16. data/lib/jamm/api/models/v1_add_charge_response.rb +2 -2
  17. data/lib/jamm/api/models/v1_buyer.rb +11 -3
  18. data/lib/jamm/api/models/v1_charge.rb +2 -2
  19. data/lib/jamm/api/models/v1_charge_message.rb +297 -0
  20. data/lib/jamm/api/models/v1_charge_message_status.rb +44 -0
  21. data/lib/jamm/api/models/v1_charge_result.rb +285 -0
  22. data/lib/jamm/api/models/v1_contract.rb +2 -2
  23. data/lib/jamm/api/models/v1_contract_message.rb +222 -0
  24. data/lib/jamm/api/models/v1_contract_status.rb +2 -2
  25. data/lib/jamm/api/models/v1_create_contract_with_charge_request.rb +2 -2
  26. data/lib/jamm/api/models/v1_create_contract_with_charge_response.rb +2 -2
  27. data/lib/jamm/api/models/v1_create_contract_without_charge_request.rb +2 -2
  28. data/lib/jamm/api/models/v1_create_contract_without_charge_response.rb +2 -2
  29. data/lib/jamm/api/models/v1_create_customer_request.rb +2 -2
  30. data/lib/jamm/api/models/v1_create_customer_response.rb +2 -2
  31. data/lib/jamm/api/models/v1_customer.rb +9 -4
  32. data/lib/jamm/api/models/v1_delete_customer_response.rb +2 -2
  33. data/lib/jamm/api/models/v1_error.rb +217 -0
  34. data/lib/jamm/api/models/v1_event_type.rb +46 -0
  35. data/lib/jamm/api/models/v1_get_charge_response.rb +212 -0
  36. data/lib/jamm/api/models/v1_get_charges_response.rb +214 -0
  37. data/lib/jamm/api/models/v1_get_contract_response.rb +13 -13
  38. data/lib/jamm/api/models/v1_get_customer_response.rb +2 -2
  39. data/lib/jamm/api/models/v1_initial_charge.rb +2 -2
  40. data/lib/jamm/api/models/v1_merchant.rb +2 -2
  41. data/lib/jamm/api/models/v1_merchant_customer.rb +2 -2
  42. data/lib/jamm/api/models/v1_merchant_webhook_message.rb +259 -0
  43. data/lib/jamm/api/models/v1_message_response.rb +217 -0
  44. data/lib/jamm/api/models/v1_pagination.rb +212 -0
  45. data/lib/jamm/api/models/v1_payment_link.rb +2 -2
  46. data/lib/jamm/api/models/v1_ping_response.rb +2 -2
  47. data/lib/jamm/api/models/v1_update_customer_response.rb +2 -2
  48. data/lib/jamm/api/models/v1_url.rb +2 -2
  49. data/lib/jamm/api/models/v1_withdraw_request.rb +212 -0
  50. data/lib/jamm/api/models/v1_withdraw_response.rb +212 -0
  51. data/lib/jamm/api/version.rb +2 -2
  52. data/lib/jamm/api.rb +17 -3
  53. data/lib/jamm/api_patches.rb +14 -0
  54. data/lib/jamm/charge.rb +43 -0
  55. data/lib/jamm/client.rb +1 -1
  56. data/lib/jamm/contract.rb +35 -0
  57. data/lib/jamm/customer.rb +24 -9
  58. data/lib/jamm/healthcheck.rb +14 -0
  59. data/lib/jamm/openapi.rb +10 -0
  60. data/lib/jamm/version.rb +1 -1
  61. data/lib/jamm/webhook.rb +46 -0
  62. data/lib/jamm.rb +16 -14
  63. metadata +23 -4
  64. data/lib/jamm/payment.rb +0 -27
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # #api/v1/common.proto
3
+ # #Jamm API
4
4
  #
5
5
  # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
6
  #
7
- # The version of the OpenAPI document: version not set
7
+ # The version of the OpenAPI document: 1.0
8
8
  #
9
9
  # Generated by: https://openapi-generator.tech
10
10
  # Generator version: 7.9.0
@@ -15,13 +15,13 @@ require 'time'
15
15
 
16
16
  module Api
17
17
  class GetContractResponse
18
- attr_accessor :contract, :customer
18
+ attr_accessor :customer, :contract
19
19
 
20
20
  # Attribute mapping from ruby-style variable name to JSON key.
21
21
  def self.attribute_map
22
22
  {
23
- :contract => :contract,
24
- :customer => :customer
23
+ :customer => :customer,
24
+ :contract => :contract
25
25
  }
26
26
  end
27
27
 
@@ -33,8 +33,8 @@ module Api
33
33
  # Attribute type mapping.
34
34
  def self.openapi_types
35
35
  {
36
- :contract => :Contract,
37
- :customer => :Customer
36
+ :customer => :MerchantCustomer,
37
+ :contract => :Contract
38
38
  }
39
39
  end
40
40
 
@@ -55,11 +55,11 @@ module Api
55
55
  h[k.to_sym] = v
56
56
  end
57
57
 
58
- self.contract = attributes[:contract] if attributes.key?(:contract)
58
+ self.customer = attributes[:customer] if attributes.key?(:customer)
59
59
 
60
- return unless attributes.key?(:customer)
60
+ return unless attributes.key?(:contract)
61
61
 
62
- self.customer = attributes[:customer]
62
+ self.contract = attributes[:contract]
63
63
  end
64
64
 
65
65
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -82,8 +82,8 @@ module Api
82
82
  return true if equal?(other)
83
83
 
84
84
  self.class == other.class &&
85
- contract == other.contract &&
86
- customer == other.customer
85
+ customer == other.customer &&
86
+ contract == other.contract
87
87
  end
88
88
 
89
89
  # @see the `==` method
@@ -95,7 +95,7 @@ module Api
95
95
  # Calculates hash code according to all attributes.
96
96
  # @return [Integer] Hash code
97
97
  def hash
98
- [contract, customer].hash
98
+ [customer, contract].hash
99
99
  end
100
100
 
101
101
  # Builds the object from hash
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # #api/v1/common.proto
3
+ # #Jamm API
4
4
  #
5
5
  # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
6
  #
7
- # The version of the OpenAPI document: version not set
7
+ # The version of the OpenAPI document: 1.0
8
8
  #
9
9
  # Generated by: https://openapi-generator.tech
10
10
  # Generator version: 7.9.0
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # #api/v1/common.proto
3
+ # #Jamm API
4
4
  #
5
5
  # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
6
  #
7
- # The version of the OpenAPI document: version not set
7
+ # The version of the OpenAPI document: 1.0
8
8
  #
9
9
  # Generated by: https://openapi-generator.tech
10
10
  # Generator version: 7.9.0
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # #api/v1/common.proto
3
+ # #Jamm API
4
4
  #
5
5
  # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
6
  #
7
- # The version of the OpenAPI document: version not set
7
+ # The version of the OpenAPI document: 1.0
8
8
  #
9
9
  # Generated by: https://openapi-generator.tech
10
10
  # Generator version: 7.9.0
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # #api/v1/common.proto
3
+ # #Jamm API
4
4
  #
5
5
  # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
6
  #
7
- # The version of the OpenAPI document: version not set
7
+ # The version of the OpenAPI document: 1.0
8
8
  #
9
9
  # Generated by: https://openapi-generator.tech
10
10
  # Generator version: 7.9.0
@@ -0,0 +1,259 @@
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
+ # MerchantWebhookMessage is a generic message wrapper representing an event for a specific merchant.
18
+ class MerchantWebhookMessage
19
+ # Unique identifier for the webhook. It represents the message uniqueness, therefore it won't change when retried. Use this value to avoid processing the same message multiple times.
20
+ attr_accessor :id
21
+
22
+ # Signature of the message.
23
+ attr_accessor :signature
24
+
25
+ attr_accessor :event_type, :content, :created_at
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype, :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :id => :id,
52
+ :signature => :signature,
53
+ :event_type => :eventType,
54
+ :content => :content,
55
+ :created_at => :createdAt
56
+ }
57
+ end
58
+
59
+ # Returns all the JSON keys this model knows about
60
+ def self.acceptable_attributes
61
+ attribute_map.values
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.openapi_types
66
+ {
67
+ :id => :String,
68
+ :signature => :String,
69
+ :event_type => :EventType,
70
+ :content => :ProtobufAny,
71
+ :created_at => :Time
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Api::MerchantWebhookMessage` initialize method' unless attributes.is_a?(Hash)
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) do |(k, v), h|
87
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Api::MerchantWebhookMessage`. 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)
88
+
89
+ h[k.to_sym] = v
90
+ end
91
+
92
+ self.id = attributes[:id] if attributes.key?(:id)
93
+
94
+ self.signature = attributes[:signature] if attributes.key?(:signature)
95
+
96
+ self.event_type = if attributes.key?(:event_type)
97
+ attributes[:event_type]
98
+ else
99
+ 'EVENT_TYPE_UNSPECIFIED'
100
+ end
101
+
102
+ self.content = attributes[:content] if attributes.key?(:content)
103
+
104
+ return unless attributes.key?(:created_at)
105
+
106
+ self.created_at = attributes[:created_at]
107
+ end
108
+
109
+ # Show invalid properties with the reasons. Usually used together with valid?
110
+ # @return Array for valid properties with the reasons
111
+ def list_invalid_properties
112
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
113
+ []
114
+ end
115
+
116
+ # Check to see if the all the properties in the model are valid
117
+ # @return true if the model is valid
118
+ def valid?
119
+ warn '[DEPRECATED] the `valid?` method is obsolete'
120
+ true
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(other)
126
+ return true if equal?(other)
127
+
128
+ self.class == other.class &&
129
+ id == other.id &&
130
+ signature == other.signature &&
131
+ event_type == other.event_type &&
132
+ content == other.content &&
133
+ created_at == other.created_at
134
+ end
135
+
136
+ # @see the `==` method
137
+ # @param [Object] Object to be compared
138
+ def eql?(other)
139
+ self == other
140
+ end
141
+
142
+ # Calculates hash code according to all attributes.
143
+ # @return [Integer] Hash code
144
+ def hash
145
+ [id, signature, event_type, content, created_at].hash
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def self.build_from_hash(attributes)
152
+ return nil unless attributes.is_a?(Hash)
153
+
154
+ attributes = attributes.transform_keys(&:to_sym)
155
+ transformed_hash = {}
156
+ openapi_types.each_pair do |key, type|
157
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
158
+ transformed_hash[key.to_s] = nil
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ 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)
163
+ elsif !attributes[attribute_map[key]].nil?
164
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
165
+ end
166
+ end
167
+ new(transformed_hash)
168
+ end
169
+
170
+ # Deserializes the data based on type
171
+ # @param string type Data type
172
+ # @param string value Value to be deserialized
173
+ # @return [Object] Deserialized data
174
+ def self._deserialize(type, value)
175
+ case type.to_sym
176
+ when :Time
177
+ Time.parse(value)
178
+ when :Date
179
+ Date.parse(value)
180
+ when :String
181
+ value.to_s
182
+ when :Integer
183
+ value.to_i
184
+ when :Float
185
+ value.to_f
186
+ when :Boolean
187
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
188
+ true
189
+ else
190
+ false
191
+ end
192
+ when :Object
193
+ # generic object (usually a Hash), return directly
194
+ value
195
+ when /\AArray<(?<inner_type>.+)>\z/
196
+ inner_type = Regexp.last_match[:inner_type]
197
+ value.map { |v| _deserialize(inner_type, v) }
198
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
199
+ k_type = Regexp.last_match[:k_type]
200
+ v_type = Regexp.last_match[:v_type]
201
+ {}.tap do |hash|
202
+ value.each do |k, v|
203
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
204
+ end
205
+ end
206
+ else # model
207
+ # models (e.g. Pet) or oneOf
208
+ klass = Api.const_get(type)
209
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+ end
259
+ end
@@ -0,0 +1,217 @@
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 MessageResponse
18
+ attr_accessor :merchant_webhook_message, :charge_message, :contract_message
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :merchant_webhook_message => :merchantWebhookMessage,
24
+ :charge_message => :chargeMessage,
25
+ :contract_message => :contractMessage
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :merchant_webhook_message => :MerchantWebhookMessage,
38
+ :charge_message => :ChargeMessage,
39
+ :contract_message => :ContractMessage
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Api::MessageResponse` initialize method' unless attributes.is_a?(Hash)
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) do |(k, v), h|
55
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Api::MessageResponse`. 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)
56
+
57
+ h[k.to_sym] = v
58
+ end
59
+
60
+ self.merchant_webhook_message = attributes[:merchant_webhook_message] if attributes.key?(:merchant_webhook_message)
61
+
62
+ self.charge_message = attributes[:charge_message] if attributes.key?(:charge_message)
63
+
64
+ return unless attributes.key?(:contract_message)
65
+
66
+ self.contract_message = attributes[:contract_message]
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
73
+ []
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ warn '[DEPRECATED] the `valid?` method is obsolete'
80
+ true
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
85
+ def ==(other)
86
+ return true if equal?(other)
87
+
88
+ self.class == other.class &&
89
+ merchant_webhook_message == other.merchant_webhook_message &&
90
+ charge_message == other.charge_message &&
91
+ contract_message == other.contract_message
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(other)
97
+ self == other
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Integer] Hash code
102
+ def hash
103
+ [merchant_webhook_message, charge_message, contract_message].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def self.build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash[key.to_s] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ 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)
121
+ elsif !attributes[attribute_map[key]].nil?
122
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
123
+ end
124
+ end
125
+ new(transformed_hash)
126
+ end
127
+
128
+ # Deserializes the data based on type
129
+ # @param string type Data type
130
+ # @param string value Value to be deserialized
131
+ # @return [Object] Deserialized data
132
+ def self._deserialize(type, value)
133
+ case type.to_sym
134
+ when :Time
135
+ Time.parse(value)
136
+ when :Date
137
+ Date.parse(value)
138
+ when :String
139
+ value.to_s
140
+ when :Integer
141
+ value.to_i
142
+ when :Float
143
+ value.to_f
144
+ when :Boolean
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ # models (e.g. Pet) or oneOf
166
+ klass = Api.const_get(type)
167
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ end