moneykit 0.1.10 → 0.1.11

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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +1 -1
  4. data/docs/AccessTokenApi.md +26 -21
  5. data/docs/AccountBalances.md +2 -2
  6. data/docs/AccountGroup.md +1 -1
  7. data/docs/AccountIdentity.md +2 -0
  8. data/docs/AccountImportData.md +26 -0
  9. data/docs/AccountResponse.md +28 -0
  10. data/docs/AccountWithAccountNumbersLegacy20230218.md +2 -0
  11. data/docs/Address.md +1 -1
  12. data/docs/AppClientResponse.md +2 -2
  13. data/docs/AppLinkStateChangedWebhook.md +36 -0
  14. data/docs/AppResponse.md +2 -2
  15. data/docs/Body.md +3 -3
  16. data/docs/CreateAccessTokenResponse.md +22 -0
  17. data/docs/CreateLinkSessionRequest.md +1 -1
  18. data/docs/CustomerUser.md +22 -0
  19. data/docs/CustomerUserEmail.md +20 -0
  20. data/docs/CustomerUserPhone.md +22 -0
  21. data/docs/Date.md +15 -0
  22. data/docs/Email.md +1 -1
  23. data/docs/GetAccountResponse.md +1 -1
  24. data/docs/GetAccountsResponse.md +1 -1
  25. data/docs/GetHoldingsResponse.md +1 -1
  26. data/docs/GetInvestmentTransactionsResponse.md +1 -1
  27. data/docs/GetTransactionsResponse.md +2 -2
  28. data/docs/GetUserTransactionsResponse.md +1 -1
  29. data/docs/ImportLinkRequest.md +26 -0
  30. data/docs/Institution.md +1 -1
  31. data/docs/LinkCommon.md +3 -3
  32. data/docs/LinkProductError.md +15 -0
  33. data/docs/LinkProductRefreshWebhook.md +2 -2
  34. data/docs/LinkProductResponse.md +28 -0
  35. data/docs/LinkProducts.md +7 -5
  36. data/docs/LinkResponse.md +3 -3
  37. data/docs/LinkSessionApi.md +1 -1
  38. data/docs/LinksApi.md +79 -9
  39. data/docs/PhoneNumber.md +1 -1
  40. data/docs/PublicLinkState.md +15 -0
  41. data/docs/Response401DeleteLinkLinksIdDelete.md +22 -0
  42. data/docs/Response401GetTransactionsSyncLinksIdTransactionsSyncGet.md +22 -0
  43. data/docs/Response401ImportLinkLinksImportPost.md +22 -0
  44. data/docs/ResponseHandleLinkWebhookEventRequestBodyWebhookPost.md +3 -3
  45. data/docs/TransactionCategoryResponse.md +20 -0
  46. data/docs/TransactionEnrichmentResponse.md +26 -0
  47. data/docs/TransactionImportData.md +28 -0
  48. data/docs/TransactionMerchantResponse.md +24 -0
  49. data/docs/TransactionProcessorResponse.md +24 -0
  50. data/docs/TransactionRecurrenceResponse.md +20 -0
  51. data/docs/TransactionResponse.md +42 -0
  52. data/docs/TransactionSubcategoryResponse.md +20 -0
  53. data/docs/TransactionSync.md +22 -0
  54. data/docs/TransactionSyncResponse.md +1 -1
  55. data/docs/TransactionUpdatesAvailableWebhook.md +4 -2
  56. data/docs/TransactionsApi.md +15 -15
  57. data/docs/TransactionsLinkProduct.md +1 -1
  58. data/lib/moneykit/api/access_token_api.rb +19 -16
  59. data/lib/moneykit/api/links_api.rb +75 -7
  60. data/lib/moneykit/api/transactions_api.rb +17 -17
  61. data/lib/moneykit/models/account_balances.rb +2 -30
  62. data/lib/moneykit/models/account_group.rb +1 -1
  63. data/lib/moneykit/models/account_identity.rb +11 -1
  64. data/lib/moneykit/models/account_import_data.rb +280 -0
  65. data/lib/moneykit/models/account_response.rb +290 -0
  66. data/lib/moneykit/models/account_with_account_numbers_legacy20230218.rb +11 -1
  67. data/lib/moneykit/models/address.rb +0 -2
  68. data/lib/moneykit/models/app_client_response.rb +1 -1
  69. data/lib/moneykit/models/app_link_state_changed_webhook.rb +394 -0
  70. data/lib/moneykit/models/body.rb +1 -1
  71. data/lib/moneykit/models/create_access_token_response.rb +255 -0
  72. data/lib/moneykit/models/create_link_session_request.rb +1 -1
  73. data/lib/moneykit/models/customer_user.rb +266 -0
  74. data/lib/moneykit/models/customer_user_email.rb +258 -0
  75. data/lib/moneykit/models/customer_user_phone.rb +289 -0
  76. data/lib/moneykit/models/date.rb +104 -0
  77. data/lib/moneykit/models/email.rb +0 -2
  78. data/lib/moneykit/models/get_account_response.rb +1 -1
  79. data/lib/moneykit/models/get_accounts_response.rb +1 -1
  80. data/lib/moneykit/models/get_holdings_response.rb +1 -1
  81. data/lib/moneykit/models/get_investment_transactions_response.rb +1 -1
  82. data/lib/moneykit/models/get_transactions_response.rb +2 -2
  83. data/lib/moneykit/models/get_user_transactions_response.rb +1 -1
  84. data/lib/moneykit/models/import_link_request.rb +303 -0
  85. data/lib/moneykit/models/institution.rb +0 -7
  86. data/lib/moneykit/models/link_common.rb +3 -3
  87. data/lib/moneykit/models/link_product_error.rb +46 -0
  88. data/lib/moneykit/models/link_product_refresh_webhook.rb +24 -24
  89. data/lib/moneykit/models/link_product_response.rb +283 -0
  90. data/lib/moneykit/models/link_product_state.rb +3 -1
  91. data/lib/moneykit/models/link_products.rb +16 -7
  92. data/lib/moneykit/models/link_response.rb +3 -3
  93. data/lib/moneykit/models/phone_number.rb +0 -2
  94. data/lib/moneykit/models/product.rb +2 -1
  95. data/lib/moneykit/models/provider.rb +1 -2
  96. data/lib/moneykit/models/public_link_error.rb +1 -1
  97. data/lib/moneykit/models/public_link_state.rb +43 -0
  98. data/lib/moneykit/models/response401_delete_link_links_id_delete.rb +104 -0
  99. data/lib/moneykit/models/response401_get_transactions_sync_links_id_transactions_sync_get.rb +104 -0
  100. data/lib/moneykit/models/response401_import_link_links_import_post.rb +103 -0
  101. data/lib/moneykit/models/response_handle_link_webhook_event_request_body_webhook_post.rb +1 -1
  102. data/lib/moneykit/models/transaction_category_response.rb +230 -0
  103. data/lib/moneykit/models/transaction_enrichment_response.rb +255 -0
  104. data/lib/moneykit/models/transaction_import_data.rb +283 -0
  105. data/lib/moneykit/models/transaction_merchant_response.rb +243 -0
  106. data/lib/moneykit/models/transaction_processor_response.rb +243 -0
  107. data/lib/moneykit/models/transaction_recurrence_response.rb +223 -0
  108. data/lib/moneykit/models/transaction_response.rb +402 -0
  109. data/lib/moneykit/models/transaction_subcategory_response.rb +230 -0
  110. data/lib/moneykit/models/transaction_sync.rb +257 -0
  111. data/lib/moneykit/models/transaction_sync_response.rb +1 -1
  112. data/lib/moneykit/models/transaction_updates_available_webhook.rb +42 -24
  113. data/lib/moneykit/models/transactions_link_product.rb +1 -1
  114. data/lib/moneykit/version.rb +1 -1
  115. data/lib/moneykit.rb +25 -16
  116. data/spec/models/account_import_data_spec.rb +60 -0
  117. data/spec/models/account_response_spec.rb +66 -0
  118. data/spec/models/app_link_state_changed_webhook_spec.rb +102 -0
  119. data/spec/models/create_access_token_response_spec.rb +48 -0
  120. data/spec/models/customer_user_email_spec.rb +42 -0
  121. data/spec/models/customer_user_phone_spec.rb +48 -0
  122. data/spec/models/customer_user_spec.rb +48 -0
  123. data/spec/models/date_spec.rb +21 -0
  124. data/spec/models/import_link_request_spec.rb +60 -0
  125. data/spec/models/link_product_error_spec.rb +30 -0
  126. data/spec/models/link_product_response_spec.rb +66 -0
  127. data/spec/models/public_link_error_spec.rb +30 -0
  128. data/spec/models/public_link_state_spec.rb +30 -0
  129. data/spec/models/response401_delete_link_links_id_delete_spec.rb +21 -0
  130. data/spec/models/response401_get_transactions_sync_links_id_transactions_sync_get_spec.rb +21 -0
  131. data/spec/models/response401_import_link_links_import_post_spec.rb +21 -0
  132. data/spec/models/transaction_category_response_spec.rb +42 -0
  133. data/spec/models/transaction_enrichment_response_spec.rb +60 -0
  134. data/spec/models/transaction_import_data_spec.rb +66 -0
  135. data/spec/models/transaction_merchant_response_spec.rb +54 -0
  136. data/spec/models/transaction_processor_response_spec.rb +54 -0
  137. data/spec/models/transaction_recurrence_response_spec.rb +42 -0
  138. data/spec/models/transaction_response_spec.rb +108 -0
  139. data/spec/models/transaction_subcategory_response_spec.rb +42 -0
  140. data/spec/models/transaction_sync_spec.rb +48 -0
  141. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-11.1.3/gem_make.out +5 -5
  142. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  143. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.1.1/gem_make.out +5 -5
  144. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.1.1/mkmf.log +2 -2
  145. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.3/gem_make.out +5 -5
  146. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.1.0/gem_make.out +5 -5
  147. metadata +219 -121
