Class: Kojn::Invoice

Inherits:
Model
  • Object
show all
Defined in:
lib/kojn/invoice.rb

Constant Summary collapse

UNCONFIRMED =
1
INSUFFICIENT =
2
SEEN =
3
CANCELLED =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#attributes, #attributes=, #initialize

Constructor Details

This class inherits a constructor from Kojn::Model

Instance Attribute Details

#addressObject

Returns the value of attribute address.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def address
  @address
end

#amountObject

Returns the value of attribute amount.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def amount
  @amount
end

#amount_in_fiatObject

Returns the value of attribute amount_in_fiat.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def amount_in_fiat
  @amount_in_fiat
end

#amount_leftObject

Returns the value of attribute amount_left.



12
13
14
# File 'lib/kojn/invoice.rb', line 12

def amount_left
  @amount_left
end

#confirmedObject

Returns the value of attribute confirmed.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def confirmed
  @confirmed
end

#currencyObject

Returns the value of attribute currency.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def currency
  @currency
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def description
  @description
end

#errorObject

Returns the value of attribute error.



13
14
15
# File 'lib/kojn/invoice.rb', line 13

def error
  @error
end

#errorsObject

Returns the value of attribute errors.



13
14
15
# File 'lib/kojn/invoice.rb', line 13

def errors
  @errors
end

#exchange_rateObject

Returns the value of attribute exchange_rate.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def exchange_rate
  @exchange_rate
end

#external_idObject

Returns the value of attribute external_id.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def external_id
  @external_id
end

#internal_idObject

Returns the value of attribute internal_id.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def internal_id
  @internal_id
end

#messageObject

Returns the value of attribute message.



13
14
15
# File 'lib/kojn/invoice.rb', line 13

def message
  @message
end

Returns the value of attribute paid.



12
13
14
# File 'lib/kojn/invoice.rb', line 12

def paid
  @paid
end

#received_amountObject

Returns the value of attribute received_amount.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def received_amount
  @received_amount
end

#received_amount_in_fiatObject

Returns the value of attribute received_amount_in_fiat.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def received_amount_in_fiat
  @received_amount_in_fiat
end

#redirect_uriObject

Returns the value of attribute redirect_uri.



12
13
14
# File 'lib/kojn/invoice.rb', line 12

def redirect_uri
  @redirect_uri
end

#seenObject

Returns the value of attribute seen.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def seen
  @seen
end

#source_currencyObject

Returns the value of attribute source_currency.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def source_currency
  @source_currency
end

#statusObject

Returns the value of attribute status.



11
12
13
# File 'lib/kojn/invoice.rb', line 11

def status
  @status
end

Instance Method Details

#new_record?Boolean

Returns whether this ‘record’ is new. Inspired by rails :) TODO Make sure if a newly initialized object’s internal_id is actually set to nil.

Returns:

  • (Boolean)


27
28
29
# File 'lib/kojn/invoice.rb', line 27

def new_record?
  self.internal_id == nil
end

#saveObject



15
16
17
18
19
20
21
22
23
# File 'lib/kojn/invoice.rb', line 15

def save
  # Uses the invoices helper class to create and update
  # Copies the returned invoices' attributes over to its own.
  if self.new_record?
    self.attributes = Kojn.invoices.create(self.attributes).attributes
  else
    self.attributes = Kojn.invoices.update(self.internal_id, self.attributes).attributes
  end
end