snaptrade 2.0.30 → 2.0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +31 -29
- data/README.md +5 -7
- data/lib/snaptrade/api/account_information_api.rb +16 -16
- data/lib/snaptrade/models/account_balance.rb +1 -1
- data/lib/snaptrade/models/account_balance_total.rb +2 -0
- data/lib/snaptrade/models/account_holdings_account.rb +5 -1
- data/lib/snaptrade/models/account_order_record.rb +4 -2
- data/lib/snaptrade/models/amount.rb +2 -0
- data/lib/snaptrade/models/balance.rb +3 -1
- data/lib/snaptrade/models/currency.rb +4 -1
- data/lib/snaptrade/models/exchange.rb +9 -1
- data/lib/snaptrade/models/figi_instrument.rb +3 -1
- data/lib/snaptrade/models/option_brokerage_symbol.rb +3 -1
- data/lib/snaptrade/models/options_position.rb +4 -3
- data/lib/snaptrade/models/options_position_currency.rb +4 -0
- data/lib/snaptrade/models/options_symbol.rb +12 -24
- data/lib/snaptrade/models/position.rb +6 -4
- data/lib/snaptrade/models/position_symbol.rb +6 -1
- data/lib/snaptrade/models/security_type.rb +5 -1
- data/lib/snaptrade/models/snap_trade_holdings_account_account_id.rb +11 -3
- data/lib/snaptrade/models/snap_trade_holdings_total_value.rb +3 -1
- data/lib/snaptrade/models/symbol_figi_instrument.rb +2 -0
- data/lib/snaptrade/models/underlying_symbol.rb +20 -5
- data/lib/snaptrade/models/{model_portfolio.rb → underlying_symbol_exchange.rb} +73 -12
- data/lib/snaptrade/models/{brokerage_symbol.rb → underlying_symbol_type.rb} +28 -38
- data/lib/snaptrade/models/universal_symbol.rb +9 -3
- data/lib/snaptrade/models/{model_asset_class.rb → universal_symbol_currency.rb} +24 -4
- data/lib/snaptrade/models/{portfolio_group.rb → universal_symbol_exchange.rb} +78 -7
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +4 -37
- data/spec/api/account_information_api_spec.rb +3 -3
- data/spec/models/options_symbol_spec.rb +0 -12
- data/spec/models/{brokerage_symbol_option_symbol_spec.rb → underlying_symbol_exchange_spec.rb} +14 -14
- data/spec/models/underlying_symbol_spec.rb +6 -0
- data/spec/models/{trade_impact_spec.rb → underlying_symbol_type_spec.rb} +10 -16
- data/spec/models/{model_portfolio_spec.rb → universal_symbol_currency_spec.rb} +8 -8
- data/spec/models/{trade_spec.rb → universal_symbol_exchange_spec.rb} +13 -13
- metadata +113 -212
- data/lib/snaptrade/models/brokerage_authorization_type.rb +0 -216
- data/lib/snaptrade/models/brokerage_authorization_type_type.rb +0 -37
- data/lib/snaptrade/models/brokerage_symbol_option_symbol.rb +0 -325
- data/lib/snaptrade/models/brokerage_symbol_symbol.rb +0 -339
- data/lib/snaptrade/models/calculated_trade.rb +0 -228
- data/lib/snaptrade/models/excluded_asset.rb +0 -217
- data/lib/snaptrade/models/jwt.rb +0 -217
- data/lib/snaptrade/models/model_asset_class_details.rb +0 -227
- data/lib/snaptrade/models/model_asset_class_target.rb +0 -216
- data/lib/snaptrade/models/model_portfolio_asset_class.rb +0 -249
- data/lib/snaptrade/models/model_portfolio_details.rb +0 -238
- data/lib/snaptrade/models/model_portfolio_security.rb +0 -249
- data/lib/snaptrade/models/model_type.rb +0 -38
- data/lib/snaptrade/models/options_holdings.rb +0 -267
- data/lib/snaptrade/models/portfolio_group_info.rb +0 -325
- data/lib/snaptrade/models/portfolio_group_position.rb +0 -237
- data/lib/snaptrade/models/portfolio_group_settings.rb +0 -276
- data/lib/snaptrade/models/redirect_tokenand_pin.rb +0 -226
- data/lib/snaptrade/models/snap_trade_api_disclaimer_accept_status.rb +0 -226
- data/lib/snaptrade/models/state.rb +0 -40
- data/lib/snaptrade/models/strategy_impact.rb +0 -309
- data/lib/snaptrade/models/strategy_impact_legs_inner.rb +0 -270
- data/lib/snaptrade/models/strategy_order_place.rb +0 -228
- data/lib/snaptrade/models/strategy_order_place_orders_inner.rb +0 -596
- data/lib/snaptrade/models/strategy_order_place_orders_inner_legs_inner.rb +0 -270
- data/lib/snaptrade/models/target_asset.rb +0 -289
- data/lib/snaptrade/models/trade.rb +0 -280
- data/lib/snaptrade/models/trade_action.rb +0 -37
- data/lib/snaptrade/models/trade_execution_status.rb +0 -297
- data/lib/snaptrade/models/trade_execution_status_action.rb +0 -37
- data/lib/snaptrade/models/trade_impact.rb +0 -256
- data/lib/snaptrade/models/user_error_log.rb +0 -262
- data/lib/snaptrade/models/user_settings.rb +0 -298
- data/spec/models/brokerage_authorization_type_spec.rb +0 -29
- data/spec/models/brokerage_authorization_type_type_spec.rb +0 -23
- data/spec/models/brokerage_symbol_spec.rb +0 -59
- data/spec/models/brokerage_symbol_symbol_spec.rb +0 -83
- data/spec/models/calculated_trade_spec.rb +0 -35
- data/spec/models/excluded_asset_spec.rb +0 -29
- data/spec/models/jwt_spec.rb +0 -29
- data/spec/models/model_asset_class_details_spec.rb +0 -35
- data/spec/models/model_asset_class_spec.rb +0 -35
- data/spec/models/model_asset_class_target_spec.rb +0 -29
- data/spec/models/model_portfolio_asset_class_spec.rb +0 -35
- data/spec/models/model_portfolio_details_spec.rb +0 -41
- data/spec/models/model_portfolio_security_spec.rb +0 -35
- data/spec/models/model_type_spec.rb +0 -23
- data/spec/models/options_holdings_spec.rb +0 -59
- data/spec/models/portfolio_group_info_spec.rb +0 -89
- data/spec/models/portfolio_group_position_spec.rb +0 -41
- data/spec/models/portfolio_group_settings_spec.rb +0 -53
- data/spec/models/portfolio_group_spec.rb +0 -35
- data/spec/models/redirect_tokenand_pin_spec.rb +0 -35
- data/spec/models/snap_trade_api_disclaimer_accept_status_spec.rb +0 -35
- data/spec/models/state_spec.rb +0 -23
- data/spec/models/strategy_impact_legs_inner_spec.rb +0 -65
- data/spec/models/strategy_impact_spec.rb +0 -89
- data/spec/models/strategy_order_place_orders_inner_legs_inner_spec.rb +0 -65
- data/spec/models/strategy_order_place_orders_inner_spec.rb +0 -281
- data/spec/models/strategy_order_place_spec.rb +0 -35
- data/spec/models/target_asset_spec.rb +0 -59
- data/spec/models/trade_action_spec.rb +0 -23
- data/spec/models/trade_execution_status_action_spec.rb +0 -23
- data/spec/models/trade_execution_status_spec.rb +0 -77
- data/spec/models/user_error_log_spec.rb +0 -59
- data/spec/models/user_settings_spec.rb +0 -83
@@ -1,249 +0,0 @@
|
|
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
|
-
class ModelPortfolioSecurity
|
15
|
-
attr_accessor :symbol
|
16
|
-
|
17
|
-
attr_accessor :percent
|
18
|
-
|
19
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
-
def self.attribute_map
|
21
|
-
{
|
22
|
-
:'symbol' => :'symbol',
|
23
|
-
:'percent' => :'percent'
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
# Returns all the JSON keys this model knows about
|
28
|
-
def self.acceptable_attributes
|
29
|
-
attribute_map.values
|
30
|
-
end
|
31
|
-
|
32
|
-
# Attribute type mapping.
|
33
|
-
def self.openapi_types
|
34
|
-
{
|
35
|
-
:'symbol' => :'UniversalSymbol',
|
36
|
-
:'percent' => :'Integer'
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
# List of attributes with nullable: true
|
41
|
-
def self.openapi_nullable
|
42
|
-
Set.new([
|
43
|
-
])
|
44
|
-
end
|
45
|
-
|
46
|
-
# Initializes the object
|
47
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
48
|
-
def initialize(attributes = {})
|
49
|
-
if (!attributes.is_a?(Hash))
|
50
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ModelPortfolioSecurity` initialize method"
|
51
|
-
end
|
52
|
-
|
53
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
54
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
55
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
56
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ModelPortfolioSecurity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
57
|
-
end
|
58
|
-
h[k.to_sym] = v
|
59
|
-
}
|
60
|
-
|
61
|
-
if attributes.key?(:'symbol')
|
62
|
-
self.symbol = attributes[:'symbol']
|
63
|
-
end
|
64
|
-
|
65
|
-
if attributes.key?(:'percent')
|
66
|
-
self.percent = attributes[:'percent']
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
71
|
-
# @return Array for valid properties with the reasons
|
72
|
-
def list_invalid_properties
|
73
|
-
invalid_properties = Array.new
|
74
|
-
if !@percent.nil? && @percent > 100
|
75
|
-
invalid_properties.push('invalid value for "percent", must be smaller than or equal to 100.')
|
76
|
-
end
|
77
|
-
|
78
|
-
if !@percent.nil? && @percent < 0
|
79
|
-
invalid_properties.push('invalid value for "percent", must be greater than or equal to 0.')
|
80
|
-
end
|
81
|
-
|
82
|
-
invalid_properties
|
83
|
-
end
|
84
|
-
|
85
|
-
# Check to see if the all the properties in the model are valid
|
86
|
-
# @return true if the model is valid
|
87
|
-
def valid?
|
88
|
-
return false if !@percent.nil? && @percent > 100
|
89
|
-
return false if !@percent.nil? && @percent < 0
|
90
|
-
true
|
91
|
-
end
|
92
|
-
|
93
|
-
# Custom attribute writer method with validation
|
94
|
-
# @param [Object] percent Value to be assigned
|
95
|
-
def percent=(percent)
|
96
|
-
if !percent.nil? && percent > 100
|
97
|
-
fail ArgumentError, 'invalid value for "percent", must be smaller than or equal to 100.'
|
98
|
-
end
|
99
|
-
|
100
|
-
if !percent.nil? && percent < 0
|
101
|
-
fail ArgumentError, 'invalid value for "percent", must be greater than or equal to 0.'
|
102
|
-
end
|
103
|
-
|
104
|
-
@percent = percent
|
105
|
-
end
|
106
|
-
|
107
|
-
# Checks equality by comparing each attribute.
|
108
|
-
# @param [Object] Object to be compared
|
109
|
-
def ==(o)
|
110
|
-
return true if self.equal?(o)
|
111
|
-
self.class == o.class &&
|
112
|
-
symbol == o.symbol &&
|
113
|
-
percent == o.percent
|
114
|
-
end
|
115
|
-
|
116
|
-
# @see the `==` method
|
117
|
-
# @param [Object] Object to be compared
|
118
|
-
def eql?(o)
|
119
|
-
self == o
|
120
|
-
end
|
121
|
-
|
122
|
-
# Calculates hash code according to all attributes.
|
123
|
-
# @return [Integer] Hash code
|
124
|
-
def hash
|
125
|
-
[symbol, percent].hash
|
126
|
-
end
|
127
|
-
|
128
|
-
# Builds the object from hash
|
129
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
130
|
-
# @return [Object] Returns the model itself
|
131
|
-
def self.build_from_hash(attributes)
|
132
|
-
new.build_from_hash(attributes)
|
133
|
-
end
|
134
|
-
|
135
|
-
# Builds the object from hash
|
136
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
137
|
-
# @return [Object] Returns the model itself
|
138
|
-
def build_from_hash(attributes)
|
139
|
-
return nil unless attributes.is_a?(Hash)
|
140
|
-
attributes = attributes.transform_keys(&:to_sym)
|
141
|
-
self.class.openapi_types.each_pair do |key, type|
|
142
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
143
|
-
self.send("#{key}=", nil)
|
144
|
-
elsif type =~ /\AArray<(.*)>/i
|
145
|
-
# check to ensure the input is an array given that the attribute
|
146
|
-
# is documented as an array but the input is not
|
147
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
148
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
149
|
-
end
|
150
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
151
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
self
|
156
|
-
end
|
157
|
-
|
158
|
-
# Deserializes the data based on type
|
159
|
-
# @param string type Data type
|
160
|
-
# @param string value Value to be deserialized
|
161
|
-
# @return [Object] Deserialized data
|
162
|
-
def _deserialize(type, value)
|
163
|
-
case type.to_sym
|
164
|
-
when :Time
|
165
|
-
Time.parse(value)
|
166
|
-
when :Date
|
167
|
-
Date.parse(value)
|
168
|
-
when :String
|
169
|
-
value.to_s
|
170
|
-
when :Integer
|
171
|
-
value.to_i
|
172
|
-
when :Float
|
173
|
-
value.to_f
|
174
|
-
when :Boolean
|
175
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
176
|
-
true
|
177
|
-
else
|
178
|
-
false
|
179
|
-
end
|
180
|
-
when :Object
|
181
|
-
# generic object (usually a Hash), return directly
|
182
|
-
value
|
183
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
184
|
-
inner_type = Regexp.last_match[:inner_type]
|
185
|
-
value.map { |v| _deserialize(inner_type, v) }
|
186
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
187
|
-
k_type = Regexp.last_match[:k_type]
|
188
|
-
v_type = Regexp.last_match[:v_type]
|
189
|
-
{}.tap do |hash|
|
190
|
-
value.each do |k, v|
|
191
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
else # model
|
195
|
-
# models (e.g. Pet) or oneOf
|
196
|
-
klass = SnapTrade.const_get(type)
|
197
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
# Returns the string representation of the object
|
202
|
-
# @return [String] String presentation of the object
|
203
|
-
def to_s
|
204
|
-
to_hash.to_s
|
205
|
-
end
|
206
|
-
|
207
|
-
# to_body is an alias to to_hash (backward compatibility)
|
208
|
-
# @return [Hash] Returns the object in the form of hash
|
209
|
-
def to_body
|
210
|
-
to_hash
|
211
|
-
end
|
212
|
-
|
213
|
-
# Returns the object in the form of hash
|
214
|
-
# @return [Hash] Returns the object in the form of hash
|
215
|
-
def to_hash
|
216
|
-
hash = {}
|
217
|
-
self.class.attribute_map.each_pair do |attr, param|
|
218
|
-
value = self.send(attr)
|
219
|
-
if value.nil?
|
220
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
221
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
222
|
-
end
|
223
|
-
|
224
|
-
hash[param] = _to_hash(value)
|
225
|
-
end
|
226
|
-
hash
|
227
|
-
end
|
228
|
-
|
229
|
-
# Outputs non-array value in the form of hash
|
230
|
-
# For object, use to_hash. Otherwise, just return the value
|
231
|
-
# @param [Object] value Any valid value
|
232
|
-
# @return [Hash] Returns the value in the form of hash
|
233
|
-
def _to_hash(value)
|
234
|
-
if value.is_a?(Array)
|
235
|
-
value.compact.map { |v| _to_hash(v) }
|
236
|
-
elsif value.is_a?(Hash)
|
237
|
-
{}.tap do |hash|
|
238
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
239
|
-
end
|
240
|
-
elsif value.respond_to? :to_hash
|
241
|
-
value.to_hash
|
242
|
-
else
|
243
|
-
value
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
end
|
248
|
-
|
249
|
-
end
|
@@ -1,38 +0,0 @@
|
|
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
|
-
class ModelType
|
15
|
-
NMINUS_1 = -1.freeze
|
16
|
-
N0 = 0.freeze
|
17
|
-
N1 = 1.freeze
|
18
|
-
|
19
|
-
def self.all_vars
|
20
|
-
@all_vars ||= [NMINUS_1, N0, N1].freeze
|
21
|
-
end
|
22
|
-
|
23
|
-
# Builds the enum from string
|
24
|
-
# @param [String] The enum value in the form of the string
|
25
|
-
# @return [String] The enum value
|
26
|
-
def self.build_from_hash(value)
|
27
|
-
new.build_from_hash(value)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Builds the enum from string
|
31
|
-
# @param [String] The enum value in the form of the string
|
32
|
-
# @return [String] The enum value
|
33
|
-
def build_from_hash(value)
|
34
|
-
return value if ModelType.all_vars.include?(value)
|
35
|
-
raise "Invalid ENUM value #{value} for class #ModelType"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,267 +0,0 @@
|
|
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
|
-
# Option Holdings
|
15
|
-
class OptionsHoldings
|
16
|
-
# Options information
|
17
|
-
attr_accessor :id
|
18
|
-
|
19
|
-
attr_accessor :symbol
|
20
|
-
|
21
|
-
attr_accessor :option_symbol
|
22
|
-
|
23
|
-
# Trade Price if limit or stop limit order
|
24
|
-
attr_accessor :price
|
25
|
-
|
26
|
-
attr_accessor :currency
|
27
|
-
|
28
|
-
# Average purchase price for this position
|
29
|
-
attr_accessor :average_purchase_price
|
30
|
-
|
31
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
32
|
-
def self.attribute_map
|
33
|
-
{
|
34
|
-
:'id' => :'id',
|
35
|
-
:'symbol' => :'symbol',
|
36
|
-
:'option_symbol' => :'option_symbol',
|
37
|
-
:'price' => :'price',
|
38
|
-
:'currency' => :'currency',
|
39
|
-
:'average_purchase_price' => :'average_purchase_price'
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns all the JSON keys this model knows about
|
44
|
-
def self.acceptable_attributes
|
45
|
-
attribute_map.values
|
46
|
-
end
|
47
|
-
|
48
|
-
# Attribute type mapping.
|
49
|
-
def self.openapi_types
|
50
|
-
{
|
51
|
-
:'id' => :'String',
|
52
|
-
:'symbol' => :'String',
|
53
|
-
:'option_symbol' => :'OptionsSymbol',
|
54
|
-
:'price' => :'Float',
|
55
|
-
:'currency' => :'Currency',
|
56
|
-
:'average_purchase_price' => :'Float'
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
# List of attributes with nullable: true
|
61
|
-
def self.openapi_nullable
|
62
|
-
Set.new([
|
63
|
-
:'price',
|
64
|
-
:'average_purchase_price'
|
65
|
-
])
|
66
|
-
end
|
67
|
-
|
68
|
-
# Initializes the object
|
69
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
70
|
-
def initialize(attributes = {})
|
71
|
-
if (!attributes.is_a?(Hash))
|
72
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::OptionsHoldings` initialize method"
|
73
|
-
end
|
74
|
-
|
75
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
76
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
77
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
78
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::OptionsHoldings`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
79
|
-
end
|
80
|
-
h[k.to_sym] = v
|
81
|
-
}
|
82
|
-
|
83
|
-
if attributes.key?(:'id')
|
84
|
-
self.id = attributes[:'id']
|
85
|
-
end
|
86
|
-
|
87
|
-
if attributes.key?(:'symbol')
|
88
|
-
self.symbol = attributes[:'symbol']
|
89
|
-
end
|
90
|
-
|
91
|
-
if attributes.key?(:'option_symbol')
|
92
|
-
self.option_symbol = attributes[:'option_symbol']
|
93
|
-
end
|
94
|
-
|
95
|
-
if attributes.key?(:'price')
|
96
|
-
self.price = attributes[:'price']
|
97
|
-
end
|
98
|
-
|
99
|
-
if attributes.key?(:'currency')
|
100
|
-
self.currency = attributes[:'currency']
|
101
|
-
end
|
102
|
-
|
103
|
-
if attributes.key?(:'average_purchase_price')
|
104
|
-
self.average_purchase_price = attributes[:'average_purchase_price']
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
109
|
-
# @return Array for valid properties with the reasons
|
110
|
-
def list_invalid_properties
|
111
|
-
invalid_properties = Array.new
|
112
|
-
invalid_properties
|
113
|
-
end
|
114
|
-
|
115
|
-
# Check to see if the all the properties in the model are valid
|
116
|
-
# @return true if the model is valid
|
117
|
-
def valid?
|
118
|
-
true
|
119
|
-
end
|
120
|
-
|
121
|
-
# Checks equality by comparing each attribute.
|
122
|
-
# @param [Object] Object to be compared
|
123
|
-
def ==(o)
|
124
|
-
return true if self.equal?(o)
|
125
|
-
self.class == o.class &&
|
126
|
-
id == o.id &&
|
127
|
-
symbol == o.symbol &&
|
128
|
-
option_symbol == o.option_symbol &&
|
129
|
-
price == o.price &&
|
130
|
-
currency == o.currency &&
|
131
|
-
average_purchase_price == o.average_purchase_price
|
132
|
-
end
|
133
|
-
|
134
|
-
# @see the `==` method
|
135
|
-
# @param [Object] Object to be compared
|
136
|
-
def eql?(o)
|
137
|
-
self == o
|
138
|
-
end
|
139
|
-
|
140
|
-
# Calculates hash code according to all attributes.
|
141
|
-
# @return [Integer] Hash code
|
142
|
-
def hash
|
143
|
-
[id, symbol, option_symbol, price, currency, average_purchase_price].hash
|
144
|
-
end
|
145
|
-
|
146
|
-
# Builds the object from hash
|
147
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
148
|
-
# @return [Object] Returns the model itself
|
149
|
-
def self.build_from_hash(attributes)
|
150
|
-
new.build_from_hash(attributes)
|
151
|
-
end
|
152
|
-
|
153
|
-
# Builds the object from hash
|
154
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
155
|
-
# @return [Object] Returns the model itself
|
156
|
-
def build_from_hash(attributes)
|
157
|
-
return nil unless attributes.is_a?(Hash)
|
158
|
-
attributes = attributes.transform_keys(&:to_sym)
|
159
|
-
self.class.openapi_types.each_pair do |key, type|
|
160
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
161
|
-
self.send("#{key}=", nil)
|
162
|
-
elsif type =~ /\AArray<(.*)>/i
|
163
|
-
# check to ensure the input is an array given that the attribute
|
164
|
-
# is documented as an array but the input is not
|
165
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
166
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
167
|
-
end
|
168
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
169
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
self
|
174
|
-
end
|
175
|
-
|
176
|
-
# Deserializes the data based on type
|
177
|
-
# @param string type Data type
|
178
|
-
# @param string value Value to be deserialized
|
179
|
-
# @return [Object] Deserialized data
|
180
|
-
def _deserialize(type, value)
|
181
|
-
case type.to_sym
|
182
|
-
when :Time
|
183
|
-
Time.parse(value)
|
184
|
-
when :Date
|
185
|
-
Date.parse(value)
|
186
|
-
when :String
|
187
|
-
value.to_s
|
188
|
-
when :Integer
|
189
|
-
value.to_i
|
190
|
-
when :Float
|
191
|
-
value.to_f
|
192
|
-
when :Boolean
|
193
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
194
|
-
true
|
195
|
-
else
|
196
|
-
false
|
197
|
-
end
|
198
|
-
when :Object
|
199
|
-
# generic object (usually a Hash), return directly
|
200
|
-
value
|
201
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
202
|
-
inner_type = Regexp.last_match[:inner_type]
|
203
|
-
value.map { |v| _deserialize(inner_type, v) }
|
204
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
205
|
-
k_type = Regexp.last_match[:k_type]
|
206
|
-
v_type = Regexp.last_match[:v_type]
|
207
|
-
{}.tap do |hash|
|
208
|
-
value.each do |k, v|
|
209
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
else # model
|
213
|
-
# models (e.g. Pet) or oneOf
|
214
|
-
klass = SnapTrade.const_get(type)
|
215
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
# Returns the string representation of the object
|
220
|
-
# @return [String] String presentation of the object
|
221
|
-
def to_s
|
222
|
-
to_hash.to_s
|
223
|
-
end
|
224
|
-
|
225
|
-
# to_body is an alias to to_hash (backward compatibility)
|
226
|
-
# @return [Hash] Returns the object in the form of hash
|
227
|
-
def to_body
|
228
|
-
to_hash
|
229
|
-
end
|
230
|
-
|
231
|
-
# Returns the object in the form of hash
|
232
|
-
# @return [Hash] Returns the object in the form of hash
|
233
|
-
def to_hash
|
234
|
-
hash = {}
|
235
|
-
self.class.attribute_map.each_pair do |attr, param|
|
236
|
-
value = self.send(attr)
|
237
|
-
if value.nil?
|
238
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
239
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
240
|
-
end
|
241
|
-
|
242
|
-
hash[param] = _to_hash(value)
|
243
|
-
end
|
244
|
-
hash
|
245
|
-
end
|
246
|
-
|
247
|
-
# Outputs non-array value in the form of hash
|
248
|
-
# For object, use to_hash. Otherwise, just return the value
|
249
|
-
# @param [Object] value Any valid value
|
250
|
-
# @return [Hash] Returns the value in the form of hash
|
251
|
-
def _to_hash(value)
|
252
|
-
if value.is_a?(Array)
|
253
|
-
value.compact.map { |v| _to_hash(v) }
|
254
|
-
elsif value.is_a?(Hash)
|
255
|
-
{}.tap do |hash|
|
256
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
257
|
-
end
|
258
|
-
elsif value.respond_to? :to_hash
|
259
|
-
value.to_hash
|
260
|
-
else
|
261
|
-
value
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
end
|
266
|
-
|
267
|
-
end
|