Class: SnapTrade::Account
- Inherits:
-
Object
- Object
- SnapTrade::Account
- Defined in:
- lib/snaptrade/models/account.rb
Overview
A single account at a brokerage.
Instance Attribute Summary collapse
-
#balance ⇒ Object
Returns the value of attribute balance.
-
#brokerage_authorization ⇒ Object
Unique identifier for the connection.
-
#cash_restrictions ⇒ Object
This field is deprecated.
-
#created_date ⇒ Object
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format indicating when the account was created in SnapTrade.
-
#funding_date ⇒ Object
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format indicating when the account was funded.
-
#id ⇒ Object
Unique identifier for the connected brokerage account.
-
#institution_name ⇒ Object
The name of the brokerage that holds the account.
-
#is_paper ⇒ Object
Indicates whether the account is a paper (simulated) trading account.
-
#meta ⇒ Object
Additional information about the account, such as account type, status, etc.
-
#name ⇒ Object
A display name for the account.
-
#number ⇒ Object
The account number assigned by the brokerage.
-
#opening_date ⇒ Object
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format indicating when the account was opened at the brokerage.
-
#portfolio_group ⇒ Object
Portfolio Group ID.
-
#raw_type ⇒ Object
The account type as provided by the brokerage.
-
#status ⇒ Object
The current status of the account.
-
#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 = {}) ⇒ Account
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 = {}) ⇒ Account
Initializes the object
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 175 176 177 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 |
# File 'lib/snaptrade/models/account.rb', line 124 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::Account` 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::Account`. 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?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'brokerage_authorization') self. = attributes[:'brokerage_authorization'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'number') self.number = attributes[:'number'] end if attributes.key?(:'institution_name') self.institution_name = attributes[:'institution_name'] end if attributes.key?(:'created_date') self.created_date = attributes[:'created_date'] end if attributes.key?(:'funding_date') self.funding_date = attributes[:'funding_date'] 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?(:'balance') self.balance = attributes[:'balance'] end if attributes.key?(:'status') self.status = attributes[:'status'] end if attributes.key?(:'raw_type') self.raw_type = attributes[:'raw_type'] end if attributes.key?(:'meta') if (value = attributes[:'meta']).is_a?(Hash) self. = value end end if attributes.key?(:'portfolio_group') self.portfolio_group = attributes[:'portfolio_group'] end if attributes.key?(:'cash_restrictions') if (value = attributes[:'cash_restrictions']).is_a?(Array) self.cash_restrictions = value end end if attributes.key?(:'is_paper') self.is_paper = attributes[:'is_paper'] end end |
Instance Attribute Details
#balance ⇒ Object
Returns the value of attribute balance.
42 43 44 |
# File 'lib/snaptrade/models/account.rb', line 42 def balance @balance end |
#brokerage_authorization ⇒ Object
Unique identifier for the connection. This is the UUID used to reference the connection in SnapTrade.
20 21 22 |
# File 'lib/snaptrade/models/account.rb', line 20 def @brokerage_authorization end |
#cash_restrictions ⇒ Object
This field is deprecated.
57 58 59 |
# File 'lib/snaptrade/models/account.rb', line 57 def cash_restrictions @cash_restrictions end |
#created_date ⇒ Object
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format indicating when the account was created in SnapTrade. This is not the account opening date at the brokerage.
32 33 34 |
# File 'lib/snaptrade/models/account.rb', line 32 def created_date @created_date end |
#funding_date ⇒ Object
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format indicating when the account was funded.
35 36 37 |
# File 'lib/snaptrade/models/account.rb', line 35 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. This ID should not change for as long as the connection stays active. If the connection is deleted and re-added, a new account ID will be generated.
17 18 19 |
# File 'lib/snaptrade/models/account.rb', line 17 def id @id end |
#institution_name ⇒ Object
The name of the brokerage that holds the account.
29 30 31 |
# File 'lib/snaptrade/models/account.rb', line 29 def institution_name @institution_name end |
#is_paper ⇒ Object
Indicates whether the account is a paper (simulated) trading account.
60 61 62 |
# File 'lib/snaptrade/models/account.rb', line 60 def is_paper @is_paper end |
#meta ⇒ Object
Additional information about the account, such as account type, status, etc. This information is specific to the brokerage and there’s no standard format for this data. This field is deprecated and subject to removal in a future version.
51 52 53 |
# File 'lib/snaptrade/models/account.rb', line 51 def @meta end |
#name ⇒ Object
A display name for the account. Either assigned by the user or by the brokerage itself. For certain brokerages, SnapTrade appends the brokerage name to the account name for clarity.
23 24 25 |
# File 'lib/snaptrade/models/account.rb', line 23 def name @name end |
#number ⇒ Object
The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons.
26 27 28 |
# File 'lib/snaptrade/models/account.rb', line 26 def number @number end |
#opening_date ⇒ Object
Timestamp in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format indicating when the account was opened at the brokerage.
38 39 40 |
# File 'lib/snaptrade/models/account.rb', line 38 def opening_date @opening_date end |
#portfolio_group ⇒ Object
Portfolio Group ID. Portfolio Groups have been deprecated. Please contact support if you have a usecase for it.
54 55 56 |
# File 'lib/snaptrade/models/account.rb', line 54 def portfolio_group @portfolio_group end |
#raw_type ⇒ Object
The account type as provided by the brokerage
48 49 50 |
# File 'lib/snaptrade/models/account.rb', line 48 def raw_type @raw_type end |
#status ⇒ Object
The current status of the account. Can be either "open", "closed", "archived" or null if the status is unknown or not provided by the brokerage.
45 46 47 |
# File 'lib/snaptrade/models/account.rb', line 45 def status @status end |
#sync_status ⇒ Object
Returns the value of attribute sync_status.
40 41 42 |
# File 'lib/snaptrade/models/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
85 86 87 |
# File 'lib/snaptrade/models/account.rb', line 85 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/snaptrade/models/account.rb', line 63 def self.attribute_map { :'id' => :'id', :'brokerage_authorization' => :'brokerage_authorization', :'name' => :'name', :'number' => :'number', :'institution_name' => :'institution_name', :'created_date' => :'created_date', :'funding_date' => :'funding_date', :'opening_date' => :'opening_date', :'sync_status' => :'sync_status', :'balance' => :'balance', :'status' => :'status', :'raw_type' => :'raw_type', :'meta' => :'meta', :'portfolio_group' => :'portfolio_group', :'cash_restrictions' => :'cash_restrictions', :'is_paper' => :'is_paper' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
297 298 299 |
# File 'lib/snaptrade/models/account.rb', line 297 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
112 113 114 115 116 117 118 119 120 |
# File 'lib/snaptrade/models/account.rb', line 112 def self.openapi_nullable Set.new([ :'name', :'funding_date', :'opening_date', :'status', :'raw_type', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/snaptrade/models/account.rb', line 90 def self.openapi_types { :'id' => :'String', :'brokerage_authorization' => :'String', :'name' => :'String', :'number' => :'String', :'institution_name' => :'String', :'created_date' => :'Time', :'funding_date' => :'Time', :'opening_date' => :'Time', :'sync_status' => :'AccountSyncStatus', :'balance' => :'AccountBalance', :'status' => :'AccountStatus', :'raw_type' => :'String', :'meta' => :'Hash<String, Object>', :'portfolio_group' => :'String', :'cash_restrictions' => :'Array<String>', :'is_paper' => :'Boolean' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/snaptrade/models/account.rb', line 261 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && == o. && name == o.name && number == o.number && institution_name == o.institution_name && created_date == o.created_date && funding_date == o.funding_date && opening_date == o.opening_date && sync_status == o.sync_status && balance == o.balance && status == o.status && raw_type == o.raw_type && == o. && portfolio_group == o.portfolio_group && cash_restrictions == o.cash_restrictions && is_paper == o.is_paper end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/snaptrade/models/account.rb', line 328 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
399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/snaptrade/models/account.rb', line 399 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
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/snaptrade/models/account.rb', line 304 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
284 285 286 |
# File 'lib/snaptrade/models/account.rb', line 284 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
290 291 292 |
# File 'lib/snaptrade/models/account.rb', line 290 def hash [id, , name, number, institution_name, created_date, funding_date, opening_date, sync_status, balance, status, raw_type, , portfolio_group, cash_restrictions, is_paper].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/snaptrade/models/account.rb', line 208 def list_invalid_properties invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @brokerage_authorization.nil? invalid_properties.push('invalid value for "brokerage_authorization", brokerage_authorization cannot be nil.') end if @number.nil? invalid_properties.push('invalid value for "number", number cannot be nil.') end if @institution_name.nil? invalid_properties.push('invalid value for "institution_name", institution_name cannot be nil.') end if @created_date.nil? invalid_properties.push('invalid value for "created_date", created_date cannot be nil.') end if @sync_status.nil? invalid_properties.push('invalid value for "sync_status", sync_status cannot be nil.') end if @balance.nil? invalid_properties.push('invalid value for "balance", balance 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)
375 376 377 |
# File 'lib/snaptrade/models/account.rb', line 375 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/snaptrade/models/account.rb', line 381 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
369 370 371 |
# File 'lib/snaptrade/models/account.rb', line 369 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/snaptrade/models/account.rb', line 247 def valid? return false if @id.nil? return false if @brokerage_authorization.nil? return false if @number.nil? return false if @institution_name.nil? return false if @created_date.nil? return false if @sync_status.nil? return false if @balance.nil? return false if @is_paper.nil? true end |