snaptrade 2.0.34 → 2.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +57 -35
- data/lib/snaptrade/api/account_information_api.rb +4 -4
- data/lib/snaptrade/api/authentication_api.rb +44 -46
- data/lib/snaptrade/api/connections_api.rb +8 -8
- data/lib/snaptrade/api/transactions_and_reporting_api.rb +36 -28
- data/lib/snaptrade/models/account.rb +7 -7
- data/lib/snaptrade/models/account_order_record.rb +1 -1
- data/lib/snaptrade/models/account_order_record_universal_symbol.rb +2 -2
- data/lib/snaptrade/models/account_simple.rb +4 -1
- data/lib/snaptrade/models/delete_user_response.rb +12 -3
- data/lib/snaptrade/models/login_redirect_uri.rb +3 -2
- data/lib/snaptrade/models/snap_trade_login_user_request_body.rb +10 -6
- data/lib/snaptrade/models/symbol.rb +16 -10
- data/lib/snaptrade/models/{universal_symbol_currency.rb → symbol_currency.rb} +3 -3
- data/lib/snaptrade/models/{universal_symbol_exchange.rb → symbol_exchange.rb} +3 -3
- data/lib/snaptrade/models/underlying_symbol.rb +1 -1
- data/lib/snaptrade/models/universal_activity.rb +91 -81
- data/lib/snaptrade/models/universal_activity_currency.rb +245 -0
- data/lib/snaptrade/models/universal_activity_option_symbol.rb +314 -0
- data/lib/snaptrade/models/universal_activity_symbol.rb +304 -0
- data/lib/snaptrade/models/universal_symbol.rb +2 -2
- data/lib/snaptrade/models/user_i_dand_secret.rb +1 -1
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +5 -2
- data/spec/api/account_information_api_spec.rb +1 -1
- data/spec/api/authentication_api_spec.rb +7 -7
- data/spec/api/connections_api_spec.rb +2 -2
- data/spec/api/transactions_and_reporting_api_spec.rb +7 -7
- data/spec/models/delete_user_response_spec.rb +6 -0
- data/spec/models/{universal_symbol_currency_spec.rb → symbol_currency_spec.rb} +6 -6
- data/spec/models/{universal_symbol_exchange_spec.rb → symbol_exchange_spec.rb} +6 -6
- data/spec/models/symbol_spec.rb +1 -1
- data/spec/models/universal_activity_currency_spec.rb +41 -0
- data/spec/models/universal_activity_option_symbol_spec.rb +65 -0
- data/spec/models/universal_activity_spec.rb +15 -15
- data/spec/models/universal_activity_symbol_spec.rb +77 -0
- metadata +17 -8
@@ -13,65 +13,73 @@ require 'time'
|
|
13
13
|
module SnapTrade
|
14
14
|
# A transaction or activity from an institution
|
15
15
|
class UniversalActivity
|
16
|
+
# Unique identifier for the transaction. This is the ID used to reference the transaction in SnapTrade. Please note that this ID _can_ change if the transaction is deleted and re-added. Under normal circumstances, SnapTrade does not delete transactions. The only time this would happen is if SnapTrade re-fetches and reprocesses the data from the brokerage, which is rare. If you require a stable ID, please let us know and we can work with you to provide one.
|
16
17
|
attr_accessor :id
|
17
18
|
|
18
19
|
attr_accessor :account
|
19
20
|
|
20
|
-
attr_accessor :
|
21
|
+
attr_accessor :symbol
|
21
22
|
|
22
|
-
attr_accessor :
|
23
|
+
attr_accessor :option_symbol
|
23
24
|
|
24
|
-
|
25
|
+
# The price of the security for the transaction. This is mostly applicable to `BUY`, `SELL`, and `DIVIDEND` transactions.
|
26
|
+
attr_accessor :price
|
25
27
|
|
26
|
-
|
28
|
+
# The number of units of the security for the transaction. This is mostly applicable to `BUY`, `SELL`, and `DIVIDEND` transactions.
|
29
|
+
attr_accessor :units
|
27
30
|
|
28
|
-
# The
|
29
|
-
attr_accessor :
|
31
|
+
# The amount of the transaction denominated in `currency`. This can be positive or negative. In general, transactions that positively affect the account balance (like sell, deposits, dividends, etc) will have a positive amount, while transactions that negatively affect the account balance (like buy, withdrawals, fees, etc) will have a negative amount.
|
32
|
+
attr_accessor :amount
|
30
33
|
|
31
|
-
attr_accessor :
|
34
|
+
attr_accessor :currency
|
32
35
|
|
33
|
-
#
|
34
|
-
attr_accessor :
|
36
|
+
# A string representing the type of transaction. SnapTrade does a best effort to categorize the brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY - SELL - DIVIDEND - CONTRIBUTION - WITHDRAWAL - REI - INTEREST - FEE
|
37
|
+
attr_accessor :type
|
35
38
|
|
36
|
-
|
39
|
+
# If an option `BUY` or `SELL` transaction, this further specifies the type of action. The possible values are: - BUY_TO_OPEN - BUY_TO_CLOSE - SELL_TO_OPEN - SELL_TO_CLOSE
|
40
|
+
attr_accessor :option_type
|
37
41
|
|
38
|
-
|
42
|
+
# A human-readable description of the transaction. This is usually the brokerage's description of the transaction.
|
43
|
+
attr_accessor :description
|
39
44
|
|
40
|
-
#
|
41
|
-
attr_accessor :
|
45
|
+
# The recorded time for the transaction. The granularity of this timestamp depends on the brokerage. Some brokerages provide the exact time of the transaction, while others provide only the date. Please check the [integrations page](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=6fab8012ade6441fa0c6d9af9c55ce3a) for the specific brokerage to see the granularity of the timestamps. Note that even though the field is named `trade_date`, it can represent any type of transaction, not just trades.
|
46
|
+
attr_accessor :trade_date
|
42
47
|
|
43
|
-
|
48
|
+
# The date on which the transaction is settled.
|
49
|
+
attr_accessor :settlement_date
|
44
50
|
|
45
|
-
|
51
|
+
# Any fee associated with the transaction if provided by the brokerage.
|
52
|
+
attr_accessor :fee
|
46
53
|
|
47
|
-
|
54
|
+
# The forex conversion rate involved in the transaction if provided by the brokerage. Used in cases where securities of one currency are purchased in a different currency, and the forex conversion is automatic. In those cases, price, amount and fee will be in the top level currency (activity -> currency)
|
55
|
+
attr_accessor :fx_rate
|
48
56
|
|
49
|
-
#
|
50
|
-
attr_accessor :
|
57
|
+
# The institution that the transaction is associated with. This is usually the brokerage name.
|
58
|
+
attr_accessor :institution
|
51
59
|
|
52
|
-
#
|
53
|
-
attr_accessor :
|
60
|
+
# Reference ID from brokerage used to identify related transactions. For example if an order comprises of several transactions (buy, fee, fx), they can be grouped if they share the same `external_reference_id`
|
61
|
+
attr_accessor :external_reference_id
|
54
62
|
|
55
63
|
# Attribute mapping from ruby-style variable name to JSON key.
|
56
64
|
def self.attribute_map
|
57
65
|
{
|
58
66
|
:'id' => :'id',
|
59
67
|
:'account' => :'account',
|
68
|
+
:'symbol' => :'symbol',
|
69
|
+
:'option_symbol' => :'option_symbol',
|
70
|
+
:'price' => :'price',
|
71
|
+
:'units' => :'units',
|
60
72
|
:'amount' => :'amount',
|
61
73
|
:'currency' => :'currency',
|
74
|
+
:'type' => :'type',
|
75
|
+
:'option_type' => :'option_type',
|
62
76
|
:'description' => :'description',
|
77
|
+
:'trade_date' => :'trade_date',
|
78
|
+
:'settlement_date' => :'settlement_date',
|
63
79
|
:'fee' => :'fee',
|
64
80
|
:'fx_rate' => :'fx_rate',
|
65
81
|
:'institution' => :'institution',
|
66
|
-
:'
|
67
|
-
:'price' => :'price',
|
68
|
-
:'settlement_date' => :'settlement_date',
|
69
|
-
:'external_reference_id' => :'external_reference_id',
|
70
|
-
:'symbol' => :'symbol',
|
71
|
-
:'option_symbol' => :'option_symbol',
|
72
|
-
:'trade_date' => :'trade_date',
|
73
|
-
:'type' => :'type',
|
74
|
-
:'units' => :'units'
|
82
|
+
:'external_reference_id' => :'external_reference_id'
|
75
83
|
}
|
76
84
|
end
|
77
85
|
|
@@ -85,31 +93,33 @@ module SnapTrade
|
|
85
93
|
{
|
86
94
|
:'id' => :'String',
|
87
95
|
:'account' => :'AccountSimple',
|
96
|
+
:'symbol' => :'UniversalActivitySymbol',
|
97
|
+
:'option_symbol' => :'UniversalActivityOptionSymbol',
|
98
|
+
:'price' => :'Float',
|
99
|
+
:'units' => :'Float',
|
88
100
|
:'amount' => :'Float',
|
89
|
-
:'currency' => :'
|
101
|
+
:'currency' => :'UniversalActivityCurrency',
|
102
|
+
:'type' => :'String',
|
103
|
+
:'option_type' => :'String',
|
90
104
|
:'description' => :'String',
|
105
|
+
:'trade_date' => :'Time',
|
106
|
+
:'settlement_date' => :'Time',
|
91
107
|
:'fee' => :'Float',
|
92
108
|
:'fx_rate' => :'Float',
|
93
109
|
:'institution' => :'String',
|
94
|
-
:'
|
95
|
-
:'price' => :'Float',
|
96
|
-
:'settlement_date' => :'String',
|
97
|
-
:'external_reference_id' => :'String',
|
98
|
-
:'symbol' => :'Symbol',
|
99
|
-
:'option_symbol' => :'OptionsSymbol',
|
100
|
-
:'trade_date' => :'String',
|
101
|
-
:'type' => :'String',
|
102
|
-
:'units' => :'Float'
|
110
|
+
:'external_reference_id' => :'String'
|
103
111
|
}
|
104
112
|
end
|
105
113
|
|
106
114
|
# List of attributes with nullable: true
|
107
115
|
def self.openapi_nullable
|
108
116
|
Set.new([
|
117
|
+
:'symbol',
|
118
|
+
:'option_symbol',
|
109
119
|
:'amount',
|
110
|
-
:'fx_rate',
|
111
|
-
:'external_reference_id',
|
112
120
|
:'trade_date',
|
121
|
+
:'fx_rate',
|
122
|
+
:'external_reference_id'
|
113
123
|
])
|
114
124
|
end
|
115
125
|
|
@@ -136,64 +146,64 @@ module SnapTrade
|
|
136
146
|
self.account = attributes[:'account']
|
137
147
|
end
|
138
148
|
|
139
|
-
if attributes.key?(:'
|
140
|
-
self.
|
149
|
+
if attributes.key?(:'symbol')
|
150
|
+
self.symbol = attributes[:'symbol']
|
141
151
|
end
|
142
152
|
|
143
|
-
if attributes.key?(:'
|
144
|
-
self.
|
153
|
+
if attributes.key?(:'option_symbol')
|
154
|
+
self.option_symbol = attributes[:'option_symbol']
|
145
155
|
end
|
146
156
|
|
147
|
-
if attributes.key?(:'
|
148
|
-
self.
|
157
|
+
if attributes.key?(:'price')
|
158
|
+
self.price = attributes[:'price']
|
149
159
|
end
|
150
160
|
|
151
|
-
if attributes.key?(:'
|
152
|
-
self.
|
161
|
+
if attributes.key?(:'units')
|
162
|
+
self.units = attributes[:'units']
|
153
163
|
end
|
154
164
|
|
155
|
-
if attributes.key?(:'
|
156
|
-
self.
|
165
|
+
if attributes.key?(:'amount')
|
166
|
+
self.amount = attributes[:'amount']
|
157
167
|
end
|
158
168
|
|
159
|
-
if attributes.key?(:'
|
160
|
-
self.
|
169
|
+
if attributes.key?(:'currency')
|
170
|
+
self.currency = attributes[:'currency']
|
161
171
|
end
|
162
172
|
|
163
|
-
if attributes.key?(:'
|
164
|
-
self.
|
173
|
+
if attributes.key?(:'type')
|
174
|
+
self.type = attributes[:'type']
|
165
175
|
end
|
166
176
|
|
167
|
-
if attributes.key?(:'
|
168
|
-
self.
|
177
|
+
if attributes.key?(:'option_type')
|
178
|
+
self.option_type = attributes[:'option_type']
|
169
179
|
end
|
170
180
|
|
171
|
-
if attributes.key?(:'
|
172
|
-
self.
|
181
|
+
if attributes.key?(:'description')
|
182
|
+
self.description = attributes[:'description']
|
173
183
|
end
|
174
184
|
|
175
|
-
if attributes.key?(:'
|
176
|
-
self.
|
185
|
+
if attributes.key?(:'trade_date')
|
186
|
+
self.trade_date = attributes[:'trade_date']
|
177
187
|
end
|
178
188
|
|
179
|
-
if attributes.key?(:'
|
180
|
-
self.
|
189
|
+
if attributes.key?(:'settlement_date')
|
190
|
+
self.settlement_date = attributes[:'settlement_date']
|
181
191
|
end
|
182
192
|
|
183
|
-
if attributes.key?(:'
|
184
|
-
self.
|
193
|
+
if attributes.key?(:'fee')
|
194
|
+
self.fee = attributes[:'fee']
|
185
195
|
end
|
186
196
|
|
187
|
-
if attributes.key?(:'
|
188
|
-
self.
|
197
|
+
if attributes.key?(:'fx_rate')
|
198
|
+
self.fx_rate = attributes[:'fx_rate']
|
189
199
|
end
|
190
200
|
|
191
|
-
if attributes.key?(:'
|
192
|
-
self.
|
201
|
+
if attributes.key?(:'institution')
|
202
|
+
self.institution = attributes[:'institution']
|
193
203
|
end
|
194
204
|
|
195
|
-
if attributes.key?(:'
|
196
|
-
self.
|
205
|
+
if attributes.key?(:'external_reference_id')
|
206
|
+
self.external_reference_id = attributes[:'external_reference_id']
|
197
207
|
end
|
198
208
|
end
|
199
209
|
|
@@ -217,21 +227,21 @@ module SnapTrade
|
|
217
227
|
self.class == o.class &&
|
218
228
|
id == o.id &&
|
219
229
|
account == o.account &&
|
230
|
+
symbol == o.symbol &&
|
231
|
+
option_symbol == o.option_symbol &&
|
232
|
+
price == o.price &&
|
233
|
+
units == o.units &&
|
220
234
|
amount == o.amount &&
|
221
235
|
currency == o.currency &&
|
236
|
+
type == o.type &&
|
237
|
+
option_type == o.option_type &&
|
222
238
|
description == o.description &&
|
239
|
+
trade_date == o.trade_date &&
|
240
|
+
settlement_date == o.settlement_date &&
|
223
241
|
fee == o.fee &&
|
224
242
|
fx_rate == o.fx_rate &&
|
225
243
|
institution == o.institution &&
|
226
|
-
|
227
|
-
price == o.price &&
|
228
|
-
settlement_date == o.settlement_date &&
|
229
|
-
external_reference_id == o.external_reference_id &&
|
230
|
-
symbol == o.symbol &&
|
231
|
-
option_symbol == o.option_symbol &&
|
232
|
-
trade_date == o.trade_date &&
|
233
|
-
type == o.type &&
|
234
|
-
units == o.units
|
244
|
+
external_reference_id == o.external_reference_id
|
235
245
|
end
|
236
246
|
|
237
247
|
# @see the `==` method
|
@@ -243,7 +253,7 @@ module SnapTrade
|
|
243
253
|
# Calculates hash code according to all attributes.
|
244
254
|
# @return [Integer] Hash code
|
245
255
|
def hash
|
246
|
-
[id, account,
|
256
|
+
[id, account, symbol, option_symbol, price, units, amount, currency, type, option_type, description, trade_date, settlement_date, fee, fx_rate, institution, external_reference_id].hash
|
247
257
|
end
|
248
258
|
|
249
259
|
# Builds the object from hash
|
@@ -0,0 +1,245 @@
|
|
1
|
+
=begin
|
2
|
+
#SnapTrade
|
3
|
+
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: api@snaptrade.com
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'date'
|
11
|
+
require 'time'
|
12
|
+
|
13
|
+
module SnapTrade
|
14
|
+
# The currency in which the transaction `price` and `amount` is denominated.
|
15
|
+
class UniversalActivityCurrency
|
16
|
+
# Unique identifier for the currency. This is the UUID used to reference the currency in SnapTrade.
|
17
|
+
attr_accessor :id
|
18
|
+
|
19
|
+
# The ISO-4217 currency code for the currency.
|
20
|
+
attr_accessor :code
|
21
|
+
|
22
|
+
# A human-friendly name of the currency.
|
23
|
+
attr_accessor :name
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'id' => :'id',
|
29
|
+
:'code' => :'code',
|
30
|
+
:'name' => :'name'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns all the JSON keys this model knows about
|
35
|
+
def self.acceptable_attributes
|
36
|
+
attribute_map.values
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.openapi_types
|
41
|
+
{
|
42
|
+
:'id' => :'String',
|
43
|
+
:'code' => :'String',
|
44
|
+
:'name' => :'String'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# List of attributes with nullable: true
|
49
|
+
def self.openapi_nullable
|
50
|
+
Set.new([
|
51
|
+
])
|
52
|
+
end
|
53
|
+
|
54
|
+
# List of class defined in allOf (OpenAPI v3)
|
55
|
+
def self.openapi_all_of
|
56
|
+
[
|
57
|
+
:'Currency'
|
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 `SnapTrade::UniversalActivityCurrency` 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 `SnapTrade::UniversalActivityCurrency`. 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?(:'code')
|
81
|
+
self.code = attributes[:'code']
|
82
|
+
end
|
83
|
+
|
84
|
+
if attributes.key?(:'name')
|
85
|
+
self.name = attributes[:'name']
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
90
|
+
# @return Array for valid properties with the reasons
|
91
|
+
def list_invalid_properties
|
92
|
+
invalid_properties = Array.new
|
93
|
+
invalid_properties
|
94
|
+
end
|
95
|
+
|
96
|
+
# Check to see if the all the properties in the model are valid
|
97
|
+
# @return true if the model is valid
|
98
|
+
def valid?
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
# Checks equality by comparing each attribute.
|
103
|
+
# @param [Object] Object to be compared
|
104
|
+
def ==(o)
|
105
|
+
return true if self.equal?(o)
|
106
|
+
self.class == o.class &&
|
107
|
+
id == o.id &&
|
108
|
+
code == o.code &&
|
109
|
+
name == o.name
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see the `==` method
|
113
|
+
# @param [Object] Object to be compared
|
114
|
+
def eql?(o)
|
115
|
+
self == o
|
116
|
+
end
|
117
|
+
|
118
|
+
# Calculates hash code according to all attributes.
|
119
|
+
# @return [Integer] Hash code
|
120
|
+
def hash
|
121
|
+
[id, code, name].hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def self.build_from_hash(attributes)
|
128
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
135
|
+
return nil unless attributes.is_a?(Hash)
|
136
|
+
attributes = attributes.transform_keys(&:to_sym)
|
137
|
+
self.class.openapi_types.each_pair do |key, type|
|
138
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
139
|
+
self.send("#{key}=", nil)
|
140
|
+
elsif type =~ /\AArray<(.*)>/i
|
141
|
+
# check to ensure the input is an array given that the attribute
|
142
|
+
# is documented as an array but the input is not
|
143
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
144
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
145
|
+
end
|
146
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
147
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
self
|
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 _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 = SnapTrade.const_get(type)
|
193
|
+
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
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|