xeroizer 0.2.2 → 0.3.0
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/VERSION +1 -1
- data/lib/xeroizer/exceptions.rb +13 -0
- data/lib/xeroizer/generic_application.rb +1 -0
- data/lib/xeroizer/models/credit_note.rb +1 -0
- data/lib/xeroizer/models/employee.rb +28 -0
- data/lib/xeroizer/models/external_link.rb +16 -0
- data/lib/xeroizer/models/invoice.rb +2 -0
- data/lib/xeroizer/models/organisation.rb +13 -7
- data/lib/xeroizer/models/payment.rb +1 -1
- data/lib/xeroizer/models/tracking_category_child.rb +4 -1
- data/lib/xeroizer/record/base.rb +2 -2
- data/lib/xeroizer/record/base_model.rb +21 -3
- data/lib/xeroizer/record/model_definition_helper.rb +6 -2
- data/lib/xeroizer/record/record_association_helper.rb +42 -4
- data/lib/xeroizer/record/xml_helper.rb +3 -2
- data/lib/xeroizer/report/factory.rb +3 -2
- data/lib/xeroizer/response.rb +1 -1
- data/lib/xeroizer.rb +1 -0
- data/test/stub_responses/contacts.xml +0 -3349
- data/test/stub_responses/credit_note.xml +37 -31
- data/test/stub_responses/credit_notes.xml +54 -34
- data/test/stub_responses/employees.xml +29 -0
- data/test/stub_responses/invoice.xml +44 -51
- data/test/stub_responses/invoices.xml +1180 -1055
- data/test/stub_responses/organisation.xml +10 -1
- data/test/stub_responses/organisations.xml +13 -4
- data/test/stub_responses/payments.xml +1121 -0
- data/test/stub_responses/records/credit_note-371cd138-1e5c-4ec1-a8c6-a1c10e8bdab1.xml +13 -9
- data/test/stub_responses/records/credit_note-3bffc09b-79f2-490d-b91b-c59b700b43a4.xml +13 -9
- data/test/stub_responses/records/credit_note-43c678ee-f357-48e2-b192-b6e3634762f9.xml +13 -9
- data/test/stub_responses/records/credit_note-482c018b-d329-4e05-9b4f-7a4cfc695aa0.xml +13 -9
- data/test/stub_responses/records/credit_note-4f67130a-749a-4ee6-98b2-743adbc11245.xml +11 -9
- data/test/stub_responses/records/credit_note-50e98404-2fba-4031-af67-8ba4bb227c44.xml +12 -9
- data/test/stub_responses/records/credit_note-7df8949c-b71f-40c0-bbcf-39f2f450f286.xml +11 -9
- data/test/stub_responses/records/credit_note-b356e488-2678-4be4-ad4b-d294df2d48d6.xml +9 -7
- data/test/stub_responses/records/invoice-0032f627-3156-4d30-9b1c-4d3b994dc921.xml +13 -11
- data/test/stub_responses/records/invoice-00c9511b-24b9-4190-a90a-8abf2fe9f4a0.xml +13 -11
- data/test/stub_responses/records/invoice-024d7994-a26c-4c20-9894-13934840fc31.xml +12 -11
- data/test/stub_responses/records/invoice-0e64a623-c2a1-446a-93ed-eb897f118cbc.xml +9 -8
- data/test/stub_responses/records/invoice-15e88e57-2554-4496-a18e-eb3f5c622345.xml +13 -11
- data/test/stub_responses/records/invoice-166f0588-d0ba-458c-b28a-8edd4c8fc463.xml +13 -11
- data/test/stub_responses/records/invoice-1d1ba340-afa2-4f4c-8ff7-a147bda9a47b.xml +13 -11
- data/test/stub_responses/records/invoice-290ef4c4-baec-492b-b4dd-c102826470ae.xml +13 -11
- data/test/stub_responses/records/invoice-30a87092-31b5-4a2c-831e-327486533dd2.xml +10 -8
- data/test/stub_responses/records/invoice-30dbd181-72a8-43df-b392-4241bf43d5fc.xml +22 -11
- data/test/stub_responses/records/invoice-33e4123e-7cdd-4f05-9a0a-eb8adeb2b868.xml +13 -11
- data/test/stub_responses/records/invoice-387db692-26ac-47e6-b6cc-015343809bda.xml +13 -11
- data/test/stub_responses/records/invoice-3b28bf11-ed2f-4cf4-8e9e-fcae730cc292.xml +13 -11
- data/test/stub_responses/records/invoice-3fcb9847-b350-412e-ab90-7d9d774ad881.xml +13 -11
- data/test/stub_responses/records/invoice-440613e4-4785-4eff-9ba1-c432816cf8c7.xml +78 -0
- data/test/stub_responses/records/invoice-4602eda6-abe9-448e-b65f-ae6bea21f0eb.xml +10 -8
- data/test/stub_responses/records/invoice-46441f63-873f-4cdc-a278-b8fe516f3abb.xml +11 -8
- data/test/stub_responses/records/invoice-4ad1ec01-f4a3-41d7-bbb4-d2ab2fec8e65.xml +12 -11
- data/test/stub_responses/records/invoice-4b9afceb-f7c7-4e64-8aac-7b009971fd52.xml +13 -11
- data/test/stub_responses/records/invoice-4edbf6d5-4e92-43af-bedd-7effc0b86833.xml +10 -8
- data/test/stub_responses/records/invoice-4fad1af2-b871-4ac5-a15a-3c5e32d2e2c4.xml +19 -9
- data/test/stub_responses/records/invoice-52ee4d67-cae4-462c-adb2-182c39017f3d.xml +13 -11
- data/test/stub_responses/records/invoice-54585f46-c1a0-4432-bd4f-c1fae2fba59b.xml +9 -8
- data/test/stub_responses/records/invoice-5613938b-9e27-472e-92ae-3b038b669d10.xml +13 -11
- data/test/stub_responses/records/invoice-5aa9451d-95d1-4f95-a966-bbab2573f71c.xml +10 -8
- data/test/stub_responses/records/invoice-5aadcd34-01a9-4b8d-a2bb-d7cc1de9fa45.xml +13 -11
- data/test/stub_responses/records/invoice-5f6deadf-36a2-495a-9980-ceb11e8af9a9.xml +10 -8
- data/test/stub_responses/records/invoice-625ffe1b-f5d8-438e-a376-981de5f5a733.xml +13 -11
- data/test/stub_responses/records/invoice-64cd559e-8e03-46af-b461-8555285cee71.xml +10 -8
- data/test/stub_responses/records/invoice-66fbe37f-49b1-43fd-97ed-85114022cd2f.xml +10 -8
- data/test/stub_responses/records/invoice-673dd7cc-beb7-4697-83d4-0c47cb400cc2.xml +21 -11
- data/test/stub_responses/records/invoice-69fc971e-9b37-41c5-9c87-174330f22343.xml +9 -8
- data/test/stub_responses/records/invoice-70e6db69-e5a4-42c7-a397-aa3212c2945f.xml +10 -8
- data/test/stub_responses/records/invoice-766d1289-b440-4675-a656-1a0612ecac77.xml +13 -11
- data/test/stub_responses/records/invoice-76bcb361-f93b-4513-b312-5a4af306d276.xml +9 -8
- data/test/stub_responses/records/invoice-76e3f056-479f-417c-a72b-f3d767899b87.xml +13 -11
- data/test/stub_responses/records/invoice-77b338ef-ecc0-4b95-a0d7-2617b0054611.xml +21 -10
- data/test/stub_responses/records/invoice-7be9956d-5316-4f6b-a66a-d355b3f159b2.xml +13 -11
- data/test/stub_responses/records/invoice-7dae876a-b424-436b-a4e6-17b3fdeec80c.xml +20 -11
- data/test/stub_responses/records/invoice-7e862d93-8dab-4856-8b0c-d844e09d750f.xml +10 -8
- data/test/stub_responses/records/invoice-803f70b0-56d9-4157-9787-41df271777a0.xml +13 -11
- data/test/stub_responses/records/invoice-86102312-aa3f-438c-9938-6840f4d8dda6.xml +12 -11
- data/test/stub_responses/records/invoice-8694c9c5-7097-4449-a708-b8c1982921a4.xml +9 -8
- data/test/stub_responses/records/invoice-86d6e00f-ef56-49f7-9a54-796ccd5ca057.xml +10 -8
- data/test/stub_responses/records/invoice-88e77f0f-54a5-4efc-a979-7e22223cc4d7.xml +9 -8
- data/test/stub_responses/records/invoice-8b0ccb6a-d9b7-4da5-8360-ef7fb157b5aa.xml +9 -8
- data/test/stub_responses/records/invoice-935fc854-8037-4111-8d91-993010c331cc.xml +12 -11
- data/test/stub_responses/records/invoice-962ef33f-c9d2-4602-9b9f-93a02bea23b3.xml +13 -10
- data/test/stub_responses/records/invoice-9868b472-1983-48e9-8edf-7e81ddf2c03a.xml +10 -8
- data/test/stub_responses/records/invoice-a3bc62ef-f11b-4a9c-a4f9-a342bda371b5.xml +9 -8
- data/test/stub_responses/records/invoice-a6894ca0-60ee-4d45-9dd4-b44fcba46ec5.xml +13 -11
- data/test/stub_responses/records/invoice-a77268ce-74b2-483d-a2b3-70dbdc9e49d2.xml +78 -0
- data/test/stub_responses/records/invoice-a9f765e6-b9bc-4505-a47b-fb3ecb327e7b.xml +14 -11
- data/test/stub_responses/records/invoice-aa0173af-8707-4e7f-8dde-4c7a357bd312.xml +30 -13
- data/test/stub_responses/records/invoice-ab63738a-370a-43a5-bfa3-620d684e66d0.xml +10 -8
- data/test/stub_responses/records/invoice-b0344791-5a8a-40dd-a208-d99a461a6c10.xml +13 -11
- data/test/stub_responses/records/invoice-b1e53910-473c-46a3-b3cb-38ece571220e.xml +21 -11
- data/test/stub_responses/records/invoice-b2c02d0b-41a8-4d4d-97d7-014c78b3547d.xml +13 -11
- data/test/stub_responses/records/invoice-b75b3928-ab72-4424-8b93-9cdbbde4cd72.xml +19 -9
- data/test/stub_responses/records/invoice-bcd8a71f-aa31-4d0f-8a01-13ea26363ddf.xml +13 -11
- data/test/stub_responses/records/invoice-bfbb7c45-de02-45e7-b065-d9863ecfb0d8.xml +9 -8
- data/test/stub_responses/records/invoice-c12aff7e-12bf-4185-8702-460929f19674.xml +9 -8
- data/test/stub_responses/records/invoice-c3380b96-976d-4b3e-8b26-8d01eb6a3742.xml +13 -11
- data/test/stub_responses/records/invoice-c963f2b0-cbe1-4abd-9ccc-7e512c942068.xml +9 -8
- data/test/stub_responses/records/invoice-cba46b29-3788-4158-b668-ab10160ccbfe.xml +78 -0
- data/test/stub_responses/records/invoice-dba2f021-f149-4191-a126-5351d587ab0e.xml +12 -11
- data/test/stub_responses/records/invoice-de5d9c29-21b3-4342-958b-ed72c4bd7ab0.xml +13 -11
- data/test/stub_responses/records/invoice-e3d96555-2876-4364-a46a-7551a4f52611.xml +15 -11
- data/test/stub_responses/records/invoice-e4a0afbd-aea0-450b-ae23-0ce921e84a77.xml +11 -8
- data/test/stub_responses/records/invoice-e9cb9ecb-58ef-43a8-bd20-69a85338142d.xml +13 -11
- data/test/stub_responses/records/invoice-ec9a6f67-7128-4a63-8ba3-5e516f455f9b.xml +13 -11
- data/test/stub_responses/records/invoice-ed0f2587-84fc-4aef-bc4b-b1a262e24484.xml +14 -11
- data/test/stub_responses/records/invoice-f362ca53-8ade-4047-865a-bb64bee5863d.xml +12 -11
- data/test/stub_responses/records/invoice-f571c38b-5be1-41e1-ad5a-ff6184284beb.xml +21 -11
- data/test/stub_responses/records/invoice-f5832195-5cd3-4660-ad3f-b73d9c64f263.xml +10 -8
- data/test/stub_responses/records/invoice-f9c857eb-64cd-4235-a078-d04b52c77ea7.xml +13 -11
- data/test/stub_responses/refresh_responses.rb +1 -1
- data/test/unit/record/record_association_test.rb +33 -0
- data/xeroizer.gemspec +9 -2
- metadata +11 -4
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.0
|
data/lib/xeroizer/exceptions.rb
CHANGED
|
@@ -94,4 +94,17 @@ module Xeroizer
|
|
|
94
94
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
+
class AssociationTypeMismatch < StandardError
|
|
98
|
+
|
|
99
|
+
def initialize(model_class, actual_class)
|
|
100
|
+
@model_class = model_class
|
|
101
|
+
@actual_class = actual_class
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def message
|
|
105
|
+
"#{@model_class} expected, got #{@actual_class}"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
|
|
97
110
|
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'xeroizer/models/external_link'
|
|
2
|
+
|
|
3
|
+
module Xeroizer
|
|
4
|
+
module Record
|
|
5
|
+
|
|
6
|
+
class EmployeeModel < BaseModel
|
|
7
|
+
|
|
8
|
+
set_permissions :read, :write, :update
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Employee < Base
|
|
13
|
+
|
|
14
|
+
set_primary_key :employee_id
|
|
15
|
+
|
|
16
|
+
guid :employee_id
|
|
17
|
+
string :status
|
|
18
|
+
string :first_name
|
|
19
|
+
string :last_name
|
|
20
|
+
|
|
21
|
+
belongs_to :external_link
|
|
22
|
+
|
|
23
|
+
validates_presence_of :first_name, :last_name
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -70,10 +70,12 @@ module Xeroizer
|
|
|
70
70
|
datetime :updated_date_utc, :api_name => 'UpdatedDateUTC'
|
|
71
71
|
string :currency_code
|
|
72
72
|
datetime :fully_paid_on_date
|
|
73
|
+
boolean :sent_to_contact
|
|
73
74
|
|
|
74
75
|
belongs_to :contact
|
|
75
76
|
has_many :line_items
|
|
76
77
|
has_many :payments
|
|
78
|
+
has_many :credit_notes
|
|
77
79
|
|
|
78
80
|
validates_presence_of :date, :due_date
|
|
79
81
|
validates_inclusion_of :type, :in => INVOICE_TYPES
|
|
@@ -10,13 +10,19 @@ module Xeroizer
|
|
|
10
10
|
|
|
11
11
|
class Organisation < Base
|
|
12
12
|
|
|
13
|
-
string
|
|
14
|
-
string
|
|
15
|
-
boolean
|
|
16
|
-
string
|
|
17
|
-
string
|
|
18
|
-
string
|
|
19
|
-
|
|
13
|
+
string :name
|
|
14
|
+
string :legal_name
|
|
15
|
+
boolean :pays_tax
|
|
16
|
+
string :version
|
|
17
|
+
string :organisation_type
|
|
18
|
+
string :base_currency
|
|
19
|
+
integer :financial_year_end_day
|
|
20
|
+
integer :financial_year_end_month
|
|
21
|
+
date :period_lock_date
|
|
22
|
+
date :end_of_year_lock_date
|
|
23
|
+
string :registration_number
|
|
24
|
+
datetime :created_date_utc, :api_name => 'CreatedDateUTC'
|
|
25
|
+
|
|
20
26
|
end
|
|
21
27
|
|
|
22
28
|
end
|
data/lib/xeroizer/record/base.rb
CHANGED
|
@@ -109,8 +109,8 @@ module Xeroizer
|
|
|
109
109
|
|
|
110
110
|
# Parse the response from a create/update request.
|
|
111
111
|
def parse_save_response(response_xml)
|
|
112
|
-
|
|
113
|
-
record =
|
|
112
|
+
response = parent.parse_response(response_xml)
|
|
113
|
+
record = response.response_items.first if response.response_items.is_a?(Array)
|
|
114
114
|
if record && record.is_a?(self.class)
|
|
115
115
|
@attributes = record.attributes
|
|
116
116
|
end
|
|
@@ -14,6 +14,9 @@ module Xeroizer
|
|
|
14
14
|
ALLOWED_PERMISSIONS = [:read, :write, :update]
|
|
15
15
|
class_inheritable_attributes :permissions
|
|
16
16
|
|
|
17
|
+
class_inheritable_attributes :xml_root_name
|
|
18
|
+
class_inheritable_attributes :xml_node_name
|
|
19
|
+
|
|
17
20
|
include BaseModelHttpProxy
|
|
18
21
|
|
|
19
22
|
attr_reader :application
|
|
@@ -43,6 +46,19 @@ module Xeroizer
|
|
|
43
46
|
end
|
|
44
47
|
end
|
|
45
48
|
|
|
49
|
+
# Method to allow override of the default XML node name.
|
|
50
|
+
#
|
|
51
|
+
# Default: singularized model name in camel-case.
|
|
52
|
+
def set_xml_node_name(node_name)
|
|
53
|
+
self.xml_node_name = node_name
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Method to allow override of the default XML root name to use
|
|
57
|
+
# in has_many associations.
|
|
58
|
+
def set_xml_root_name(root_name)
|
|
59
|
+
self.xml_root_name = root_name
|
|
60
|
+
end
|
|
61
|
+
|
|
46
62
|
end
|
|
47
63
|
|
|
48
64
|
public
|
|
@@ -73,7 +89,8 @@ module Xeroizer
|
|
|
73
89
|
def all(options = {})
|
|
74
90
|
raise MethodNotAllowed.new(self, :all) unless self.class.permissions[:read]
|
|
75
91
|
response_xml = http_get(parse_params(options))
|
|
76
|
-
parse_response(response_xml, options)
|
|
92
|
+
response = parse_response(response_xml, options)
|
|
93
|
+
response.response_items || []
|
|
77
94
|
end
|
|
78
95
|
|
|
79
96
|
# Helper method to retrieve just the first element from
|
|
@@ -88,8 +105,8 @@ module Xeroizer
|
|
|
88
105
|
def find(id, options = {})
|
|
89
106
|
raise MethodNotAllowed.new(self, :all) unless self.class.permissions[:read]
|
|
90
107
|
response_xml = @application.http_get(@application.client, "#{url}/#{CGI.escape(id)}", options)
|
|
91
|
-
|
|
92
|
-
result =
|
|
108
|
+
response = parse_response(response_xml, options)
|
|
109
|
+
result = response.response_items.first if response.response_items.is_a?(Array)
|
|
93
110
|
result.complete_record_downloaded = true if result
|
|
94
111
|
result
|
|
95
112
|
end
|
|
@@ -97,6 +114,7 @@ module Xeroizer
|
|
|
97
114
|
def parse_response(response_xml, options = {})
|
|
98
115
|
Response.parse(response_xml, options) do | response, elements, response_model_name |
|
|
99
116
|
if model_name == response_model_name
|
|
117
|
+
@response = response
|
|
100
118
|
parse_records(response, elements)
|
|
101
119
|
end
|
|
102
120
|
end
|
|
@@ -56,6 +56,7 @@ module Xeroizer
|
|
|
56
56
|
# :api_name => allows the API name to be specified if it can't be properly converted from camelize.
|
|
57
57
|
# :model_name => allows class used for children to be different from it's ndoe name in the XML.
|
|
58
58
|
# :type => type of field
|
|
59
|
+
# :skip_writer => skip the writer method
|
|
59
60
|
def define_simple_attribute(field_name, field_type, options, value_if_nil = nil)
|
|
60
61
|
self.fields ||= {}
|
|
61
62
|
|
|
@@ -68,8 +69,11 @@ module Xeroizer
|
|
|
68
69
|
define_method internal_field_name do
|
|
69
70
|
@attributes[field_name] || value_if_nil
|
|
70
71
|
end
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
unless options[:skip_writer]
|
|
74
|
+
define_method "#{internal_field_name}=".to_sym do | value |
|
|
75
|
+
@attributes[field_name] = value
|
|
76
|
+
end
|
|
73
77
|
end
|
|
74
78
|
end
|
|
75
79
|
|
|
@@ -62,27 +62,65 @@ module Xeroizer
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# Add each record.
|
|
65
|
+
record = nil
|
|
65
66
|
records.each do | record |
|
|
66
67
|
record = record_class.build(record, model_parent) if record.is_a?(Hash)
|
|
67
68
|
raise StandardError.new("Record #{record.class.name} is not a #{record_class.name}.") unless record.is_a?(record_class)
|
|
68
69
|
self.attributes[field_name] ||= []
|
|
69
70
|
self.attributes[field_name] << record
|
|
70
71
|
end
|
|
72
|
+
record # last record
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
def define_association_attribute(field_name, internal_field_name, association_type, options)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
define_simple_attribute(field_name, association_type, options.merge!(:skip_writer => true), ((association_type == :has_many) ? [] : nil))
|
|
79
|
+
|
|
80
|
+
internal_field_name = options[:internal_name] || field_name
|
|
81
|
+
internal_singular_field_name = internal_field_name.to_s.singularize
|
|
82
|
+
model_name = options[:model_name] ? options[:model_name].to_sym : field_name.to_s.singularize.camelize.to_sym
|
|
83
|
+
|
|
84
|
+
define_method "#{internal_field_name}=".to_sym do | value |
|
|
85
|
+
record_class = Xeroizer::Record.const_get(model_name)
|
|
86
|
+
case value
|
|
87
|
+
when Hash
|
|
88
|
+
self.attributes[field_name] = ((association_type == :has_many) ? [] : nil)
|
|
89
|
+
case association_type
|
|
90
|
+
when :has_many
|
|
91
|
+
self.attributes[field_name] = []
|
|
92
|
+
self.send("add_#{internal_singular_field_name}".to_sym, value)
|
|
93
|
+
|
|
94
|
+
when :belongs_to
|
|
95
|
+
self.attributes[field_name] = Xeroizer::Record.const_get(model_name).build(value, new_model_class(model_name))
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
when Array
|
|
100
|
+
self.attributes[field_name] = ((association_type == :has_many) ? [] : nil)
|
|
101
|
+
value.each do | single_value |
|
|
102
|
+
case single_value
|
|
103
|
+
when Hash then send("add_#{internal_singular_field_name}".to_sym, single_value)
|
|
104
|
+
when record_class then self.attributes[field_name] << single_value
|
|
105
|
+
else raise AssociationTypeMismatch.new(record_class, single_value.class)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
when record_class
|
|
110
|
+
self.attributes[field_name] = ((association_type == :has_many) ? [value] : value)
|
|
111
|
+
|
|
112
|
+
else
|
|
113
|
+
raise AssociationTypeMismatch.new(record_class, value.class)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
79
117
|
# Override reader for this association if this association belongs
|
|
80
118
|
# to a summary-typed record. This will automatically attempt to download
|
|
81
119
|
# the complete version of the record before accessing the association.
|
|
82
120
|
if list_contains_summary_only?
|
|
83
121
|
define_method internal_field_name do
|
|
84
122
|
download_complete_record! unless new_record? || complete_record_downloaded?
|
|
85
|
-
|
|
123
|
+
self.attributes[field_name] || ((association_type == :has_many) ? [] : nil)
|
|
86
124
|
end
|
|
87
125
|
end
|
|
88
126
|
end
|
|
@@ -56,7 +56,7 @@ module Xeroizer
|
|
|
56
56
|
|
|
57
57
|
# Turn a record into its XML representation.
|
|
58
58
|
def to_xml(b = Builder::XmlMarkup.new(:indent => 2))
|
|
59
|
-
b.tag!(parent.model_name) {
|
|
59
|
+
b.tag!(parent.class.xml_node_name || parent.model_name) {
|
|
60
60
|
attributes.each do | key, value |
|
|
61
61
|
unless value.nil?
|
|
62
62
|
field = self.class.fields[key]
|
|
@@ -97,7 +97,8 @@ module Xeroizer
|
|
|
97
97
|
|
|
98
98
|
when :has_many
|
|
99
99
|
if value.size > 0
|
|
100
|
-
|
|
100
|
+
sub_parent = value.first.parent
|
|
101
|
+
b.tag!(sub_parent.class.xml_root_name || sub_parent.model_name.pluralize) {
|
|
101
102
|
value.each { | record | record.to_xml(b) }
|
|
102
103
|
}
|
|
103
104
|
nil
|
|
@@ -23,9 +23,10 @@ module Xeroizer
|
|
|
23
23
|
# valid query-string parameters to pass to the API.
|
|
24
24
|
def get(options = {})
|
|
25
25
|
response_xml = options[:cache_file] ? File.read(options[:cache_file]) : http_get(options)
|
|
26
|
-
Response.parse(response_xml, options) do | response, elements |
|
|
26
|
+
response = Response.parse(response_xml, options) do | response, elements |
|
|
27
27
|
parse_reports(response, elements)
|
|
28
|
-
end
|
|
28
|
+
end
|
|
29
|
+
response.response_items.first # there is is only one
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
def api_controller_name
|
data/lib/xeroizer/response.rb
CHANGED
data/lib/xeroizer.rb
CHANGED
|
@@ -33,6 +33,7 @@ require 'xeroizer/models/contact'
|
|
|
33
33
|
require 'xeroizer/models/contact_group'
|
|
34
34
|
require 'xeroizer/models/credit_note'
|
|
35
35
|
require 'xeroizer/models/currency'
|
|
36
|
+
require 'xeroizer/models/employee'
|
|
36
37
|
require 'xeroizer/models/invoice'
|
|
37
38
|
require 'xeroizer/models/item'
|
|
38
39
|
require 'xeroizer/models/item_purchase_sale_details'
|