@@ -0,0 +1,243 @@
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 TransactionProcessorResponse
18
+ # Unique identifier for the processor
19
+ attr_accessor :id
20
+
21
+ # Processor name
22
+ attr_accessor :name
23
+
24
+ # Processor logo URL
25
+ attr_accessor :logo
26
+
27
+ # Confidence score. Estimated accuracy of this data point (as a percentage).
28
+ attr_accessor :confidence
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'id' => :'id',
34
+ :'name' => :'name',
35
+ :'logo' => :'logo',
36
+ :'confidence' => :'confidence'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'id' => :'String',
49
+ :'name' => :'String',
50
+ :'logo' => :'String',
51
+ :'confidence' => :'Integer'
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 `MoneyKit::TransactionProcessorResponse` 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 `MoneyKit::TransactionProcessorResponse`. 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?(:'id')
77
+ self.id = attributes[:'id']
78
+ end
79
+
80
+ if attributes.key?(:'name')
81
+ self.name = attributes[:'name']
82
+ end
83
+
84
+ if attributes.key?(:'logo')
85
+ self.logo = attributes[:'logo']
86
+ end
87
+
88
+ if attributes.key?(:'confidence')
89
+ self.confidence = attributes[:'confidence']
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
97
+ invalid_properties = Array.new
98
+ invalid_properties
99
+ end
100
+
101
+ # Check to see if the all the properties in the model are valid
102
+ # @return true if the model is valid
103
+ def valid?
104
+ warn '[DEPRECATED] the `valid?` method is obsolete'
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ id == o.id &&
114
+ name == o.name &&
115
+ logo == o.logo &&
116
+ confidence == o.confidence
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(o)
122
+ self == o
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Integer] Hash code
127
+ def hash
128
+ [id, name, logo, confidence].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def self.build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ attributes = attributes.transform_keys(&:to_sym)
137
+ transformed_hash = {}
138
+ openapi_types.each_pair do |key, type|
139
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = nil
141
+ elsif type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[attribute_map[key]].is_a?(Array)
145
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
146
+ end
147
+ elsif !attributes[attribute_map[key]].nil?
148
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
149
+ end
150
+ end
151
+ new(transformed_hash)
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def self._deserialize(type, value)
159
+ case type.to_sym
160
+ when :Time
161
+ Time.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ # models (e.g. Pet) or oneOf
192
+ klass = MoneyKit.const_get(type)
193
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ if value.nil?
216
+ is_nullable = self.class.openapi_nullable.include?(attr)
217
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
218
+ end
219
+
220
+ hash[param] = _to_hash(value)
221
+ end
222
+ hash
223
+ end
224
+
225
+ # Outputs non-array value in the form of hash
226
+ # For object, use to_hash. Otherwise, just return the value
227
+ # @param [Object] value Any valid value
228
+ # @return [Hash] Returns the value in the form of hash
229
+ def _to_hash(value)
230
+ if value.is_a?(Array)
231
+ value.compact.map { |v| _to_hash(v) }
232
+ elsif value.is_a?(Hash)
233
+ {}.tap do |hash|
234
+ value.each { |k, v| hash[k] = _to_hash(v) }
235
+ end
236
+ elsif value.respond_to? :to_hash
237
+ value.to_hash
238
+ else
239
+ value
240
+ end
241
+ end
242
+ end
243
+ end
@@ -0,0 +1,223 @@
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 TransactionRecurrenceResponse
18
+ # Frequency of the recurring transaction
19
+ attr_accessor :frequency
20
+
21
+ # Predicted date of next transaction
22
+ attr_accessor :next_predicted_date
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'frequency' => :'frequency',
28
+ :'next_predicted_date' => :'next_predicted_date'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'frequency' => :'String',
41
+ :'next_predicted_date' => :'Date'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::TransactionRecurrenceResponse` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::TransactionRecurrenceResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'frequency')
67
+ self.frequency = attributes[:'frequency']
68
+ end
69
+
70
+ if attributes.key?(:'next_predicted_date')
71
+ self.next_predicted_date = attributes[:'next_predicted_date']
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
79
+ invalid_properties = Array.new
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ warn '[DEPRECATED] the `valid?` method is obsolete'
87
+ true
88
+ end
89
+
90
+ # Checks equality by comparing each attribute.
91
+ # @param [Object] Object to be compared
92
+ def ==(o)
93
+ return true if self.equal?(o)
94
+ self.class == o.class &&
95
+ frequency == o.frequency &&
96
+ next_predicted_date == o.next_predicted_date
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [frequency, next_predicted_date].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ transformed_hash = {}
118
+ openapi_types.each_pair do |key, type|
119
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
120
+ transformed_hash["#{key}"] = nil
121
+ elsif type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[attribute_map[key]].is_a?(Array)
125
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
126
+ end
127
+ elsif !attributes[attribute_map[key]].nil?
128
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
129
+ end
130
+ end
131
+ new(transformed_hash)
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def self._deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = MoneyKit.const_get(type)
173
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+ end
223
+ end