Class: Wesabe::Account
Overview
Encapsulates an account from Wesabe’s API.
Instance Attribute Summary collapse
-
#balance ⇒ Object
This account’s balance or
nil
if the account is a cash account. -
#currency ⇒ Object
This account’s currency.
-
#financial_institution ⇒ Object
The financial institution this account is held at.
-
#id ⇒ Object
The user-scoped account id, used to identify the account in URLs.
-
#name ⇒ Object
The user-provided account name (“Bank of America - Checking”).
-
#number ⇒ Object
The application-scoped account id, used in upload.
-
#type ⇒ Object
The account type (“Credit Card”, “Savings” …).
Attributes inherited from BaseModel
Class Method Summary collapse
-
.from_xml(xml) ⇒ Wesabe::Account
Returns a
Wesabe::Account
generated from Wesabe’s API XML.
Instance Method Summary collapse
-
#initialize {|account| ... } ⇒ Account
constructor
Initializes a
Wesabe::Account
and yields itself. - #inspect ⇒ Object
-
#new_upload ⇒ Wesabe::Upload
Creates a
Wesabe::Upload
that can be used to upload to this account.
Methods inherited from BaseModel
Methods included from Util
Constructor Details
#initialize {|account| ... } ⇒ Account
Initializes a Wesabe::Account
and yields itself.
22 23 24 |
# File 'lib/wesabe/account.rb', line 22 def initialize yield self if block_given? end |
Instance Attribute Details
#balance ⇒ Object
This account’s balance or nil
if the account is a cash account.
12 13 14 |
# File 'lib/wesabe/account.rb', line 12 def balance @balance end |
#currency ⇒ Object
This account’s currency.
14 15 16 |
# File 'lib/wesabe/account.rb', line 14 def currency @currency end |
#financial_institution ⇒ Object
The financial institution this account is held at.
16 17 18 |
# File 'lib/wesabe/account.rb', line 16 def financial_institution @financial_institution end |
#id ⇒ Object
The user-scoped account id, used to identify the account in URLs.
4 5 6 |
# File 'lib/wesabe/account.rb', line 4 def id @id end |
#name ⇒ Object
The user-provided account name (“Bank of America - Checking”)
8 9 10 |
# File 'lib/wesabe/account.rb', line 8 def name @name end |
#number ⇒ Object
The application-scoped account id, used in upload
6 7 8 |
# File 'lib/wesabe/account.rb', line 6 def number @number end |
#type ⇒ Object
The account type (“Credit Card”, “Savings” …)
10 11 12 |
# File 'lib/wesabe/account.rb', line 10 def type @type end |
Class Method Details
.from_xml(xml) ⇒ Wesabe::Account
Returns a Wesabe::Account
generated from Wesabe’s API XML.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/wesabe/account.rb', line 45 def self.from_xml(xml) new do |account| account.id = xml.at("id").inner_text.to_i account.name = xml.at("name").inner_text account.type = xml.at("account-type").inner_text account.number = xml.at("account-number").inner_text if xml.at("account-number") balance = xml.at("current-balance") account.balance = balance.inner_text.to_f if balance account.currency = Wesabe::Currency.from_xml(xml.at("currency")) fi = xml.at("financial-institution") account.financial_institution = Wesabe::FinancialInstitution.from_xml(fi) if fi end end |
Instance Method Details
#inspect ⇒ Object
59 60 61 |
# File 'lib/wesabe/account.rb', line 59 def inspect inspect_these :id, :number, :type, :name, :balance, :financial_institution, :currency end |
#new_upload ⇒ Wesabe::Upload
Creates a Wesabe::Upload
that can be used to upload to this account.
30 31 32 33 34 35 36 |
# File 'lib/wesabe/account.rb', line 30 def new_upload Wesabe::Upload.new do |upload| upload.accounts = [self] upload.financial_institution = financial_institution associate upload end end |