Class: XeroCLI::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_cli/commands/base.rb

Direct Known Subclasses

Accounts, Balance, Receive, Spend, Transfer

Instance Method Summary collapse

Instance Method Details

#format_date(on) ⇒ Object



16
17
18
# File 'lib/xero_cli/commands/base.rb', line 16

def format_date(on)
  Time.at(on).strftime('%d-%m-%Y')
end

#money_to_cents(amount) ⇒ Object



12
13
14
# File 'lib/xero_cli/commands/base.rb', line 12

def money_to_cents(amount)
  amount / 100.0
end

#read_guidObject



2
3
4
# File 'lib/xero_cli/commands/base.rb', line 2

def read_guid
  @read_guid ||= XeroCLI::Credentials.read_guid
end

#xero_apiObject



6
7
8
9
10
# File 'lib/xero_cli/commands/base.rb', line 6

def xero_api
  @xero_api ||= XeroAPI.new(read_guid)
rescue StandardError
  raise Exception, 'Please set XERO_CONNECTOR_URL' if ENV['XERO_CONNECTOR_URL'].empty?
end