Class: XeroGateway::Payment
- Inherits:
-
Object
- Object
- XeroGateway::Payment
- Defined in:
- lib/xero_gateway/payment.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
All accessible fields.
-
#currency_rate ⇒ Object
All accessible fields.
-
#date ⇒ Object
All accessible fields.
-
#errors ⇒ Object
readonly
Any errors that occurred when the #valid? method called.
-
#payment_id ⇒ Object
All accessible fields.
-
#reference ⇒ Object
All accessible fields.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(params = {}) ⇒ Payment
constructor
A new instance of Payment.
Methods included from Dates
Methods included from Money
Constructor Details
#initialize(params = {}) ⇒ Payment
Returns a new instance of Payment.
12 13 14 15 16 17 18 |
# File 'lib/xero_gateway/payment.rb', line 12 def initialize(params = {}) @errors ||= [] params.each do |k,v| self.send("#{k}=", v) end end |
Instance Attribute Details
#amount ⇒ Object
All accessible fields
10 11 12 |
# File 'lib/xero_gateway/payment.rb', line 10 def amount @amount end |
#currency_rate ⇒ Object
All accessible fields
10 11 12 |
# File 'lib/xero_gateway/payment.rb', line 10 def currency_rate @currency_rate end |
#date ⇒ Object
All accessible fields
10 11 12 |
# File 'lib/xero_gateway/payment.rb', line 10 def date @date end |
#errors ⇒ Object (readonly)
Any errors that occurred when the #valid? method called.
7 8 9 |
# File 'lib/xero_gateway/payment.rb', line 7 def errors @errors end |
#payment_id ⇒ Object
All accessible fields
10 11 12 |
# File 'lib/xero_gateway/payment.rb', line 10 def payment_id @payment_id end |
#reference ⇒ Object
All accessible fields
10 11 12 |
# File 'lib/xero_gateway/payment.rb', line 10 def reference @reference end |
Class Method Details
.from_xml(payment_element) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/xero_gateway/payment.rb', line 20 def self.from_xml(payment_element) payment = Payment.new payment_element.children.each do | element | case element.name when 'PaymentID' then payment.payment_id = element.text when 'Date' then payment.date = parse_date_time(element.text) when 'Amount' then payment.amount = BigDecimal.new(element.text) when 'Reference' then payment.reference = element.text when 'CurrencyRate' then payment.currency_rate = BigDecimal.new(element.text) end end payment end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/xero_gateway/payment.rb', line 34 def ==(other) [:payment_id, :date, :amount].each do |field| return false if send(field) != other.send(field) end return true end |