snaptrade 2.0.31 → 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 +4 -2
- data/lib/snaptrade/api/account_information_api.rb +6 -2
- data/lib/snaptrade/models/account_holdings_account.rb +1 -1
- data/lib/snaptrade/models/account_order_record.rb +4 -2
- 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 +1 -1
- data/lib/snaptrade/models/options_position_currency.rb +1 -0
- data/lib/snaptrade/models/options_symbol.rb +12 -24
- data/lib/snaptrade/models/position_symbol.rb +6 -1
- data/lib/snaptrade/models/security_type.rb +5 -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 -36
- data/spec/api/account_information_api_spec.rb +1 -1
- 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 -209
- 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/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/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,270 +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 StrategyOrderPlaceOrdersInnerLegsInner
|
15
|
-
attr_accessor :leg_id
|
16
|
-
|
17
|
-
attr_accessor :symbol
|
18
|
-
|
19
|
-
attr_accessor :symbol_id
|
20
|
-
|
21
|
-
attr_accessor :leg_ratio_quantity
|
22
|
-
|
23
|
-
attr_accessor :side
|
24
|
-
|
25
|
-
attr_accessor :avg_exec_price
|
26
|
-
|
27
|
-
attr_accessor :last_exec_price
|
28
|
-
|
29
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
-
def self.attribute_map
|
31
|
-
{
|
32
|
-
:'leg_id' => :'legId',
|
33
|
-
:'symbol' => :'symbol',
|
34
|
-
:'symbol_id' => :'symbolId',
|
35
|
-
:'leg_ratio_quantity' => :'legRatioQuantity',
|
36
|
-
:'side' => :'side',
|
37
|
-
:'avg_exec_price' => :'avgExecPrice',
|
38
|
-
:'last_exec_price' => :'lastExecPrice'
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns all the JSON keys this model knows about
|
43
|
-
def self.acceptable_attributes
|
44
|
-
attribute_map.values
|
45
|
-
end
|
46
|
-
|
47
|
-
# Attribute type mapping.
|
48
|
-
def self.openapi_types
|
49
|
-
{
|
50
|
-
:'leg_id' => :'Integer',
|
51
|
-
:'symbol' => :'String',
|
52
|
-
:'symbol_id' => :'Integer',
|
53
|
-
:'leg_ratio_quantity' => :'Integer',
|
54
|
-
:'side' => :'String',
|
55
|
-
:'avg_exec_price' => :'Integer',
|
56
|
-
:'last_exec_price' => :'String'
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
# List of attributes with nullable: true
|
61
|
-
def self.openapi_nullable
|
62
|
-
Set.new([
|
63
|
-
])
|
64
|
-
end
|
65
|
-
|
66
|
-
# Initializes the object
|
67
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
68
|
-
def initialize(attributes = {})
|
69
|
-
if (!attributes.is_a?(Hash))
|
70
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::StrategyOrderPlaceOrdersInnerLegsInner` initialize method"
|
71
|
-
end
|
72
|
-
|
73
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
75
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
76
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::StrategyOrderPlaceOrdersInnerLegsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
77
|
-
end
|
78
|
-
h[k.to_sym] = v
|
79
|
-
}
|
80
|
-
|
81
|
-
if attributes.key?(:'leg_id')
|
82
|
-
self.leg_id = attributes[:'leg_id']
|
83
|
-
end
|
84
|
-
|
85
|
-
if attributes.key?(:'symbol')
|
86
|
-
self.symbol = attributes[:'symbol']
|
87
|
-
end
|
88
|
-
|
89
|
-
if attributes.key?(:'symbol_id')
|
90
|
-
self.symbol_id = attributes[:'symbol_id']
|
91
|
-
end
|
92
|
-
|
93
|
-
if attributes.key?(:'leg_ratio_quantity')
|
94
|
-
self.leg_ratio_quantity = attributes[:'leg_ratio_quantity']
|
95
|
-
end
|
96
|
-
|
97
|
-
if attributes.key?(:'side')
|
98
|
-
self.side = attributes[:'side']
|
99
|
-
end
|
100
|
-
|
101
|
-
if attributes.key?(:'avg_exec_price')
|
102
|
-
self.avg_exec_price = attributes[:'avg_exec_price']
|
103
|
-
end
|
104
|
-
|
105
|
-
if attributes.key?(:'last_exec_price')
|
106
|
-
self.last_exec_price = attributes[:'last_exec_price']
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
111
|
-
# @return Array for valid properties with the reasons
|
112
|
-
def list_invalid_properties
|
113
|
-
invalid_properties = Array.new
|
114
|
-
invalid_properties
|
115
|
-
end
|
116
|
-
|
117
|
-
# Check to see if the all the properties in the model are valid
|
118
|
-
# @return true if the model is valid
|
119
|
-
def valid?
|
120
|
-
true
|
121
|
-
end
|
122
|
-
|
123
|
-
# Checks equality by comparing each attribute.
|
124
|
-
# @param [Object] Object to be compared
|
125
|
-
def ==(o)
|
126
|
-
return true if self.equal?(o)
|
127
|
-
self.class == o.class &&
|
128
|
-
leg_id == o.leg_id &&
|
129
|
-
symbol == o.symbol &&
|
130
|
-
symbol_id == o.symbol_id &&
|
131
|
-
leg_ratio_quantity == o.leg_ratio_quantity &&
|
132
|
-
side == o.side &&
|
133
|
-
avg_exec_price == o.avg_exec_price &&
|
134
|
-
last_exec_price == o.last_exec_price
|
135
|
-
end
|
136
|
-
|
137
|
-
# @see the `==` method
|
138
|
-
# @param [Object] Object to be compared
|
139
|
-
def eql?(o)
|
140
|
-
self == o
|
141
|
-
end
|
142
|
-
|
143
|
-
# Calculates hash code according to all attributes.
|
144
|
-
# @return [Integer] Hash code
|
145
|
-
def hash
|
146
|
-
[leg_id, symbol, symbol_id, leg_ratio_quantity, side, avg_exec_price, last_exec_price].hash
|
147
|
-
end
|
148
|
-
|
149
|
-
# Builds the object from hash
|
150
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
151
|
-
# @return [Object] Returns the model itself
|
152
|
-
def self.build_from_hash(attributes)
|
153
|
-
new.build_from_hash(attributes)
|
154
|
-
end
|
155
|
-
|
156
|
-
# Builds the object from hash
|
157
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
158
|
-
# @return [Object] Returns the model itself
|
159
|
-
def build_from_hash(attributes)
|
160
|
-
return nil unless attributes.is_a?(Hash)
|
161
|
-
attributes = attributes.transform_keys(&:to_sym)
|
162
|
-
self.class.openapi_types.each_pair do |key, type|
|
163
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
164
|
-
self.send("#{key}=", nil)
|
165
|
-
elsif type =~ /\AArray<(.*)>/i
|
166
|
-
# check to ensure the input is an array given that the attribute
|
167
|
-
# is documented as an array but the input is not
|
168
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
169
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
170
|
-
end
|
171
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
172
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
self
|
177
|
-
end
|
178
|
-
|
179
|
-
# Deserializes the data based on type
|
180
|
-
# @param string type Data type
|
181
|
-
# @param string value Value to be deserialized
|
182
|
-
# @return [Object] Deserialized data
|
183
|
-
def _deserialize(type, value)
|
184
|
-
case type.to_sym
|
185
|
-
when :Time
|
186
|
-
Time.parse(value)
|
187
|
-
when :Date
|
188
|
-
Date.parse(value)
|
189
|
-
when :String
|
190
|
-
value.to_s
|
191
|
-
when :Integer
|
192
|
-
value.to_i
|
193
|
-
when :Float
|
194
|
-
value.to_f
|
195
|
-
when :Boolean
|
196
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
197
|
-
true
|
198
|
-
else
|
199
|
-
false
|
200
|
-
end
|
201
|
-
when :Object
|
202
|
-
# generic object (usually a Hash), return directly
|
203
|
-
value
|
204
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
205
|
-
inner_type = Regexp.last_match[:inner_type]
|
206
|
-
value.map { |v| _deserialize(inner_type, v) }
|
207
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
208
|
-
k_type = Regexp.last_match[:k_type]
|
209
|
-
v_type = Regexp.last_match[:v_type]
|
210
|
-
{}.tap do |hash|
|
211
|
-
value.each do |k, v|
|
212
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
else # model
|
216
|
-
# models (e.g. Pet) or oneOf
|
217
|
-
klass = SnapTrade.const_get(type)
|
218
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
# Returns the string representation of the object
|
223
|
-
# @return [String] String presentation of the object
|
224
|
-
def to_s
|
225
|
-
to_hash.to_s
|
226
|
-
end
|
227
|
-
|
228
|
-
# to_body is an alias to to_hash (backward compatibility)
|
229
|
-
# @return [Hash] Returns the object in the form of hash
|
230
|
-
def to_body
|
231
|
-
to_hash
|
232
|
-
end
|
233
|
-
|
234
|
-
# Returns the object in the form of hash
|
235
|
-
# @return [Hash] Returns the object in the form of hash
|
236
|
-
def to_hash
|
237
|
-
hash = {}
|
238
|
-
self.class.attribute_map.each_pair do |attr, param|
|
239
|
-
value = self.send(attr)
|
240
|
-
if value.nil?
|
241
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
242
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
243
|
-
end
|
244
|
-
|
245
|
-
hash[param] = _to_hash(value)
|
246
|
-
end
|
247
|
-
hash
|
248
|
-
end
|
249
|
-
|
250
|
-
# Outputs non-array value in the form of hash
|
251
|
-
# For object, use to_hash. Otherwise, just return the value
|
252
|
-
# @param [Object] value Any valid value
|
253
|
-
# @return [Hash] Returns the value in the form of hash
|
254
|
-
def _to_hash(value)
|
255
|
-
if value.is_a?(Array)
|
256
|
-
value.compact.map { |v| _to_hash(v) }
|
257
|
-
elsif value.is_a?(Hash)
|
258
|
-
{}.tap do |hash|
|
259
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
260
|
-
end
|
261
|
-
elsif value.respond_to? :to_hash
|
262
|
-
value.to_hash
|
263
|
-
else
|
264
|
-
value
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
end
|
269
|
-
|
270
|
-
end
|
@@ -1,289 +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
|
-
# Target percentage of a certain asset
|
15
|
-
class TargetAsset
|
16
|
-
attr_accessor :id
|
17
|
-
|
18
|
-
attr_accessor :symbol
|
19
|
-
|
20
|
-
attr_accessor :percent
|
21
|
-
|
22
|
-
attr_accessor :is_supported
|
23
|
-
|
24
|
-
attr_accessor :is_excluded
|
25
|
-
|
26
|
-
attr_accessor :meta
|
27
|
-
|
28
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
-
def self.attribute_map
|
30
|
-
{
|
31
|
-
:'id' => :'id',
|
32
|
-
:'symbol' => :'symbol',
|
33
|
-
:'percent' => :'percent',
|
34
|
-
:'is_supported' => :'is_supported',
|
35
|
-
:'is_excluded' => :'is_excluded',
|
36
|
-
:'meta' => :'meta'
|
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
|
-
:'symbol' => :'UniversalSymbol',
|
50
|
-
:'percent' => :'Float',
|
51
|
-
:'is_supported' => :'Boolean',
|
52
|
-
:'is_excluded' => :'Boolean',
|
53
|
-
:'meta' => :'Hash<String, Object>'
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
# List of attributes with nullable: true
|
58
|
-
def self.openapi_nullable
|
59
|
-
Set.new([
|
60
|
-
:'meta'
|
61
|
-
])
|
62
|
-
end
|
63
|
-
|
64
|
-
# Initializes the object
|
65
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
66
|
-
def initialize(attributes = {})
|
67
|
-
if (!attributes.is_a?(Hash))
|
68
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::TargetAsset` initialize method"
|
69
|
-
end
|
70
|
-
|
71
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
72
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
73
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
74
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::TargetAsset`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
75
|
-
end
|
76
|
-
h[k.to_sym] = v
|
77
|
-
}
|
78
|
-
|
79
|
-
if attributes.key?(:'id')
|
80
|
-
self.id = attributes[:'id']
|
81
|
-
end
|
82
|
-
|
83
|
-
if attributes.key?(:'symbol')
|
84
|
-
self.symbol = attributes[:'symbol']
|
85
|
-
end
|
86
|
-
|
87
|
-
if attributes.key?(:'percent')
|
88
|
-
self.percent = attributes[:'percent']
|
89
|
-
end
|
90
|
-
|
91
|
-
if attributes.key?(:'is_supported')
|
92
|
-
self.is_supported = attributes[:'is_supported']
|
93
|
-
end
|
94
|
-
|
95
|
-
if attributes.key?(:'is_excluded')
|
96
|
-
self.is_excluded = attributes[:'is_excluded']
|
97
|
-
end
|
98
|
-
|
99
|
-
if attributes.key?(:'meta')
|
100
|
-
if (value = attributes[:'meta']).is_a?(Hash)
|
101
|
-
self.meta = value
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
107
|
-
# @return Array for valid properties with the reasons
|
108
|
-
def list_invalid_properties
|
109
|
-
invalid_properties = Array.new
|
110
|
-
if !@percent.nil? && @percent > 100
|
111
|
-
invalid_properties.push('invalid value for "percent", must be smaller than or equal to 100.')
|
112
|
-
end
|
113
|
-
|
114
|
-
if !@percent.nil? && @percent < 0
|
115
|
-
invalid_properties.push('invalid value for "percent", must be greater than or equal to 0.')
|
116
|
-
end
|
117
|
-
|
118
|
-
invalid_properties
|
119
|
-
end
|
120
|
-
|
121
|
-
# Check to see if the all the properties in the model are valid
|
122
|
-
# @return true if the model is valid
|
123
|
-
def valid?
|
124
|
-
return false if !@percent.nil? && @percent > 100
|
125
|
-
return false if !@percent.nil? && @percent < 0
|
126
|
-
true
|
127
|
-
end
|
128
|
-
|
129
|
-
# Custom attribute writer method with validation
|
130
|
-
# @param [Object] percent Value to be assigned
|
131
|
-
def percent=(percent)
|
132
|
-
if !percent.nil? && percent > 100
|
133
|
-
fail ArgumentError, 'invalid value for "percent", must be smaller than or equal to 100.'
|
134
|
-
end
|
135
|
-
|
136
|
-
if !percent.nil? && percent < 0
|
137
|
-
fail ArgumentError, 'invalid value for "percent", must be greater than or equal to 0.'
|
138
|
-
end
|
139
|
-
|
140
|
-
@percent = percent
|
141
|
-
end
|
142
|
-
|
143
|
-
# Checks equality by comparing each attribute.
|
144
|
-
# @param [Object] Object to be compared
|
145
|
-
def ==(o)
|
146
|
-
return true if self.equal?(o)
|
147
|
-
self.class == o.class &&
|
148
|
-
id == o.id &&
|
149
|
-
symbol == o.symbol &&
|
150
|
-
percent == o.percent &&
|
151
|
-
is_supported == o.is_supported &&
|
152
|
-
is_excluded == o.is_excluded &&
|
153
|
-
meta == o.meta
|
154
|
-
end
|
155
|
-
|
156
|
-
# @see the `==` method
|
157
|
-
# @param [Object] Object to be compared
|
158
|
-
def eql?(o)
|
159
|
-
self == o
|
160
|
-
end
|
161
|
-
|
162
|
-
# Calculates hash code according to all attributes.
|
163
|
-
# @return [Integer] Hash code
|
164
|
-
def hash
|
165
|
-
[id, symbol, percent, is_supported, is_excluded, meta].hash
|
166
|
-
end
|
167
|
-
|
168
|
-
# Builds the object from hash
|
169
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
170
|
-
# @return [Object] Returns the model itself
|
171
|
-
def self.build_from_hash(attributes)
|
172
|
-
new.build_from_hash(attributes)
|
173
|
-
end
|
174
|
-
|
175
|
-
# Builds the object from hash
|
176
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
177
|
-
# @return [Object] Returns the model itself
|
178
|
-
def build_from_hash(attributes)
|
179
|
-
return nil unless attributes.is_a?(Hash)
|
180
|
-
attributes = attributes.transform_keys(&:to_sym)
|
181
|
-
self.class.openapi_types.each_pair do |key, type|
|
182
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
183
|
-
self.send("#{key}=", nil)
|
184
|
-
elsif type =~ /\AArray<(.*)>/i
|
185
|
-
# check to ensure the input is an array given that the attribute
|
186
|
-
# is documented as an array but the input is not
|
187
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
188
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
189
|
-
end
|
190
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
191
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
self
|
196
|
-
end
|
197
|
-
|
198
|
-
# Deserializes the data based on type
|
199
|
-
# @param string type Data type
|
200
|
-
# @param string value Value to be deserialized
|
201
|
-
# @return [Object] Deserialized data
|
202
|
-
def _deserialize(type, value)
|
203
|
-
case type.to_sym
|
204
|
-
when :Time
|
205
|
-
Time.parse(value)
|
206
|
-
when :Date
|
207
|
-
Date.parse(value)
|
208
|
-
when :String
|
209
|
-
value.to_s
|
210
|
-
when :Integer
|
211
|
-
value.to_i
|
212
|
-
when :Float
|
213
|
-
value.to_f
|
214
|
-
when :Boolean
|
215
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
216
|
-
true
|
217
|
-
else
|
218
|
-
false
|
219
|
-
end
|
220
|
-
when :Object
|
221
|
-
# generic object (usually a Hash), return directly
|
222
|
-
value
|
223
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
224
|
-
inner_type = Regexp.last_match[:inner_type]
|
225
|
-
value.map { |v| _deserialize(inner_type, v) }
|
226
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
227
|
-
k_type = Regexp.last_match[:k_type]
|
228
|
-
v_type = Regexp.last_match[:v_type]
|
229
|
-
{}.tap do |hash|
|
230
|
-
value.each do |k, v|
|
231
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
else # model
|
235
|
-
# models (e.g. Pet) or oneOf
|
236
|
-
klass = SnapTrade.const_get(type)
|
237
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
# Returns the string representation of the object
|
242
|
-
# @return [String] String presentation of the object
|
243
|
-
def to_s
|
244
|
-
to_hash.to_s
|
245
|
-
end
|
246
|
-
|
247
|
-
# to_body is an alias to to_hash (backward compatibility)
|
248
|
-
# @return [Hash] Returns the object in the form of hash
|
249
|
-
def to_body
|
250
|
-
to_hash
|
251
|
-
end
|
252
|
-
|
253
|
-
# Returns the object in the form of hash
|
254
|
-
# @return [Hash] Returns the object in the form of hash
|
255
|
-
def to_hash
|
256
|
-
hash = {}
|
257
|
-
self.class.attribute_map.each_pair do |attr, param|
|
258
|
-
value = self.send(attr)
|
259
|
-
if value.nil?
|
260
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
261
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
262
|
-
end
|
263
|
-
|
264
|
-
hash[param] = _to_hash(value)
|
265
|
-
end
|
266
|
-
hash
|
267
|
-
end
|
268
|
-
|
269
|
-
# Outputs non-array value in the form of hash
|
270
|
-
# For object, use to_hash. Otherwise, just return the value
|
271
|
-
# @param [Object] value Any valid value
|
272
|
-
# @return [Hash] Returns the value in the form of hash
|
273
|
-
def _to_hash(value)
|
274
|
-
if value.is_a?(Array)
|
275
|
-
value.compact.map { |v| _to_hash(v) }
|
276
|
-
elsif value.is_a?(Hash)
|
277
|
-
{}.tap do |hash|
|
278
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
279
|
-
end
|
280
|
-
elsif value.respond_to? :to_hash
|
281
|
-
value.to_hash
|
282
|
-
else
|
283
|
-
value
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
end
|
288
|
-
|
289
|
-
end
|