snaptrade 1.16.1 → 1.16.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,8 @@ module SnapTrade
17
17
 
18
18
  attr_accessor :ticker
19
19
 
20
+ attr_accessor :option_type
21
+
20
22
  attr_accessor :strike_price
21
23
 
22
24
  attr_accessor :expiration_date
@@ -34,6 +36,7 @@ module SnapTrade
34
36
  {
35
37
  :'id' => :'id',
36
38
  :'ticker' => :'ticker',
39
+ :'option_type' => :'option_type',
37
40
  :'strike_price' => :'strike_price',
38
41
  :'expiration_date' => :'expiration_date',
39
42
  :'is_mini_option' => :'is_mini_option',
@@ -53,6 +56,7 @@ module SnapTrade
53
56
  {
54
57
  :'id' => :'String',
55
58
  :'ticker' => :'String',
59
+ :'option_type' => :'OptionType',
56
60
  :'strike_price' => :'Float',
57
61
  :'expiration_date' => :'String',
58
62
  :'is_mini_option' => :'Boolean',
@@ -98,6 +102,10 @@ module SnapTrade
98
102
  self.ticker = attributes[:'ticker']
99
103
  end
100
104
 
105
+ if attributes.key?(:'option_type')
106
+ self.option_type = attributes[:'option_type']
107
+ end
108
+
101
109
  if attributes.key?(:'strike_price')
102
110
  self.strike_price = attributes[:'strike_price']
103
111
  end
@@ -127,12 +135,42 @@ module SnapTrade
127
135
  # @return Array for valid properties with the reasons
128
136
  def list_invalid_properties
129
137
  invalid_properties = Array.new
138
+ if @id.nil?
139
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
140
+ end
141
+
142
+ if @ticker.nil?
143
+ invalid_properties.push('invalid value for "ticker", ticker cannot be nil.')
144
+ end
145
+
146
+ if @option_type.nil?
147
+ invalid_properties.push('invalid value for "option_type", option_type cannot be nil.')
148
+ end
149
+
150
+ if @strike_price.nil?
151
+ invalid_properties.push('invalid value for "strike_price", strike_price cannot be nil.')
152
+ end
153
+
154
+ if @expiration_date.nil?
155
+ invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.')
156
+ end
157
+
158
+ if @underlying_symbol.nil?
159
+ invalid_properties.push('invalid value for "underlying_symbol", underlying_symbol cannot be nil.')
160
+ end
161
+
130
162
  invalid_properties
131
163
  end
132
164
 
133
165
  # Check to see if the all the properties in the model are valid
134
166
  # @return true if the model is valid
135
167
  def valid?
168
+ return false if @id.nil?
169
+ return false if @ticker.nil?
170
+ return false if @option_type.nil?
171
+ return false if @strike_price.nil?
172
+ return false if @expiration_date.nil?
173
+ return false if @underlying_symbol.nil?
136
174
  true
137
175
  end
138
176
 
@@ -143,6 +181,7 @@ module SnapTrade
143
181
  self.class == o.class &&
144
182
  id == o.id &&
145
183
  ticker == o.ticker &&
184
+ option_type == o.option_type &&
146
185
  strike_price == o.strike_price &&
147
186
  expiration_date == o.expiration_date &&
148
187
  is_mini_option == o.is_mini_option &&
@@ -160,7 +199,7 @@ module SnapTrade
160
199
  # Calculates hash code according to all attributes.
161
200
  # @return [Integer] Hash code
162
201
  def hash
163
- [id, ticker, strike_price, expiration_date, is_mini_option, underlying_symbol, local_id, exchange_id].hash
202
+ [id, ticker, option_type, strike_price, expiration_date, is_mini_option, underlying_symbol, local_id, exchange_id].hash
164
203
  end
165
204
 
166
205
  # Builds the object from hash
@@ -0,0 +1,38 @@
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
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module SnapTrade
15
+ class OptionType
16
+ CALL = "CALL".freeze
17
+ PUT = "PUT".freeze
18
+
19
+ def self.all_vars
20
+ @all_vars ||= [CALL, PUT].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 OptionType.all_vars.include?(value)
35
+ raise "Invalid ENUM value #{value} for class #OptionType"
36
+ end
37
+ end
38
+ end
@@ -18,6 +18,8 @@ module SnapTrade
18
18
 
19
19
  attr_accessor :ticker
20
20
 
21
+ attr_accessor :option_type
22
+
21
23
  attr_accessor :strike_price
22
24
 
23
25
  attr_accessor :expiration_date
@@ -35,6 +37,7 @@ module SnapTrade
35
37
  {
36
38
  :'id' => :'id',
37
39
  :'ticker' => :'ticker',
40
+ :'option_type' => :'option_type',
38
41
  :'strike_price' => :'strike_price',
39
42
  :'expiration_date' => :'expiration_date',
40
43
  :'is_mini_option' => :'is_mini_option',
@@ -54,6 +57,7 @@ module SnapTrade
54
57
  {
55
58
  :'id' => :'String',
56
59
  :'ticker' => :'String',
60
+ :'option_type' => :'OptionType',
57
61
  :'strike_price' => :'Float',
58
62
  :'expiration_date' => :'String',
59
63
  :'is_mini_option' => :'Boolean',
@@ -92,6 +96,10 @@ module SnapTrade
92
96
  self.ticker = attributes[:'ticker']
93
97
  end
94
98
 
99
+ if attributes.key?(:'option_type')
100
+ self.option_type = attributes[:'option_type']
101
+ end
102
+
95
103
  if attributes.key?(:'strike_price')
96
104
  self.strike_price = attributes[:'strike_price']
97
105
  end
@@ -121,12 +129,42 @@ module SnapTrade
121
129
  # @return Array for valid properties with the reasons
122
130
  def list_invalid_properties
123
131
  invalid_properties = Array.new
132
+ if @id.nil?
133
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
134
+ end
135
+
136
+ if @ticker.nil?
137
+ invalid_properties.push('invalid value for "ticker", ticker cannot be nil.')
138
+ end
139
+
140
+ if @option_type.nil?
141
+ invalid_properties.push('invalid value for "option_type", option_type cannot be nil.')
142
+ end
143
+
144
+ if @strike_price.nil?
145
+ invalid_properties.push('invalid value for "strike_price", strike_price cannot be nil.')
146
+ end
147
+
148
+ if @expiration_date.nil?
149
+ invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.')
150
+ end
151
+
152
+ if @underlying_symbol.nil?
153
+ invalid_properties.push('invalid value for "underlying_symbol", underlying_symbol cannot be nil.')
154
+ end
155
+
124
156
  invalid_properties
125
157
  end
126
158
 
127
159
  # Check to see if the all the properties in the model are valid
128
160
  # @return true if the model is valid
129
161
  def valid?
162
+ return false if @id.nil?
163
+ return false if @ticker.nil?
164
+ return false if @option_type.nil?
165
+ return false if @strike_price.nil?
166
+ return false if @expiration_date.nil?
167
+ return false if @underlying_symbol.nil?
130
168
  true
131
169
  end
132
170
 
@@ -137,6 +175,7 @@ module SnapTrade
137
175
  self.class == o.class &&
138
176
  id == o.id &&
139
177
  ticker == o.ticker &&
178
+ option_type == o.option_type &&
140
179
  strike_price == o.strike_price &&
141
180
  expiration_date == o.expiration_date &&
142
181
  is_mini_option == o.is_mini_option &&
@@ -154,7 +193,7 @@ module SnapTrade
154
193
  # Calculates hash code according to all attributes.
155
194
  # @return [Integer] Hash code
156
195
  def hash
157
- [id, ticker, strike_price, expiration_date, is_mini_option, underlying_symbol, local_id, exchange_id].hash
196
+ [id, ticker, option_type, strike_price, expiration_date, is_mini_option, underlying_symbol, local_id, exchange_id].hash
158
197
  end
159
198
 
160
199
  # Builds the object from hash
@@ -1,227 +1,227 @@
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
-
9
- =end
10
-
11
- require 'date'
12
- require 'time'
13
-
14
- module SnapTrade
15
- # Summed value of account positions and cash balances
16
- class SnapTradeHoldingsTotalValue
17
- attr_accessor :value
18
-
19
- attr_accessor :currency
20
-
21
- # Attribute mapping from ruby-style variable name to JSON key.
22
- def self.attribute_map
23
- {
24
- :'value' => :'value',
25
- :'currency' => :'currency'
26
- }
27
- end
28
-
29
- # Returns all the JSON keys this model knows about
30
- def self.acceptable_attributes
31
- attribute_map.values
32
- end
33
-
34
- # Attribute type mapping.
35
- def self.openapi_types
36
- {
37
- :'value' => :'Float',
38
- :'currency' => :'String'
39
- }
40
- end
41
-
42
- # List of attributes with nullable: true
43
- def self.openapi_nullable
44
- Set.new([
45
- ])
46
- end
47
-
48
- # Initializes the object
49
- # @param [Hash] attributes Model attributes in the form of hash
50
- def initialize(attributes = {})
51
- if (!attributes.is_a?(Hash))
52
- fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::SnapTradeHoldingsTotalValue` initialize method"
53
- end
54
-
55
- # check to see if the attribute exists and convert string to symbol for hash key
56
- attributes = attributes.each_with_object({}) { |(k, v), h|
57
- if (!self.class.attribute_map.key?(k.to_sym))
58
- fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::SnapTradeHoldingsTotalValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
- end
60
- h[k.to_sym] = v
61
- }
62
-
63
- if attributes.key?(:'value')
64
- self.value = attributes[:'value']
65
- end
66
-
67
- if attributes.key?(:'currency')
68
- self.currency = attributes[:'currency']
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
- value == o.value &&
91
- currency == o.currency
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
- [value, currency].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
+ =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
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module SnapTrade
15
+ # Summed value of account positions and cash balances
16
+ class SnapTradeHoldingsTotalValue
17
+ attr_accessor :value
18
+
19
+ attr_accessor :currency
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'value' => :'value',
25
+ :'currency' => :'currency'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'value' => :'Float',
38
+ :'currency' => :'String'
39
+ }
40
+ end
41
+
42
+ # List of attributes with nullable: true
43
+ def self.openapi_nullable
44
+ Set.new([
45
+ ])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ if (!attributes.is_a?(Hash))
52
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::SnapTradeHoldingsTotalValue` initialize method"
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h|
57
+ if (!self.class.attribute_map.key?(k.to_sym))
58
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::SnapTradeHoldingsTotalValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
+ end
60
+ h[k.to_sym] = v
61
+ }
62
+
63
+ if attributes.key?(:'value')
64
+ self.value = attributes[:'value']
65
+ end
66
+
67
+ if attributes.key?(:'currency')
68
+ self.currency = attributes[:'currency']
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
+ value == o.value &&
91
+ currency == o.currency
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
+ [value, currency].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