jamm 1.2.2 → 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 (84) 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 +91 -19
  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 +238 -0
  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 +350 -0
  18. data/lib/jamm/api/models/v1_bank_assets.rb +244 -0
  19. data/lib/jamm/api/models/v1_bank_branch.rb +259 -0
  20. data/lib/jamm/api/models/v1_bank_information.rb +71 -51
  21. data/lib/jamm/api/models/v1_bank_quota.rb +278 -0
  22. data/lib/jamm/api/models/v1_bank_scheduled_maintenance_period.rb +250 -0
  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 +233 -0
  41. data/lib/jamm/api/models/v1_error_response.rb +238 -0
  42. data/lib/jamm/api/models/v1_error_type.rb +57 -0
  43. data/lib/jamm/api/models/v1_event_type.rb +20 -21
  44. data/lib/jamm/api/models/{v1_error.rb → v1_get_bank_response.rb} +45 -48
  45. data/lib/jamm/api/models/v1_get_branch_response.rb +214 -0
  46. data/lib/jamm/api/models/v1_get_branches_response.rb +216 -0
  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 +232 -0
  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 +216 -0
  70. data/lib/jamm/api/models/v1_search_branches_response.rb +216 -0
  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 +25 -11
  78. data/lib/jamm/charge.rb +12 -0
  79. data/lib/jamm/deprecation.rb +13 -0
  80. data/lib/jamm/errors.rb +27 -1
  81. data/lib/jamm/payment.rb +61 -0
  82. data/lib/jamm/version.rb +1 -1
  83. data/lib/jamm.rb +2 -0
  84. metadata +19 -3
