moneykit 0.1.6 → 0.1.9

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/README.md +1 -1
  4. data/docs/AccessTokenApi.md +4 -4
  5. data/docs/AccountNumbersApi.md +12 -12
  6. data/docs/AccountNumbersLegacy20230218.md +24 -0
  7. data/docs/AccountWithAccountNumbersLegacy20230218.md +28 -0
  8. data/docs/AccountsApi.md +20 -20
  9. data/docs/AppClientResponse.md +26 -0
  10. data/docs/AppResponse.md +24 -0
  11. data/docs/CreateLinkSessionRequest.md +2 -2
  12. data/docs/GetAccountNumbersResponseLegacy20230218.md +20 -0
  13. data/docs/IdentityApi.md +1 -1
  14. data/docs/Institution.md +1 -1
  15. data/docs/InstitutionsApi.md +2 -2
  16. data/docs/InvestmentTransactionResponse.md +4 -4
  17. data/docs/InvestmentsApi.md +2 -2
  18. data/docs/LinkProduct.md +28 -0
  19. data/docs/LinkProducts.md +4 -4
  20. data/docs/LinksApi.md +5 -5
  21. data/docs/MoneyKitConnectFeatures.md +3 -1
  22. data/docs/ProductSettings.md +24 -0
  23. data/docs/ProductsApi.md +1 -1
  24. data/docs/ProductsSettings.md +3 -3
  25. data/docs/RequestedLinkPermission.md +2 -2
  26. data/docs/Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet.md +22 -0
  27. data/docs/SecurityResponse.md +2 -2
  28. data/docs/TransactionsApi.md +5 -5
  29. data/docs/TransactionsLinkProduct.md +6 -4
  30. data/docs/TransactionsProductSettings.md +4 -2
  31. data/docs/UsersApi.md +7 -7
  32. data/docs/WebhooksApi.md +1 -1
  33. data/lib/moneykit/api/access_token_api.rb +3 -3
  34. data/lib/moneykit/api/account_numbers_api.rb +10 -10
  35. data/lib/moneykit/api/accounts_api.rb +16 -16
  36. data/lib/moneykit/api/investments_api.rb +2 -2
  37. data/lib/moneykit/api/transactions_api.rb +6 -6
  38. data/lib/moneykit/api/users_api.rb +8 -8
  39. data/lib/moneykit/models/account_numbers_legacy20230218.rb +275 -0
  40. data/lib/moneykit/models/account_with_account_numbers_legacy20230218.rb +296 -0
  41. data/lib/moneykit/models/app_client_response.rb +281 -0
  42. data/lib/moneykit/models/app_response.rb +272 -0
  43. data/lib/moneykit/models/create_link_session_request.rb +2 -2
  44. data/lib/moneykit/models/get_account_numbers_response_legacy20230218.rb +237 -0
  45. data/lib/moneykit/models/institution.rb +1 -1
  46. data/lib/moneykit/models/investment_transaction_response.rb +13 -13
  47. data/lib/moneykit/models/link_product.rb +283 -0
  48. data/lib/moneykit/models/link_product_failure_reasons.rb +2 -1
  49. data/lib/moneykit/models/link_products.rb +4 -4
  50. data/lib/moneykit/models/money_kit_connect_features.rb +16 -4
  51. data/lib/moneykit/models/product_settings.rb +249 -0
  52. data/lib/moneykit/models/products_settings.rb +3 -3
  53. data/lib/moneykit/models/requested_link_permission.rb +2 -2
  54. data/lib/moneykit/models/response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get.rb +104 -0
  55. data/lib/moneykit/models/security_response.rb +11 -11
  56. data/lib/moneykit/models/transactions_link_product.rb +22 -18
  57. data/lib/moneykit/models/transactions_product_settings.rb +20 -10
  58. data/lib/moneykit/version.rb +1 -1
  59. data/lib/moneykit.rb +8 -14
  60. data/spec/models/account_numbers_legacy20230218_spec.rb +54 -0
  61. data/spec/models/account_with_account_numbers_legacy20230218_spec.rb +66 -0
  62. data/spec/models/app_client_response_spec.rb +60 -0
  63. data/spec/models/app_response_spec.rb +54 -0
  64. data/spec/models/get_account_numbers_response_legacy20230218_spec.rb +42 -0
  65. data/spec/models/link_product_spec.rb +66 -0
  66. data/spec/models/product_settings_spec.rb +54 -0
  67. data/spec/models/response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get_spec.rb +21 -0
  68. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-11.1.3/byebug/byebug.so +0 -0
  69. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-11.1.3/gem_make.out +5 -5
  70. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  71. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/jaro_winkler/jaro_winkler_ext.so +0 -0
  72. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.1.1/gem_make.out +5 -5
  73. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.1.1/psych.so +0 -0
  74. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.3/gem_make.out +5 -5
  75. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.3/racc/cparse.so +0 -0
  76. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.1.0/gem_make.out +5 -5
  77. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.1.0/stringio.so +0 -0
  78. data/vendor/bundle/ruby/3.2.0/gems/byebug-11.1.3/lib/byebug/byebug.so +0 -0
  79. data/vendor/bundle/ruby/3.2.0/gems/jaro_winkler-1.5.6/lib/jaro_winkler/jaro_winkler_ext.so +0 -0
  80. data/vendor/bundle/ruby/3.2.0/gems/psych-5.1.1.1/lib/psych.so +0 -0
  81. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.3/lib/racc/cparse.so +0 -0
  82. data/vendor/bundle/ruby/3.2.0/gems/stringio-3.1.0/lib/stringio.so +0 -0
  83. metadata +143 -111
