Class: SchwabRb::DataObjects::UserPreferences
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::UserPreferences
show all
- Defined in:
- lib/schwab_rb/data_objects/user_preferences.rb
Defined Under Namespace
Classes: Offer, StreamerInfo, UserAccount
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of UserPreferences.
14
15
16
17
18
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 14
def initialize(data)
@accounts = data[:accounts]&.map { |account_data| UserAccount.new(account_data) } || []
@streamer_info = data[:streamerInfo]&.map { |streamer_data| StreamerInfo.new(streamer_data) } || []
@offers = data[:offers]&.map { |offer_data| Offer.new(offer_data) } || []
end
|
Instance Attribute Details
#accounts ⇒ Object
Returns the value of attribute accounts.
6
7
8
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 6
def accounts
@accounts
end
|
#offers ⇒ Object
Returns the value of attribute offers.
6
7
8
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 6
def offers
@offers
end
|
#streamer_info ⇒ Object
Returns the value of attribute streamer_info.
6
7
8
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 6
def streamer_info
@streamer_info
end
|
Class Method Details
.build(data) ⇒ Object
9
10
11
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 9
def build(data)
new(data)
end
|
Instance Method Details
#account_numbers ⇒ Object
36
37
38
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 36
def account_numbers
@accounts.map(&:account_number)
end
|
#brokerage_accounts ⇒ Object
40
41
42
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 40
def brokerage_accounts
@accounts.select { |account| account.type == "BROKERAGE" }
end
|
#find_account_by_number(account_number) ⇒ Object
32
33
34
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 32
def find_account_by_number(account_number)
@accounts.find { |account| account.account_number == account_number }
end
|
#has_level2_permissions? ⇒ Boolean
44
45
46
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 44
def has_level2_permissions?
@offers.any?(&:level2_permissions?)
end
|
#primary_account ⇒ Object
28
29
30
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 28
def primary_account
@accounts.find(&:primary_account?)
end
|
#to_h ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/schwab_rb/data_objects/user_preferences.rb', line 20
def to_h
{
accounts: @accounts.map(&:to_h),
streamerInfo: @streamer_info.map(&:to_h),
offers: @offers.map(&:to_h)
}
end
|