@@ -0,0 +1,278 @@
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
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Api
17
+ # See Google Spreadsheet for more information: https://docs.google.com/spreadsheets/d/1sxklqXzTGt-E7FgXB801d12Az8pbpZgs/edit?gid=1684227518#gid=1684227518
18
+ class BankQuota
19
+ attr_accessor :offline_purchase_limit_per_charge_with_kyc
20
+
21
+ attr_accessor :offline_purchase_limit_per_charge_without_kyc
22
+
23
+ attr_accessor :offline_purchase_limit_per_day_with_kyc
24
+
25
+ attr_accessor :offline_purchase_limit_per_day_without_kyc
26
+
27
+ attr_accessor :subscription_purchase_limit_per_charge_with_kyc
28
+
29
+ attr_accessor :subscription_purchase_limit_per_charge_without_kyc
30
+
31
+ attr_accessor :subscription_purchase_limit_per_day_with_kyc
32
+
33
+ attr_accessor :subscription_purchase_limit_per_day_without_kyc
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'offline_purchase_limit_per_charge_with_kyc' => :'offlinePurchaseLimitPerChargeWithKyc',
39
+ :'offline_purchase_limit_per_charge_without_kyc' => :'offlinePurchaseLimitPerChargeWithoutKyc',
40
+ :'offline_purchase_limit_per_day_with_kyc' => :'offlinePurchaseLimitPerDayWithKyc',
41
+ :'offline_purchase_limit_per_day_without_kyc' => :'offlinePurchaseLimitPerDayWithoutKyc',
42
+ :'subscription_purchase_limit_per_charge_with_kyc' => :'subscriptionPurchaseLimitPerChargeWithKyc',
43
+ :'subscription_purchase_limit_per_charge_without_kyc' => :'subscriptionPurchaseLimitPerChargeWithoutKyc',
44
+ :'subscription_purchase_limit_per_day_with_kyc' => :'subscriptionPurchaseLimitPerDayWithKyc',
45
+ :'subscription_purchase_limit_per_day_without_kyc' => :'subscriptionPurchaseLimitPerDayWithoutKyc'
46
+ }
47
+ end
48
+
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ attribute_map.values
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'offline_purchase_limit_per_charge_with_kyc' => :'Integer',
58
+ :'offline_purchase_limit_per_charge_without_kyc' => :'Integer',
59
+ :'offline_purchase_limit_per_day_with_kyc' => :'Integer',
60
+ :'offline_purchase_limit_per_day_without_kyc' => :'Integer',
61
+ :'subscription_purchase_limit_per_charge_with_kyc' => :'Integer',
62
+ :'subscription_purchase_limit_per_charge_without_kyc' => :'Integer',
63
+ :'subscription_purchase_limit_per_day_with_kyc' => :'Integer',
64
+ :'subscription_purchase_limit_per_day_without_kyc' => :'Integer'
65
+ }
66
+ end
67
+
68
+ # List of attributes with nullable: true
69
+ def self.openapi_nullable
70
+ Set.new([
71
+ ])
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Api::BankQuota` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Api::BankQuota`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'offline_purchase_limit_per_charge_with_kyc')
90
+ self.offline_purchase_limit_per_charge_with_kyc = attributes[:'offline_purchase_limit_per_charge_with_kyc']
91
+ end
92
+
93
+ if attributes.key?(:'offline_purchase_limit_per_charge_without_kyc')
94
+ self.offline_purchase_limit_per_charge_without_kyc = attributes[:'offline_purchase_limit_per_charge_without_kyc']
95
+ end
96
+
97
+ if attributes.key?(:'offline_purchase_limit_per_day_with_kyc')
98
+ self.offline_purchase_limit_per_day_with_kyc = attributes[:'offline_purchase_limit_per_day_with_kyc']
99
+ end
100
+
101
+ if attributes.key?(:'offline_purchase_limit_per_day_without_kyc')
102
+ self.offline_purchase_limit_per_day_without_kyc = attributes[:'offline_purchase_limit_per_day_without_kyc']
103
+ end
104
+
105
+ if attributes.key?(:'subscription_purchase_limit_per_charge_with_kyc')
106
+ self.subscription_purchase_limit_per_charge_with_kyc = attributes[:'subscription_purchase_limit_per_charge_with_kyc']
107
+ end
108
+
109
+ if attributes.key?(:'subscription_purchase_limit_per_charge_without_kyc')
110
+ self.subscription_purchase_limit_per_charge_without_kyc = attributes[:'subscription_purchase_limit_per_charge_without_kyc']
111
+ end
112
+
113
+ if attributes.key?(:'subscription_purchase_limit_per_day_with_kyc')
114
+ self.subscription_purchase_limit_per_day_with_kyc = attributes[:'subscription_purchase_limit_per_day_with_kyc']
115
+ end
116
+
117
+ if attributes.key?(:'subscription_purchase_limit_per_day_without_kyc')
118
+ self.subscription_purchase_limit_per_day_without_kyc = attributes[:'subscription_purchase_limit_per_day_without_kyc']
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
126
+ invalid_properties = Array.new
127
+ invalid_properties
128
+ end
129
+
130
+ # Check to see if the all the properties in the model are valid
131
+ # @return true if the model is valid
132
+ def valid?
133
+ warn '[DEPRECATED] the `valid?` method is obsolete'
134
+ true
135
+ end
136
+
137
+ # Checks equality by comparing each attribute.
138
+ # @param [Object] Object to be compared
139
+ def ==(o)
140
+ return true if self.equal?(o)
141
+ self.class == o.class &&
142
+ offline_purchase_limit_per_charge_with_kyc == o.offline_purchase_limit_per_charge_with_kyc &&
143
+ offline_purchase_limit_per_charge_without_kyc == o.offline_purchase_limit_per_charge_without_kyc &&
144
+ offline_purchase_limit_per_day_with_kyc == o.offline_purchase_limit_per_day_with_kyc &&
145
+ offline_purchase_limit_per_day_without_kyc == o.offline_purchase_limit_per_day_without_kyc &&
146
+ subscription_purchase_limit_per_charge_with_kyc == o.subscription_purchase_limit_per_charge_with_kyc &&
147
+ subscription_purchase_limit_per_charge_without_kyc == o.subscription_purchase_limit_per_charge_without_kyc &&
148
+ subscription_purchase_limit_per_day_with_kyc == o.subscription_purchase_limit_per_day_with_kyc &&
149
+ subscription_purchase_limit_per_day_without_kyc == o.subscription_purchase_limit_per_day_without_kyc
150
+ end
151
+
152
+ # @see the `==` method
153
+ # @param [Object] Object to be compared
154
+ def eql?(o)
155
+ self == o
156
+ end
157
+
158
+ # Calculates hash code according to all attributes.
159
+ # @return [Integer] Hash code
160
+ def hash
161
+ [offline_purchase_limit_per_charge_with_kyc, offline_purchase_limit_per_charge_without_kyc, offline_purchase_limit_per_day_with_kyc, offline_purchase_limit_per_day_without_kyc, subscription_purchase_limit_per_charge_with_kyc, subscription_purchase_limit_per_charge_without_kyc, subscription_purchase_limit_per_day_with_kyc, subscription_purchase_limit_per_day_without_kyc].hash
162
+ end
163
+
164
+ # Builds the object from hash
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ # @return [Object] Returns the model itself
167
+ def self.build_from_hash(attributes)
168
+ return nil unless attributes.is_a?(Hash)
169
+ attributes = attributes.transform_keys(&:to_sym)
170
+ transformed_hash = {}
171
+ openapi_types.each_pair do |key, type|
172
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
173
+ transformed_hash["#{key}"] = nil
174
+ elsif type =~ /\AArray<(.*)>/i
175
+ # check to ensure the input is an array given that the attribute
176
+ # is documented as an array but the input is not
177
+ if attributes[attribute_map[key]].is_a?(Array)
178
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
179
+ end
180
+ elsif !attributes[attribute_map[key]].nil?
181
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
182
+ end
183
+ end
184
+ new(transformed_hash)
185
+ end
186
+
187
+ # Deserializes the data based on type
188
+ # @param string type Data type
189
+ # @param string value Value to be deserialized
190
+ # @return [Object] Deserialized data
191
+ def self._deserialize(type, value)
192
+ case type.to_sym
193
+ when :Time
194
+ Time.parse(value)
195
+ when :Date
196
+ Date.parse(value)
197
+ when :String
198
+ value.to_s
199
+ when :Integer
200
+ value.to_i
201
+ when :Float
202
+ value.to_f
203
+ when :Boolean
204
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
205
+ true
206
+ else
207
+ false
208
+ end
209
+ when :Object
210
+ # generic object (usually a Hash), return directly
211
+ value
212
+ when /\AArray<(?<inner_type>.+)>\z/
213
+ inner_type = Regexp.last_match[:inner_type]
214
+ value.map { |v| _deserialize(inner_type, v) }
215
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
216
+ k_type = Regexp.last_match[:k_type]
217
+ v_type = Regexp.last_match[:v_type]
218
+ {}.tap do |hash|
219
+ value.each do |k, v|
220
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
221
+ end
222
+ end
223
+ else # model
224
+ # models (e.g. Pet) or oneOf
225
+ klass = Api.const_get(type)
226
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
227
+ end
228
+ end
229
+
230
+ # Returns the string representation of the object
231
+ # @return [String] String presentation of the object
232
+ def to_s
233
+ to_hash.to_s
234
+ end
235
+
236
+ # to_body is an alias to to_hash (backward compatibility)
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_body
239
+ to_hash
240
+ end
241
+
242
+ # Returns the object in the form of hash
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_hash
245
+ hash = {}
246
+ self.class.attribute_map.each_pair do |attr, param|
247
+ value = self.send(attr)
248
+ if value.nil?
249
+ is_nullable = self.class.openapi_nullable.include?(attr)
250
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
251
+ end
252
+
253
+ hash[param] = _to_hash(value)
254
+ end
255
+ hash
256
+ end
257
+
258
+ # Outputs non-array value in the form of hash
259
+ # For object, use to_hash. Otherwise, just return the value
260
+ # @param [Object] value Any valid value
261
+ # @return [Hash] Returns the value in the form of hash
262
+ def _to_hash(value)
263
+ if value.is_a?(Array)
264
+ value.compact.map { |v| _to_hash(v) }
265
+ elsif value.is_a?(Hash)
266
+ {}.tap do |hash|
267
+ value.each { |k, v| hash[k] = _to_hash(v) }
268
+ end
269
+ elsif value.respond_to? :to_hash
270
+ value.to_hash
271
+ else
272
+ value
273
+ end
274
+ end
275
+
276
+ end
277
+
278
+ end
@@ -0,0 +1,250 @@
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
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Api
17
+ class BankScheduledMaintenancePeriod
18
+ attr_accessor :bank_code
19
+
20
+ attr_accessor :start_at_jst
21
+
22
+ attr_accessor :end_at_jst
23
+
24
+ attr_accessor :start_at_utc
25
+
26
+ attr_accessor :end_at_utc
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'bank_code' => :'bankCode',
32
+ :'start_at_jst' => :'startAtJst',
33
+ :'end_at_jst' => :'endAtJst',
34
+ :'start_at_utc' => :'startAtUtc',
35
+ :'end_at_utc' => :'endAtUtc'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'bank_code' => :'String',
48
+ :'start_at_jst' => :'String',
49
+ :'end_at_jst' => :'String',
50
+ :'start_at_utc' => :'String',
51
+ :'end_at_utc' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Api::BankScheduledMaintenancePeriod` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Api::BankScheduledMaintenancePeriod`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'bank_code')
77
+ self.bank_code = attributes[:'bank_code']
78
+ end
79
+
80
+ if attributes.key?(:'start_at_jst')
81
+ self.start_at_jst = attributes[:'start_at_jst']
82
+ end
83
+
84
+ if attributes.key?(:'end_at_jst')
85
+ self.end_at_jst = attributes[:'end_at_jst']
86
+ end
87
+
88
+ if attributes.key?(:'start_at_utc')
89
+ self.start_at_utc = attributes[:'start_at_utc']
90
+ end
91
+
92
+ if attributes.key?(:'end_at_utc')
93
+ self.end_at_utc = attributes[:'end_at_utc']
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
101
+ invalid_properties = Array.new
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ warn '[DEPRECATED] the `valid?` method is obsolete'
109
+ true
110
+ end
111
+
112
+ # Checks equality by comparing each attribute.
113
+ # @param [Object] Object to be compared
114
+ def ==(o)
115
+ return true if self.equal?(o)
116
+ self.class == o.class &&
117
+ bank_code == o.bank_code &&
118
+ start_at_jst == o.start_at_jst &&
119
+ end_at_jst == o.end_at_jst &&
120
+ start_at_utc == o.start_at_utc &&
121
+ end_at_utc == o.end_at_utc
122
+ end
123
+
124
+ # @see the `==` method
125
+ # @param [Object] Object to be compared
126
+ def eql?(o)
127
+ self == o
128
+ end
129
+
130
+ # Calculates hash code according to all attributes.
131
+ # @return [Integer] Hash code
132
+ def hash
133
+ [bank_code, start_at_jst, end_at_jst, start_at_utc, end_at_utc].hash
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def self.build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ attributes = attributes.transform_keys(&:to_sym)
142
+ transformed_hash = {}
143
+ openapi_types.each_pair do |key, type|
144
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
145
+ transformed_hash["#{key}"] = nil
146
+ elsif type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[attribute_map[key]].is_a?(Array)
150
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
151
+ end
152
+ elsif !attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
154
+ end
155
+ end
156
+ new(transformed_hash)
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def self._deserialize(type, value)
164
+ case type.to_sym
165
+ when :Time
166
+ Time.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+ when :Object
182
+ # generic object (usually a Hash), return directly
183
+ value
184
+ when /\AArray<(?<inner_type>.+)>\z/
185
+ inner_type = Regexp.last_match[:inner_type]
186
+ value.map { |v| _deserialize(inner_type, v) }
187
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
188
+ k_type = Regexp.last_match[:k_type]
189
+ v_type = Regexp.last_match[:v_type]
190
+ {}.tap do |hash|
191
+ value.each do |k, v|
192
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
193
+ end
194
+ end
195
+ else # model
196
+ # models (e.g. Pet) or oneOf
197
+ klass = Api.const_get(type)
198
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ end