Class: Buxfer::Account

Inherits:
Response
  • Object
show all
Defined in:
lib/buxfer/account.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject

Returns an array of accounts. See Buxfer::Base#accounts

Example:

Buxfer::Account.all


8
9
10
# File 'lib/buxfer/account.rb', line 8

def self.all
  Buxfer.accounts
end

Instance Method Details

#add_transaction(amount, description, status = nil, tags = []) ⇒ Object

Add a transaction to Buxfer. The amount and description must be specified.

An array of tag names can be specified.

Examples:

.add_transaction(1000, 'Salary')

See: www.buxfer.com/help.php?topic=API#add_transaction



28
29
30
# File 'lib/buxfer/account.rb', line 28

def add_transaction(amount, description, status = nil, tags = [])
  Buxfer.add_transaction(amount, description, self.name, status, tags)
end

#transactions(options = {}) ⇒ Object

Return an array of the last 25 transactions for this account. See Buxfer::Base#transactions for valid options.



14
15
16
# File 'lib/buxfer/account.rb', line 14

def transactions(options = {})
  Buxfer.transactions(options.merge(:account => self))
end

#upload_statement(statement, date_format = 'DD/MM/YYYY') ⇒ Object

Upload a file containing a transaction statement to Buxfer account.

The statement can be a String or an IO object.

An optional date format can be passed indicating if the dates used in the statement are in the format ‘DD/MM/YYYY’ (default) or ‘MM/DD/YYYY’

Example:

 = Buxfer.accounts.first
.upload_statement(open('/path/to/file')) => true

www.buxfer.com/help.php?topic=API#upload_statement



45
46
47
# File 'lib/buxfer/account.rb', line 45

def upload_statement(statement, date_format = 'DD/MM/YYYY')
  Buxfer.upload_statement(self.id, statement, date_format)
end