xero_gateway-float 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/xero_gateway/gateway.rb
CHANGED
@@ -709,6 +709,7 @@ module XeroGateway
|
|
709
709
|
when "ManualJournal"
|
710
710
|
response.response_item = ManualJournal.from_xml(element, self, {:journal_lines_downloaded => options[:request_signature] != "GET/ManualJournals"})
|
711
711
|
when "Contacts" then element.children.each {|child| response.response_item << Contact.from_xml(child, self) }
|
712
|
+
when "Payments" then element.children.each {|child| response.response_item << Payment.from_xml(child, self) }
|
712
713
|
when "Invoices" then element.children.each {|child| response.response_item << Invoice.from_xml(child, self, {:line_items_downloaded => options[:request_signature] != "GET/Invoices"}) }
|
713
714
|
when "BankTransactions"
|
714
715
|
element.children.each do |child|
|
data/lib/xero_gateway/payment.rb
CHANGED
@@ -3,11 +3,14 @@ module XeroGateway
|
|
3
3
|
include Money
|
4
4
|
include Dates
|
5
5
|
|
6
|
+
# Xero::Gateway associated with this contact.
|
7
|
+
attr_accessor :gateway
|
8
|
+
#
|
6
9
|
# Any errors that occurred when the #valid? method called.
|
7
10
|
attr_reader :errors
|
8
11
|
|
9
12
|
# All accessible fields
|
10
|
-
attr_accessor :invoice_id, :invoice_number, :
|
13
|
+
attr_accessor :invoice_id, :invoice, :invoice_number, :account, :code, :payment_id, :date, :amount, :reference, :currency_rate, :account_id
|
11
14
|
|
12
15
|
def initialize(params = {})
|
13
16
|
@errors ||= []
|
@@ -17,8 +20,8 @@ module XeroGateway
|
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
|
-
def self.from_xml(payment_element)
|
21
|
-
payment = Payment.new
|
23
|
+
def self.from_xml(payment_element, gateway = nil)
|
24
|
+
payment = Payment.new(:gateway => gateway)
|
22
25
|
payment_element.children.each do | element |
|
23
26
|
case element.name
|
24
27
|
when 'PaymentID' then payment.payment_id = element.text
|
@@ -26,8 +29,8 @@ module XeroGateway
|
|
26
29
|
when 'Amount' then payment.amount = BigDecimal.new(element.text)
|
27
30
|
when 'Reference' then payment.reference = element.text
|
28
31
|
when 'CurrencyRate' then payment.currency_rate = BigDecimal.new(element.text)
|
29
|
-
when 'Invoice' then payment.
|
30
|
-
when 'Account' then payment.
|
32
|
+
when 'Invoice' then payment.invoice = Invoice.from_xml(element)
|
33
|
+
when 'Account' then payment.account = Account.from_xml(element)
|
31
34
|
end
|
32
35
|
end
|
33
36
|
payment
|
@@ -21,6 +21,7 @@ module XeroGateway
|
|
21
21
|
alias_method :tracking_categories, :array_wrapped_response_item
|
22
22
|
alias_method :tax_rates, :array_wrapped_response_item
|
23
23
|
alias_method :currencies, :array_wrapped_response_item
|
24
|
+
alias_method :payments, :array_wrapped_response_item
|
24
25
|
|
25
26
|
def initialize(params = {})
|
26
27
|
params.each do |k,v|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class GetPaymentsTest < Test::Unit::TestCase
|
4
|
+
include TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
|
8
|
+
|
9
|
+
if STUB_XERO_CALLS
|
10
|
+
@gateway.xero_url = "DUMMY_URL"
|
11
|
+
|
12
|
+
@gateway.stubs(:http_get).with {|client, url, params| url =~ /Payments$/ }.returns(get_file_as_string("payments.xml"))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_get_payments
|
17
|
+
result = @gateway.get_payments
|
18
|
+
assert result.success?
|
19
|
+
assert !result.request_params.nil?
|
20
|
+
assert !result.response_xml.nil?
|
21
|
+
assert result.payments.length == 57
|
22
|
+
assert result.payments.collect {|c| c.payment_id}.include?("4c955477-b582-4d5e-898a-86fa14e461fb")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Make sure that a reference to gateway is passed when the get_contacts response is parsed.
|
26
|
+
def test_get_payments_gateway_reference
|
27
|
+
result = @gateway.get_payments
|
28
|
+
assert(result.success?)
|
29
|
+
assert_not_equal(0, result.payments.size)
|
30
|
+
|
31
|
+
result.payments.each do | payment |
|
32
|
+
assert(payment.gateway === @gateway)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/xero_gateway.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xero_gateway-float
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- test/integration/get_manual_journal_test.rb
|
127
127
|
- test/integration/get_manual_journals_test.rb
|
128
128
|
- test/integration/get_organisation_test.rb
|
129
|
+
- test/integration/get_payments_test.rb
|
129
130
|
- test/integration/get_tax_rates_test.rb
|
130
131
|
- test/integration/get_tracking_categories_test.rb
|
131
132
|
- test/integration/update_bank_transaction_test.rb
|