snaptrade 2.0.31 → 2.0.33

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