Class: XeroAPI
- Inherits:
-
Object
- Object
- XeroAPI
- Defined in:
- lib/xero_api.rb
Constant Summary collapse
- XERO_CONNECTOR_URL =
'http://xero.accountdock.com'
Instance Method Summary collapse
- #accounts(type = nil) ⇒ Object
- #balance(bank_name) ⇒ Object
-
#initialize(xero_guid) ⇒ XeroAPI
constructor
A new instance of XeroAPI.
- #new_invoice(invoice_data, category_code) ⇒ Object
- #new_transaction(transaction_data, category_code) ⇒ Object
- #new_transfer(transfer_data) ⇒ Object
Constructor Details
#initialize(xero_guid) ⇒ XeroAPI
Returns a new instance of XeroAPI.
7 8 9 |
# File 'lib/xero_api.rb', line 7 def initialize(xero_guid) @xero_guid = xero_guid end |
Instance Method Details
#accounts(type = nil) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/xero_api.rb', line 11 def accounts(type = nil) return cached_accounts if type.nil? cached_accounts.find_all { |account| account.type == type } rescue StandardError # Handles unauthorized case [] end |
#balance(bank_name) ⇒ Object
30 31 32 |
# File 'lib/xero_api.rb', line 30 def balance(bank_name) post('/balance', data: { bank_name: bank_name }).body end |
#new_invoice(invoice_data, category_code) ⇒ Object
22 23 24 |
# File 'lib/xero_api.rb', line 22 def new_invoice(invoice_data, category_code) post('/invoices/new', data: invoice_data, category_code: category_code) end |
#new_transaction(transaction_data, category_code) ⇒ Object
18 19 20 |
# File 'lib/xero_api.rb', line 18 def new_transaction(transaction_data, category_code) post('/transactions/new', data: transaction_data, category_code: category_code) end |
#new_transfer(transfer_data) ⇒ Object
26 27 28 |
# File 'lib/xero_api.rb', line 26 def new_transfer(transfer_data) post('/transfers/new', data: transfer_data) end |