@@ -0,0 +1,275 @@
1
+ =begin
2
+ #MoneyKit API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2023-02-18
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MoneyKit
17
+ class AccountNumbersLegacy20230218
18
+ attr_accessor :ach
19
+
20
+ attr_accessor :bacs
21
+
22
+ attr_accessor :eft
23
+
24
+ attr_accessor :international
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'ach' => :'ach',
30
+ :'bacs' => :'bacs',
31
+ :'eft' => :'eft',
32
+ :'international' => :'international'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'ach' => :'Array<AchNumber>',
45
+ :'bacs' => :'Array<BacsNumber>',
46
+ :'eft' => :'Array<EftNumber>',
47
+ :'international' => :'Array<InternationalNumber>'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::AccountNumbersLegacy20230218` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
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 `MoneyKit::AccountNumbersLegacy20230218`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'ach')
73
+ if (value = attributes[:'ach']).is_a?(Array)
74
+ self.ach = value
75
+ end
76
+ else
77
+ self.ach = nil
78
+ end
79
+
80
+ if attributes.key?(:'bacs')
81
+ if (value = attributes[:'bacs']).is_a?(Array)
82
+ self.bacs = value
83
+ end
84
+ else
85
+ self.bacs = nil
86
+ end
87
+
88
+ if attributes.key?(:'eft')
89
+ if (value = attributes[:'eft']).is_a?(Array)
90
+ self.eft = value
91
+ end
92
+ else
93
+ self.eft = nil
94
+ end
95
+
96
+ if attributes.key?(:'international')
97
+ if (value = attributes[:'international']).is_a?(Array)
98
+ self.international = value
99
+ end
100
+ else
101
+ self.international = nil
102
+ end
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
109
+ invalid_properties = Array.new
110
+ if @ach.nil?
111
+ invalid_properties.push('invalid value for "ach", ach cannot be nil.')
112
+ end
113
+
114
+ if @bacs.nil?
115
+ invalid_properties.push('invalid value for "bacs", bacs cannot be nil.')
116
+ end
117
+
118
+ if @eft.nil?
119
+ invalid_properties.push('invalid value for "eft", eft cannot be nil.')
120
+ end
121
+
122
+ if @international.nil?
123
+ invalid_properties.push('invalid value for "international", international cannot be nil.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ warn '[DEPRECATED] the `valid?` method is obsolete'
133
+ return false if @ach.nil?
134
+ return false if @bacs.nil?
135
+ return false if @eft.nil?
136
+ return false if @international.nil?
137
+ true
138
+ end
139
+
140
+ # Checks equality by comparing each attribute.
141
+ # @param [Object] Object to be compared
142
+ def ==(o)
143
+ return true if self.equal?(o)
144
+ self.class == o.class &&
145
+ ach == o.ach &&
146
+ bacs == o.bacs &&
147
+ eft == o.eft &&
148
+ international == o.international
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(o)
154
+ self == o
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [ach, bacs, eft, international].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ attributes = attributes.transform_keys(&:to_sym)
169
+ transformed_hash = {}
170
+ openapi_types.each_pair do |key, type|
171
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
172
+ transformed_hash["#{key}"] = nil
173
+ elsif type =~ /\AArray<(.*)>/i
174
+ # check to ensure the input is an array given that the attribute
175
+ # is documented as an array but the input is not
176
+ if attributes[attribute_map[key]].is_a?(Array)
177
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
178
+ end
179
+ elsif !attributes[attribute_map[key]].nil?
180
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
181
+ end
182
+ end
183
+ new(transformed_hash)
184
+ end
185
+
186
+ # Deserializes the data based on type
187
+ # @param string type Data type
188
+ # @param string value Value to be deserialized
189
+ # @return [Object] Deserialized data
190
+ def self._deserialize(type, value)
191
+ case type.to_sym
192
+ when :Time
193
+ Time.parse(value)
194
+ when :Date
195
+ Date.parse(value)
196
+ when :String
197
+ value.to_s
198
+ when :Integer
199
+ value.to_i
200
+ when :Float
201
+ value.to_f
202
+ when :Boolean
203
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
+ true
205
+ else
206
+ false
207
+ end
208
+ when :Object
209
+ # generic object (usually a Hash), return directly
210
+ value
211
+ when /\AArray<(?<inner_type>.+)>\z/
212
+ inner_type = Regexp.last_match[:inner_type]
213
+ value.map { |v| _deserialize(inner_type, v) }
214
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
+ k_type = Regexp.last_match[:k_type]
216
+ v_type = Regexp.last_match[:v_type]
217
+ {}.tap do |hash|
218
+ value.each do |k, v|
219
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
+ end
221
+ end
222
+ else # model
223
+ # models (e.g. Pet) or oneOf
224
+ klass = MoneyKit.const_get(type)
225
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
226
+ end
227
+ end
228
+
229
+ # Returns the string representation of the object
230
+ # @return [String] String presentation of the object
231
+ def to_s
232
+ to_hash.to_s
233
+ end
234
+
235
+ # to_body is an alias to to_hash (backward compatibility)
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_body
238
+ to_hash
239
+ end
240
+
241
+ # Returns the object in the form of hash
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_hash
244
+ hash = {}
245
+ self.class.attribute_map.each_pair do |attr, param|
246
+ value = self.send(attr)
247
+ if value.nil?
248
+ is_nullable = self.class.openapi_nullable.include?(attr)
249
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
250
+ end
251
+
252
+ hash[param] = _to_hash(value)
253
+ end
254
+ hash
255
+ end
256
+
257
+ # Outputs non-array value in the form of hash
258
+ # For object, use to_hash. Otherwise, just return the value
259
+ # @param [Object] value Any valid value
260
+ # @return [Hash] Returns the value in the form of hash
261
+ def _to_hash(value)
262
+ if value.is_a?(Array)
263
+ value.compact.map { |v| _to_hash(v) }
264
+ elsif value.is_a?(Hash)
265
+ {}.tap do |hash|
266
+ value.each { |k, v| hash[k] = _to_hash(v) }
267
+ end
268
+ elsif value.respond_to? :to_hash
269
+ value.to_hash
270
+ else
271
+ value
272
+ end
273
+ end
274
+ end
275
+ end
@@ -0,0 +1,296 @@
1
+ =begin
2
+ #MoneyKit API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2023-02-18
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MoneyKit
17
+ class AccountWithAccountNumbersLegacy20230218
18
+ # MoneyKit's unique ID for the account. <p>The `account_id` is distinct from the institution's account number. For accounts that may change account numbers from time to time, such as credit cards, MoneyKit attempts to keep the `account_id` constant. However, if MoneyKit can't reconcile the new account data with the old data, the `account_id` may change.
19
+ attr_accessor :account_id
20
+
21
+ # See <a href=/pages/account_types>Account Types</a> for an explanation of account types. Account types are dot-prefixed with one of `depository`, `investment`, `liability`, or `other`; or the value is `unknown`. <p>**Balances for `liability` accounts are reversed:** negative balances (the amount owed) are reported as positive values. For all other types of accounts, a negative balance indicates the amount owed.
22
+ attr_accessor :account_type
23
+
24
+ # The account name, according to the institution. Note that some institutions allow the end user to nickname the account; in such cases this field may be the name assigned by the user.
25
+ attr_accessor :name
26
+
27
+ # The last four characters (usually digits) of the account number. Note that this mask may be non-unique between accounts.
28
+ attr_accessor :account_mask
29
+
30
+ attr_accessor :balances
31
+
32
+ attr_accessor :numbers
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'account_id' => :'account_id',
38
+ :'account_type' => :'account_type',
39
+ :'name' => :'name',
40
+ :'account_mask' => :'account_mask',
41
+ :'balances' => :'balances',
42
+ :'numbers' => :'numbers'
43
+ }
44
+ end
45
+
46
+ # Returns all the JSON keys this model knows about
47
+ def self.acceptable_attributes
48
+ attribute_map.values
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'account_id' => :'String',
55
+ :'account_type' => :'String',
56
+ :'name' => :'String',
57
+ :'account_mask' => :'String',
58
+ :'balances' => :'AccountBalances',
59
+ :'numbers' => :'AccountNumbersLegacy20230218'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ ])
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::AccountWithAccountNumbersLegacy20230218` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::AccountWithAccountNumbersLegacy20230218`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+ h[k.to_sym] = v
82
+ }
83
+
84
+ if attributes.key?(:'account_id')
85
+ self.account_id = attributes[:'account_id']
86
+ else
87
+ self.account_id = nil
88
+ end
89
+
90
+ if attributes.key?(:'account_type')
91
+ self.account_type = attributes[:'account_type']
92
+ else
93
+ self.account_type = nil
94
+ end
95
+
96
+ if attributes.key?(:'name')
97
+ self.name = attributes[:'name']
98
+ else
99
+ self.name = nil
100
+ end
101
+
102
+ if attributes.key?(:'account_mask')
103
+ self.account_mask = attributes[:'account_mask']
104
+ end
105
+
106
+ if attributes.key?(:'balances')
107
+ self.balances = attributes[:'balances']
108
+ else
109
+ self.balances = nil
110
+ end
111
+
112
+ if attributes.key?(:'numbers')
113
+ self.numbers = attributes[:'numbers']
114
+ else
115
+ self.numbers = nil
116
+ end
117
+ end
118
+
119
+ # Show invalid properties with the reasons. Usually used together with valid?
120
+ # @return Array for valid properties with the reasons
121
+ def list_invalid_properties
122
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
123
+ invalid_properties = Array.new
124
+ if @account_id.nil?
125
+ invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
126
+ end
127
+
128
+ if @account_type.nil?
129
+ invalid_properties.push('invalid value for "account_type", account_type cannot be nil.')
130
+ end
131
+
132
+ if @name.nil?
133
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
134
+ end
135
+
136
+ if @balances.nil?
137
+ invalid_properties.push('invalid value for "balances", balances cannot be nil.')
138
+ end
139
+
140
+ if @numbers.nil?
141
+ invalid_properties.push('invalid value for "numbers", numbers cannot be nil.')
142
+ end
143
+
144
+ invalid_properties
145
+ end
146
+
147
+ # Check to see if the all the properties in the model are valid
148
+ # @return true if the model is valid
149
+ def valid?
150
+ warn '[DEPRECATED] the `valid?` method is obsolete'
151
+ return false if @account_id.nil?
152
+ return false if @account_type.nil?
153
+ return false if @name.nil?
154
+ return false if @balances.nil?
155
+ return false if @numbers.nil?
156
+ true
157
+ end
158
+
159
+ # Checks equality by comparing each attribute.
160
+ # @param [Object] Object to be compared
161
+ def ==(o)
162
+ return true if self.equal?(o)
163
+ self.class == o.class &&
164
+ account_id == o.account_id &&
165
+ account_type == o.account_type &&
166
+ name == o.name &&
167
+ account_mask == o.account_mask &&
168
+ balances == o.balances &&
169
+ numbers == o.numbers
170
+ end
171
+
172
+ # @see the `==` method
173
+ # @param [Object] Object to be compared
174
+ def eql?(o)
175
+ self == o
176
+ end
177
+
178
+ # Calculates hash code according to all attributes.
179
+ # @return [Integer] Hash code
180
+ def hash
181
+ [account_id, account_type, name, account_mask, balances, numbers].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
+ attributes = attributes.transform_keys(&:to_sym)
190
+ transformed_hash = {}
191
+ openapi_types.each_pair do |key, type|
192
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
193
+ transformed_hash["#{key}"] = nil
194
+ elsif type =~ /\AArray<(.*)>/i
195
+ # check to ensure the input is an array given that the attribute
196
+ # is documented as an array but the input is not
197
+ if attributes[attribute_map[key]].is_a?(Array)
198
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
199
+ end
200
+ elsif !attributes[attribute_map[key]].nil?
201
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
202
+ end
203
+ end
204
+ new(transformed_hash)
205
+ end
206
+
207
+ # Deserializes the data based on type
208
+ # @param string type Data type
209
+ # @param string value Value to be deserialized
210
+ # @return [Object] Deserialized data
211
+ def self._deserialize(type, value)
212
+ case type.to_sym
213
+ when :Time
214
+ Time.parse(value)
215
+ when :Date
216
+ Date.parse(value)
217
+ when :String
218
+ value.to_s
219
+ when :Integer
220
+ value.to_i
221
+ when :Float
222
+ value.to_f
223
+ when :Boolean
224
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
225
+ true
226
+ else
227
+ false
228
+ end
229
+ when :Object
230
+ # generic object (usually a Hash), return directly
231
+ value
232
+ when /\AArray<(?<inner_type>.+)>\z/
233
+ inner_type = Regexp.last_match[:inner_type]
234
+ value.map { |v| _deserialize(inner_type, v) }
235
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
236
+ k_type = Regexp.last_match[:k_type]
237
+ v_type = Regexp.last_match[:v_type]
238
+ {}.tap do |hash|
239
+ value.each do |k, v|
240
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
241
+ end
242
+ end
243
+ else # model
244
+ # models (e.g. Pet) or oneOf
245
+ klass = MoneyKit.const_get(type)
246
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
247
+ end
248
+ end
249
+
250
+ # Returns the string representation of the object
251
+ # @return [String] String presentation of the object
252
+ def to_s
253
+ to_hash.to_s
254
+ end
255
+
256
+ # to_body is an alias to to_hash (backward compatibility)
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_body
259
+ to_hash
260
+ end
261
+
262
+ # Returns the object in the form of hash
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_hash
265
+ hash = {}
266
+ self.class.attribute_map.each_pair do |attr, param|
267
+ value = self.send(attr)
268
+ if value.nil?
269
+ is_nullable = self.class.openapi_nullable.include?(attr)
270
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
271
+ end
272
+
273
+ hash[param] = _to_hash(value)
274
+ end
275
+ hash
276
+ end
277
+
278
+ # Outputs non-array value in the form of hash
279
+ # For object, use to_hash. Otherwise, just return the value
280
+ # @param [Object] value Any valid value
281
+ # @return [Hash] Returns the value in the form of hash
282
+ def _to_hash(value)
283
+ if value.is_a?(Array)
284
+ value.compact.map { |v| _to_hash(v) }
285
+ elsif value.is_a?(Hash)
286
+ {}.tap do |hash|
287
+ value.each { |k, v| hash[k] = _to_hash(v) }
288
+ end
289
+ elsif value.respond_to? :to_hash
290
+ value.to_hash
291
+ else
292
+ value
293
+ end
294
+ end
295
+ end
296
+ end