Class: SnapTrade::InvestmentAccount
- Inherits:
-
Object
- Object
- SnapTrade::InvestmentAccount
- Defined in:
- lib/snaptrade/models/investment_account.rb
Overview
An investment/brokerage account under a connection. opening_date, funding_date, and market_value are real-time or cached depending on the caller's plan -- see Connections_listConnectionAccounts.
Instance Attribute Summary collapse
-
#connection_id ⇒ Object
Unique identifier for the connection (brokerage_authorization_id).
-
#display_name ⇒ Object
A display name for the account.
-
#funding_date ⇒ Object
Timestamp in ISO 8601 format indicating when the account was funded.
-
#id ⇒ Object
Unique identifier for the connected brokerage account.
-
#institution_account_id ⇒ Object
A stable and unique account identifier provided by the institution.
-
#institution_id ⇒ Object
Unique identifier for the institution (brokerage) that holds the account.
-
#is_paper ⇒ Object
Indicates whether the account is a paper (simulated) trading account.
-
#kind ⇒ Object
Discriminator for the account kind.
-
#market_value ⇒ Object
Returns the value of attribute market_value.
-
#number ⇒ Object
The account number assigned by the brokerage.
-
#opening_date ⇒ Object
Timestamp in ISO 8601 format indicating when the account was opened at the brokerage.
-
#raw_type ⇒ Object
The account type as provided by the brokerage.
-
#sync_status ⇒ Object
Returns the value of attribute sync_status.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ InvestmentAccount
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ InvestmentAccount
Initializes the object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/snaptrade/models/investment_account.rb', line 110 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::InvestmentAccount` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::InvestmentAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'kind') self.kind = attributes[:'kind'] end if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'connection_id') self.connection_id = attributes[:'connection_id'] end if attributes.key?(:'display_name') self.display_name = attributes[:'display_name'] end if attributes.key?(:'number') self.number = attributes[:'number'] end if attributes.key?(:'institution_account_id') self.institution_account_id = attributes[:'institution_account_id'] end if attributes.key?(:'institution_id') self.institution_id = attributes[:'institution_id'] end if attributes.key?(:'opening_date') self.opening_date = attributes[:'opening_date'] end if attributes.key?(:'sync_status') self.sync_status = attributes[:'sync_status'] end if attributes.key?(:'raw_type') self.raw_type = attributes[:'raw_type'] end if attributes.key?(:'funding_date') self.funding_date = attributes[:'funding_date'] end if attributes.key?(:'is_paper') self.is_paper = attributes[:'is_paper'] end if attributes.key?(:'market_value') self.market_value = attributes[:'market_value'] end end |
Instance Attribute Details
#connection_id ⇒ Object
Unique identifier for the connection (brokerage_authorization_id). This is the UUID used to reference the connection in SnapTrade.
23 24 25 |
# File 'lib/snaptrade/models/investment_account.rb', line 23 def connection_id @connection_id end |
#display_name ⇒ Object
A display name for the account. Either assigned by the user or by the brokerage itself.
26 27 28 |
# File 'lib/snaptrade/models/investment_account.rb', line 26 def display_name @display_name end |
#funding_date ⇒ Object
Timestamp in ISO 8601 format indicating when the account was funded.
46 47 48 |
# File 'lib/snaptrade/models/investment_account.rb', line 46 def funding_date @funding_date end |
#id ⇒ Object
Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
20 21 22 |
# File 'lib/snaptrade/models/investment_account.rb', line 20 def id @id end |
#institution_account_id ⇒ Object
A stable and unique account identifier provided by the institution. Will be set to null if not provided. When present, can be used to check if a user has connected the same brokerage account across multiple connections.
32 33 34 |
# File 'lib/snaptrade/models/investment_account.rb', line 32 def institution_account_id @institution_account_id end |
#institution_id ⇒ Object
Unique identifier for the institution (brokerage) that holds the account.
35 36 37 |
# File 'lib/snaptrade/models/investment_account.rb', line 35 def institution_id @institution_id end |
#is_paper ⇒ Object
Indicates whether the account is a paper (simulated) trading account.
49 50 51 |
# File 'lib/snaptrade/models/investment_account.rb', line 49 def is_paper @is_paper end |
#kind ⇒ Object
Discriminator for the account kind.
17 18 19 |
# File 'lib/snaptrade/models/investment_account.rb', line 17 def kind @kind end |
#market_value ⇒ Object
Returns the value of attribute market_value.
51 52 53 |
# File 'lib/snaptrade/models/investment_account.rb', line 51 def market_value @market_value end |
#number ⇒ Object
The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons.
29 30 31 |
# File 'lib/snaptrade/models/investment_account.rb', line 29 def number @number end |
#opening_date ⇒ Object
Timestamp in ISO 8601 format indicating when the account was opened at the brokerage.
38 39 40 |
# File 'lib/snaptrade/models/investment_account.rb', line 38 def opening_date @opening_date end |
#raw_type ⇒ Object
The account type as provided by the brokerage.
43 44 45 |
# File 'lib/snaptrade/models/investment_account.rb', line 43 def raw_type @raw_type end |
#sync_status ⇒ Object
Returns the value of attribute sync_status.
40 41 42 |
# File 'lib/snaptrade/models/investment_account.rb', line 40 def sync_status @sync_status end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
73 74 75 |
# File 'lib/snaptrade/models/investment_account.rb', line 73 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/snaptrade/models/investment_account.rb', line 54 def self.attribute_map { :'kind' => :'kind', :'id' => :'id', :'connection_id' => :'connection_id', :'display_name' => :'display_name', :'number' => :'number', :'institution_account_id' => :'institution_account_id', :'institution_id' => :'institution_id', :'opening_date' => :'opening_date', :'sync_status' => :'sync_status', :'raw_type' => :'raw_type', :'funding_date' => :'funding_date', :'is_paper' => :'is_paper', :'market_value' => :'market_value' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
254 255 256 |
# File 'lib/snaptrade/models/investment_account.rb', line 254 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/snaptrade/models/investment_account.rb', line 97 def self.openapi_nullable Set.new([ :'display_name', :'institution_account_id', :'opening_date', :'raw_type', :'funding_date', :'market_value' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/snaptrade/models/investment_account.rb', line 78 def self.openapi_types { :'kind' => :'Kind', :'id' => :'String', :'connection_id' => :'String', :'display_name' => :'String', :'number' => :'String', :'institution_account_id' => :'String', :'institution_id' => :'String', :'opening_date' => :'Time', :'sync_status' => :'ConnectionAccountSyncStatus', :'raw_type' => :'String', :'funding_date' => :'Time', :'is_paper' => :'Boolean', :'market_value' => :'InvestmentAccountMarketValue' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/snaptrade/models/investment_account.rb', line 221 def ==(o) return true if self.equal?(o) self.class == o.class && kind == o.kind && id == o.id && connection_id == o.connection_id && display_name == o.display_name && number == o.number && institution_account_id == o.institution_account_id && institution_id == o.institution_id && opening_date == o.opening_date && sync_status == o.sync_status && raw_type == o.raw_type && funding_date == o.funding_date && is_paper == o.is_paper && market_value == o.market_value end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/snaptrade/models/investment_account.rb', line 285 def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = SnapTrade.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/snaptrade/models/investment_account.rb', line 356 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/snaptrade/models/investment_account.rb', line 261 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(o) ⇒ Boolean
241 242 243 |
# File 'lib/snaptrade/models/investment_account.rb', line 241 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
247 248 249 |
# File 'lib/snaptrade/models/investment_account.rb', line 247 def hash [kind, id, connection_id, display_name, number, institution_account_id, institution_id, opening_date, sync_status, raw_type, funding_date, is_paper, market_value].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/snaptrade/models/investment_account.rb', line 178 def list_invalid_properties invalid_properties = Array.new if @kind.nil? invalid_properties.push('invalid value for "kind", kind cannot be nil.') end if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @connection_id.nil? invalid_properties.push('invalid value for "connection_id", connection_id cannot be nil.') end if @number.nil? invalid_properties.push('invalid value for "number", number cannot be nil.') end if @sync_status.nil? invalid_properties.push('invalid value for "sync_status", sync_status cannot be nil.') end if @is_paper.nil? invalid_properties.push('invalid value for "is_paper", is_paper cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
332 333 334 |
# File 'lib/snaptrade/models/investment_account.rb', line 332 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/snaptrade/models/investment_account.rb', line 338 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
326 327 328 |
# File 'lib/snaptrade/models/investment_account.rb', line 326 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
209 210 211 212 213 214 215 216 217 |
# File 'lib/snaptrade/models/investment_account.rb', line 209 def valid? return false if @kind.nil? return false if @id.nil? return false if @connection_id.nil? return false if @number.nil? return false if @sync_status.nil? return false if @is_paper.nil? true end |