moneykit 0.0.3 → 0.0.5
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/moneykit/api/access_token_api.rb +9 -9
- data/lib/moneykit/api/account_numbers_api.rb +6 -6
- data/lib/moneykit/api/accounts_api.rb +15 -15
- data/lib/moneykit/api/identity_api.rb +6 -6
- data/lib/moneykit/api/institutions_api.rb +7 -7
- data/lib/moneykit/api/link_session_api.rb +7 -7
- data/lib/moneykit/api/links_api.rb +76 -13
- data/lib/moneykit/api/products_api.rb +6 -6
- data/lib/moneykit/api/transactions_api.rb +28 -28
- data/lib/moneykit/api/users_api.rb +14 -14
- data/lib/moneykit/api/webhooks_api.rb +97 -0
- data/lib/moneykit/api_client.rb +40 -36
- data/lib/moneykit/api_error.rb +1 -1
- data/lib/moneykit/configuration.rb +20 -30
- data/lib/moneykit/models/account.rb +27 -54
- data/lib/moneykit/models/account_balances.rb +18 -27
- data/lib/moneykit/models/account_group.rb +23 -26
- data/lib/moneykit/models/account_identity.rb +34 -59
- data/lib/moneykit/models/account_numbers.rb +75 -51
- data/lib/moneykit/models/account_numbers_link_product.rb +18 -28
- data/lib/moneykit/models/account_numbers_product_settings.rb +16 -21
- data/lib/moneykit/models/account_with_account_numbers.rb +29 -56
- data/lib/moneykit/models/accounts_link_product.rb +17 -25
- data/lib/moneykit/models/ach_number.rb +19 -26
- data/lib/moneykit/models/address.rb +17 -28
- data/lib/moneykit/models/api_error_auth_expired_access_token_response.rb +17 -24
- data/lib/moneykit/models/api_error_auth_unauthorized_response.rb +18 -25
- data/lib/moneykit/models/api_error_rate_limit_exceeded_response.rb +17 -24
- data/lib/moneykit/models/bacs_number.rb +18 -25
- data/lib/moneykit/models/basic_account_details.rb +20 -29
- data/lib/moneykit/models/country.rb +1 -1
- data/lib/moneykit/models/create_link_session_request.rb +48 -45
- data/lib/moneykit/models/create_link_session_response.rb +17 -24
- data/lib/moneykit/models/currency.rb +1 -1
- data/lib/moneykit/models/cursor_pagination.rb +17 -24
- data/lib/moneykit/models/customer_app.rb +18 -25
- data/lib/moneykit/models/eft_number.rb +19 -26
- data/lib/moneykit/models/email.rb +17 -22
- data/lib/moneykit/models/exchange_token_request.rb +17 -24
- data/lib/moneykit/models/exchange_token_response.rb +19 -26
- data/lib/moneykit/models/generate_access_token_response.rb +19 -26
- data/lib/moneykit/models/get_account_numbers_response.rb +23 -26
- data/lib/moneykit/models/get_account_response.rb +19 -26
- data/lib/moneykit/models/get_accounts_response.rb +25 -31
- data/lib/moneykit/models/get_institutions_response.rb +25 -31
- data/lib/moneykit/models/get_transactions_response.rb +34 -39
- data/lib/moneykit/models/get_user_accounts_response.rb +24 -32
- data/lib/moneykit/models/get_user_links_response.rb +24 -32
- data/lib/moneykit/models/get_user_transactions_response.rb +32 -34
- data/lib/moneykit/models/http_validation_error.rb +24 -28
- data/lib/moneykit/models/identity_link_product.rb +18 -28
- data/lib/moneykit/models/identity_product_settings.rb +16 -21
- data/lib/moneykit/models/identity_response.rb +24 -30
- data/lib/moneykit/models/institution.rb +29 -38
- data/lib/moneykit/models/institution_error_not_found_response.rb +17 -24
- data/lib/moneykit/models/international_number.rb +18 -25
- data/lib/moneykit/models/introspect_client_response.rb +22 -29
- data/lib/moneykit/models/jwk_set.rb +23 -26
- data/lib/moneykit/models/link_common.rb +25 -39
- data/lib/moneykit/models/link_error_bad_config_response.rb +269 -0
- data/lib/moneykit/models/link_error_bad_state_response.rb +19 -28
- data/lib/moneykit/models/link_error_deleted_response.rb +17 -24
- data/lib/moneykit/models/link_error_forbidden_action_response.rb +18 -25
- data/lib/moneykit/models/link_error_not_found_response.rb +17 -24
- data/lib/moneykit/models/link_error_unauthorized_access_response.rb +17 -24
- data/lib/moneykit/models/link_permission_scope.rb +1 -1
- data/lib/moneykit/models/link_permissions.rb +23 -33
- data/lib/moneykit/models/link_products.rb +16 -21
- data/lib/moneykit/models/link_response.rb +26 -39
- data/lib/moneykit/models/link_session_customer_user.rb +20 -28
- data/lib/moneykit/models/link_session_customer_user_email.rb +18 -25
- data/lib/moneykit/models/link_session_customer_user_phone.rb +18 -26
- data/lib/moneykit/models/link_session_error_forbidden_config_response.rb +18 -25
- data/lib/moneykit/models/link_session_error_invalid_token_exchange.rb +18 -25
- data/lib/moneykit/models/link_session_setting_overrides.rb +19 -43
- data/lib/moneykit/models/link_state.rb +1 -1
- data/lib/moneykit/models/link_state_changed_webhook.rb +28 -31
- data/lib/moneykit/models/money_link_features.rb +27 -32
- data/lib/moneykit/models/owner.rb +42 -42
- data/lib/moneykit/models/phone_number.rb +18 -25
- data/lib/moneykit/models/phone_number_type.rb +1 -1
- data/lib/moneykit/models/product.rb +1 -1
- data/lib/moneykit/models/products_settings.rb +19 -24
- data/lib/moneykit/models/provider.rb +4 -2
- data/lib/moneykit/models/public_link_error.rb +43 -0
- data/lib/moneykit/models/refresh_products_request.rb +23 -34
- data/lib/moneykit/models/requested_link_permission.rb +19 -26
- data/lib/moneykit/models/response401_disconnect_links_id_delete.rb +75 -269
- data/lib/moneykit/models/response401_exchange_token_link_session_exchange_token_post.rb +74 -267
- data/lib/moneykit/models/response401_get_account_links_id_accounts_account_id_get.rb +75 -269
- data/lib/moneykit/models/response401_get_account_numbers_links_id_accounts_numbers_get.rb +75 -269
- data/lib/moneykit/models/response401_get_accounts_links_id_accounts_get.rb +75 -269
- data/lib/moneykit/models/response401_get_identities_links_id_identity_get.rb +75 -269
- data/lib/moneykit/models/response401_get_institution_institutions_institution_id_get.rb +74 -267
- data/lib/moneykit/models/response401_get_institutions_institutions_get.rb +74 -267
- data/lib/moneykit/models/response401_get_link_links_id_get.rb +75 -269
- data/lib/moneykit/models/response401_get_transactions_diff_links_id_transactions_sync_get.rb +75 -269
- data/lib/moneykit/models/response401_get_transactions_links_id_transactions_get.rb +75 -269
- data/lib/moneykit/models/response401_get_user_accounts_users_id_accounts_get.rb +74 -267
- data/lib/moneykit/models/response401_get_user_links_users_id_links_get.rb +74 -267
- data/lib/moneykit/models/response401_get_user_transactions_users_id_transactions_get.rb +74 -267
- data/lib/moneykit/models/response401_get_well_known_jwks_well_known_jwks_json_get.rb +74 -267
- data/lib/moneykit/models/response401_instrospect_client_auth_introspect_get.rb +74 -267
- data/lib/moneykit/models/response401_refresh_products_links_id_products_post.rb +75 -269
- data/lib/moneykit/models/response401_reset_login_links_id_reset_post.rb +102 -0
- data/lib/moneykit/models/response401_trigger_test_link_webhook_event_webhooks_test_link_id_post.rb +102 -0
- data/lib/moneykit/models/response401_update_link_links_id_patch.rb +75 -269
- data/lib/moneykit/models/transaction.rb +35 -35
- data/lib/moneykit/models/transaction_diff.rb +36 -37
- data/lib/moneykit/models/transaction_sync_response.rb +23 -30
- data/lib/moneykit/models/transaction_type.rb +1 -1
- data/lib/moneykit/models/transaction_type_filter.rb +1 -1
- data/lib/moneykit/models/transactions_link_product.rb +18 -28
- data/lib/moneykit/models/transactions_product_settings.rb +16 -21
- data/lib/moneykit/models/update_link_request.rb +21 -28
- data/lib/moneykit/models/validation_error.rb +25 -28
- data/lib/moneykit/models/validation_error_location_inner.rb +101 -0
- data/lib/moneykit/models/webhook_link_test_event.rb +40 -0
- data/lib/moneykit/models/webhook_test_link_request.rb +252 -0
- data/lib/moneykit/models/webhook_test_link_response.rb +220 -0
- data/lib/moneykit/version.rb +2 -2
- data/lib/moneykit.rb +10 -29
- data/lib/plaid_compatible/money_kit_plaid_compatible/api/plaid_api.rb +684 -679
- data/lib/plaid_compatible/money_kit_plaid_compatible/api_client.rb +330 -330
- data/lib/plaid_compatible/money_kit_plaid_compatible/api_error.rb +33 -33
- data/lib/plaid_compatible/money_kit_plaid_compatible/configuration.rb +245 -245
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/account_balance.rb +198 -198
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/account_base.rb +213 -213
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/account_identity.rb +223 -223
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/account_subtype.rb +89 -89
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/account_type.rb +22 -22
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/accounts_get_request.rb +198 -198
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/accounts_get_request_options.rb +175 -175
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/accounts_get_response.rb +194 -194
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/address.rb +183 -183
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/address_data.rb +209 -209
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/auth_get_numbers.rb +211 -209
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/auth_get_request.rb +198 -198
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/auth_get_request_options.rb +175 -175
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/auth_get_response.rb +200 -200
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/country_code.rb +19 -19
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/email.rb +184 -184
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/http_validation_error.rb +171 -171
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/identity_get_request.rb +198 -198
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/identity_get_request_options.rb +175 -175
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/identity_get_response.rb +194 -194
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/institution.rb +216 -214
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/institutions_get_by_id_request.rb +202 -202
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/institutions_get_by_id_response.rb +183 -183
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item.rb +246 -245
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_error_webhook.rb +208 -208
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_get_request.rb +192 -192
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_get_response.rb +189 -189
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_public_token_exchange_request.rb +192 -192
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_public_token_exchange_response.rb +193 -193
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_remove_request.rb +192 -192
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_remove_response.rb +175 -175
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_status_investments.rb +182 -182
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_status_last_webhook.rb +182 -182
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_status_nullable.rb +183 -183
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/item_status_transactions.rb +182 -182
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/link_token_create_request.rb +268 -266
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/link_token_create_request_user.rb +212 -212
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/link_token_create_response.rb +193 -193
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/numbers_ach.rb +202 -202
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/numbers_bacs.rb +193 -193
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/numbers_eft.rb +202 -202
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/numbers_international.rb +193 -193
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/owner.rb +211 -209
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/personal_finance_category.rb +184 -184
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/phone_number.rb +193 -193
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/plaid_error.rb +247 -245
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/plaid_error_type.rb +30 -30
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/products.rb +20 -20
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/removed_transaction.rb +174 -174
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transaction.rb +283 -283
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_get_request.rb +217 -217
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_get_request_options.rb +211 -211
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_get_response.rb +217 -217
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_refresh_request.rb +192 -192
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_refresh_response.rb +175 -175
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_sync_request.rb +215 -215
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_sync_request_options.rb +184 -184
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/transactions_sync_response.rb +228 -228
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/validation_error.rb +187 -187
- data/lib/plaid_compatible/money_kit_plaid_compatible/models/webhook_environment_values.rb +19 -19
- data/lib/plaid_compatible/money_kit_plaid_compatible/version.rb +1 -1
- data/lib/plaid_compatible/money_kit_plaid_compatible.rb +13 -13
- data/moneykit.gemspec +2 -1
- metadata +14 -5
@@ -5,289 +5,96 @@
|
|
5
5
|
# The version of the OpenAPI document: 0.1.0
|
6
6
|
#
|
7
7
|
# Generated by: https://openapi-generator.tech
|
8
|
-
# OpenAPI Generator version:
|
8
|
+
# OpenAPI Generator version: 7.1.0
|
9
9
|
#
|
10
10
|
|
11
11
|
require 'date'
|
12
12
|
require 'time'
|
13
13
|
|
14
14
|
module MoneyKit
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def initialize(datatype, allowable_values)
|
25
|
-
@allowable_values = allowable_values.map do |value|
|
26
|
-
case datatype.to_s
|
27
|
-
when /Integer/i
|
28
|
-
value.to_i
|
29
|
-
when /Float/i
|
30
|
-
value.to_f
|
31
|
-
else
|
32
|
-
value
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def valid?(value)
|
38
|
-
!value || allowable_values.include?(value)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
43
|
-
def self.attribute_map
|
44
|
-
{
|
45
|
-
'error_code': :error_code,
|
46
|
-
'error_message': :error_message,
|
47
|
-
'documentation_url': :documentation_url
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns all the JSON keys this model knows about
|
52
|
-
def self.acceptable_attributes
|
53
|
-
attribute_map.values
|
54
|
-
end
|
55
|
-
|
56
|
-
# Attribute type mapping.
|
57
|
-
def self.openapi_types
|
58
|
-
{
|
59
|
-
'error_code': :String,
|
60
|
-
'error_message': :String,
|
61
|
-
'documentation_url': :String
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
# List of attributes with nullable: true
|
66
|
-
def self.openapi_nullable
|
67
|
-
Set.new([
|
68
|
-
:documentation_url
|
69
|
-
])
|
70
|
-
end
|
71
|
-
|
72
|
-
# List of class defined in anyOf (OpenAPI v3)
|
73
|
-
def self.openapi_any_of
|
74
|
-
%i[
|
75
|
-
APIErrorAuthExpiredAccessTokenResponse
|
76
|
-
APIErrorAuthUnauthorizedResponse
|
77
|
-
]
|
78
|
-
end
|
79
|
-
|
80
|
-
# Initializes the object
|
81
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
82
|
-
def initialize(attributes = {})
|
83
|
-
unless attributes.is_a?(Hash)
|
84
|
-
raise ArgumentError,
|
85
|
-
'The input argument (attributes) must be a hash in `MoneyKit::Response401InstrospectClientAuthIntrospectGet` initialize method'
|
15
|
+
module Response401InstrospectClientAuthIntrospectGet
|
16
|
+
class << self
|
17
|
+
# List of class defined in anyOf (OpenAPI v3)
|
18
|
+
def openapi_any_of
|
19
|
+
%i[
|
20
|
+
APIErrorAuthExpiredAccessTokenResponse
|
21
|
+
APIErrorAuthUnauthorizedResponse
|
22
|
+
]
|
86
23
|
end
|
87
24
|
|
88
|
-
#
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
25
|
+
# Builds the object
|
26
|
+
# @param [Mixed] Data to be matched against the list of anyOf items
|
27
|
+
# @return [Object] Returns the model or the data itself
|
28
|
+
def build(data)
|
29
|
+
# Go through the list of anyOf items and attempt to identify the appropriate one.
|
30
|
+
# Note:
|
31
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
32
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
33
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
34
|
+
# - TODO: logging when debugging is set.
|
35
|
+
openapi_any_of.each do |klass|
|
36
|
+
next if klass == :AnyType # "nullable: true"
|
37
|
+
|
38
|
+
typed_data = find_and_cast_into_type(klass, data)
|
39
|
+
return typed_data if typed_data
|
40
|
+
rescue StandardError # rescue all errors so we keep iterating even if the current item lookup raises
|
93
41
|
end
|
94
42
|
|
95
|
-
|
43
|
+
openapi_any_of.include?(:AnyType) ? data : nil
|
96
44
|
end
|
97
45
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
return false if @error_message.nil?
|
126
|
-
|
127
|
-
_any_of_found = false
|
128
|
-
self.class.openapi_any_of.each do |_class|
|
129
|
-
_any_of = MoneyKit.const_get(_class).build_from_hash(to_hash)
|
130
|
-
_any_of_found = true if _any_of.valid?
|
131
|
-
end
|
132
|
-
|
133
|
-
return false unless _any_of_found
|
134
|
-
|
135
|
-
true
|
136
|
-
end
|
137
|
-
|
138
|
-
# Custom attribute writer method checking allowed values (enum).
|
139
|
-
# @param [Object] error_code Object to be assigned
|
140
|
-
def error_code=(error_code)
|
141
|
-
validator = EnumAttributeValidator.new('String', ['api_error.auth.unauthorized'])
|
142
|
-
unless validator.valid?(error_code)
|
143
|
-
raise ArgumentError, "invalid value for \"error_code\", must be one of #{validator.allowable_values}."
|
144
|
-
end
|
145
|
-
|
146
|
-
@error_code = error_code
|
147
|
-
end
|
148
|
-
|
149
|
-
# Checks equality by comparing each attribute.
|
150
|
-
# @param [Object] Object to be compared
|
151
|
-
def ==(other)
|
152
|
-
return true if equal?(other)
|
153
|
-
|
154
|
-
self.class == other.class &&
|
155
|
-
error_code == other.error_code &&
|
156
|
-
error_message == other.error_message &&
|
157
|
-
documentation_url == other.documentation_url
|
158
|
-
end
|
159
|
-
|
160
|
-
# @see the `==` method
|
161
|
-
# @param [Object] Object to be compared
|
162
|
-
def eql?(other)
|
163
|
-
self == other
|
164
|
-
end
|
165
|
-
|
166
|
-
# Calculates hash code according to all attributes.
|
167
|
-
# @return [Integer] Hash code
|
168
|
-
def hash
|
169
|
-
[error_code, error_message, documentation_url].hash
|
170
|
-
end
|
171
|
-
|
172
|
-
# Builds the object from hash
|
173
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
174
|
-
# @return [Object] Returns the model itself
|
175
|
-
def self.build_from_hash(attributes)
|
176
|
-
new.build_from_hash(attributes)
|
177
|
-
end
|
178
|
-
|
179
|
-
# Builds the object from hash
|
180
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
181
|
-
# @return [Object] Returns the model itself
|
182
|
-
def build_from_hash(attributes)
|
183
|
-
return nil unless attributes.is_a?(Hash)
|
184
|
-
|
185
|
-
attributes = attributes.transform_keys(&:to_sym)
|
186
|
-
self.class.openapi_types.each_pair do |key, type|
|
187
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
188
|
-
send("#{key}=", nil)
|
189
|
-
elsif type =~ /\AArray<(.*)>/i
|
190
|
-
# check to ensure the input is an array given that the attribute
|
191
|
-
# is documented as an array but the input is not
|
192
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
193
|
-
send("#{key}=", attributes[self.class.attribute_map[key]].map do |v|
|
194
|
-
_deserialize(::Regexp.last_match(1), v)
|
195
|
-
end)
|
46
|
+
private
|
47
|
+
|
48
|
+
SchemaMismatchError = Class.new(StandardError)
|
49
|
+
|
50
|
+
# NOTE: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
51
|
+
def find_and_cast_into_type(klass, data)
|
52
|
+
return if data.nil?
|
53
|
+
|
54
|
+
case klass.to_s
|
55
|
+
when 'Boolean'
|
56
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
57
|
+
when 'Float'
|
58
|
+
return data if data.instance_of?(Float)
|
59
|
+
when 'Integer'
|
60
|
+
return data if data.instance_of?(Integer)
|
61
|
+
when 'Time'
|
62
|
+
return Time.parse(data)
|
63
|
+
when 'Date'
|
64
|
+
return Date.parse(data)
|
65
|
+
when 'String'
|
66
|
+
return data if data.instance_of?(String)
|
67
|
+
when 'Object' # "type: object"
|
68
|
+
return data if data.instance_of?(Hash)
|
69
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
70
|
+
if data.instance_of?(Array)
|
71
|
+
sub_type = Regexp.last_match[:sub_type]
|
72
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
196
73
|
end
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
when :String
|
216
|
-
value.to_s
|
217
|
-
when :Integer
|
218
|
-
value.to_i
|
219
|
-
when :Float
|
220
|
-
value.to_f
|
221
|
-
when :Boolean
|
222
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
223
|
-
true
|
224
|
-
else
|
225
|
-
false
|
226
|
-
end
|
227
|
-
when :Object
|
228
|
-
# generic object (usually a Hash), return directly
|
229
|
-
value
|
230
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
231
|
-
inner_type = Regexp.last_match[:inner_type]
|
232
|
-
value.map { |v| _deserialize(inner_type, v) }
|
233
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
234
|
-
k_type = Regexp.last_match[:k_type]
|
235
|
-
v_type = Regexp.last_match[:v_type]
|
236
|
-
{}.tap do |hash|
|
237
|
-
value.each do |k, v|
|
238
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
74
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
75
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
76
|
+
sub_type = Regexp.last_match[:sub_type]
|
77
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
78
|
+
end
|
79
|
+
else # model
|
80
|
+
const = MoneyKit.const_get(klass)
|
81
|
+
if const
|
82
|
+
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
83
|
+
model = const.build(data)
|
84
|
+
return model if model
|
85
|
+
else
|
86
|
+
# raise if data contains keys that are not known to the model
|
87
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
88
|
+
|
89
|
+
model = const.build_from_hash(data)
|
90
|
+
return model if model
|
91
|
+
end
|
239
92
|
end
|
240
|
-
end
|
241
|
-
else # model
|
242
|
-
# models (e.g. Pet) or oneOf
|
243
|
-
klass = MoneyKit.const_get(type)
|
244
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
# Returns the string representation of the object
|
249
|
-
# @return [String] String presentation of the object
|
250
|
-
def to_s
|
251
|
-
to_hash.to_s
|
252
|
-
end
|
253
|
-
|
254
|
-
# to_body is an alias to to_hash (backward compatibility)
|
255
|
-
# @return [Hash] Returns the object in the form of hash
|
256
|
-
def to_body
|
257
|
-
to_hash
|
258
|
-
end
|
259
|
-
|
260
|
-
# Returns the object in the form of hash
|
261
|
-
# @return [Hash] Returns the object in the form of hash
|
262
|
-
def to_hash
|
263
|
-
hash = {}
|
264
|
-
self.class.attribute_map.each_pair do |attr, param|
|
265
|
-
value = send(attr)
|
266
|
-
if value.nil?
|
267
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
268
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
269
93
|
end
|
270
94
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
end
|
275
|
-
|
276
|
-
# Outputs non-array value in the form of hash
|
277
|
-
# For object, use to_hash. Otherwise, just return the value
|
278
|
-
# @param [Object] value Any valid value
|
279
|
-
# @return [Hash] Returns the value in the form of hash
|
280
|
-
def _to_hash(value)
|
281
|
-
if value.is_a?(Array)
|
282
|
-
value.compact.map { |v| _to_hash(v) }
|
283
|
-
elsif value.is_a?(Hash)
|
284
|
-
{}.tap do |hash|
|
285
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
286
|
-
end
|
287
|
-
elsif value.respond_to? :to_hash
|
288
|
-
value.to_hash
|
289
|
-
else
|
290
|
-
value
|
95
|
+
raise # if no match by now, raise
|
96
|
+
rescue StandardError
|
97
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
291
98
|
end
|
292
99
|
end
|
293
100
|
end
|