class XeroCLI::Commands::Transfer
Constants
- TRANSACTION_TYPE
Attributes
from[R]
on[R]
to[R]
transfer[R]
Public Class Methods
new(options)
click to toggle source
# File lib/xero_cli/commands/transfer.rb, line 4 def initialize(options) @transfer = options.transfer.to_f @to = options.to @from = options.from @on = options.on end
Public Instance Methods
perform()
click to toggle source
# File lib/xero_cli/commands/transfer.rb, line 11 def perform check_exceptions transfer_attributes = XeroCLI::Templates::Transfer.attributes(transfer, from, to, on) create_transfer(transfer_attributes) write_to_terminal end
Private Instance Methods
check_exceptions()
click to toggle source
# File lib/xero_cli/commands/transfer.rb, line 22 def check_exceptions raise Exception, 'Amount should positive' if transfer.negative? || transfer.zero? raise Exception, 'Please add "--from NAME"' if from.nil? raise Exception, 'Please add "--to NAME"' if to.nil? end
create_transfer(json)
click to toggle source
# File lib/xero_cli/commands/transfer.rb, line 36 def create_transfer(json) xero_api.new_transfer(json) end
write_to_terminal()
click to toggle source
# File lib/xero_cli/commands/transfer.rb, line 28 def write_to_terminal output = ["Transfer #{transfer}"] output << "from #{from}" output << "to #{to}" output << "on #{format_date(on)}" if on ap output.join(' ') end