xero-ruby 9.2.0 → 9.3.0.pre.alpha.1
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.
- checksums.yaml +4 -4
- data/lib/xero-ruby/api_client.rb +6 -6
- data/lib/xero-ruby/models/accounting/credit_note.rb +16 -4
- data/lib/xero-ruby/models/accounting/invoice.rb +16 -4
- data/lib/xero-ruby/models/accounting/invoice_address.rb +338 -0
- data/lib/xero-ruby/models/accounting/line_item.rb +75 -4
- data/lib/xero-ruby/models/accounting/tax_breakdown_component.rb +351 -0
- data/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +14 -4
- data/lib/xero-ruby/version.rb +2 -2
- data/lib/xero-ruby/where.rb +37 -37
- data/lib/xero-ruby.rb +2 -0
- data/spec/api_client_spec.rb +56 -56
- data/spec/api_error_spec.rb +1 -1
- data/spec/configuration_spec.rb +2 -2
- data/spec/helper_methods_spec.rb +3 -3
- data/spec/where_spec.rb +2 -2
- metadata +373 -371
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 486731b430129e918d848352a401ba021589c3e12fa49bfc3ecbc224a9c2eeeb
|
4
|
+
data.tar.gz: 29bc7c5ed9875728816d19d7f3ef86bc08b4bf80c2f13ec543334fdd8630bb6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 242f3d5386015779a15c3b17b66bcf193e786df58be1443cb9ad9571ad7c77a495659b3c0f8449b08502ea67675eb7c50e0e7a0f80d5acd54b1ac2f1ad5b4d70
|
7
|
+
data.tar.gz: 7359fc514fc845878a05f0235bb69a423392f2beef1d7ac9bcfeb2f2d91c9f4243f8570a0beca17cf8ccf249b608c5aad5ef09419bef126189706787fa32eba5
|
data/lib/xero-ruby/api_client.rb
CHANGED
@@ -52,7 +52,7 @@ module XeroRuby
|
|
52
52
|
|
53
53
|
def append_to_default_config(default_config, user_config)
|
54
54
|
config = default_config
|
55
|
-
user_config.each{|k,v| config.send("#{k}=", v)}
|
55
|
+
user_config.each { |k, v| config.send("#{k}=", v) }
|
56
56
|
config
|
57
57
|
end
|
58
58
|
|
@@ -194,7 +194,7 @@ module XeroRuby
|
|
194
194
|
return true
|
195
195
|
end
|
196
196
|
|
197
|
-
def decode_jwt(tkn, verify=true)
|
197
|
+
def decode_jwt(tkn, verify = true)
|
198
198
|
if verify == true
|
199
199
|
|
200
200
|
response = Faraday.get('https://identity.xero.com/.well-known/openid-configuration/jwks') do |req|
|
@@ -251,18 +251,18 @@ module XeroRuby
|
|
251
251
|
# Connection heplers
|
252
252
|
def connections
|
253
253
|
@config.base_url = 'https://api.xero.com'
|
254
|
-
opts = { :header_params => {'Content-Type': 'application/json'}, :auth_names => ['OAuth2'] }
|
254
|
+
opts = { :header_params => { 'Content-Type': 'application/json' }, :auth_names => ['OAuth2'] }
|
255
255
|
response = call_api(:GET, "/connections/", nil, opts)
|
256
256
|
response[0]
|
257
257
|
end
|
258
258
|
|
259
259
|
def last_connection
|
260
|
-
connections.sort { |a,b| DateTime.parse(a['updatedDateUtc']) <=> DateTime.parse(b['updatedDateUtc'])}.last
|
260
|
+
connections.sort { |a, b| DateTime.parse(a['updatedDateUtc']) <=> DateTime.parse(b['updatedDateUtc']) }.last
|
261
261
|
end
|
262
262
|
|
263
263
|
def disconnect(connection_id)
|
264
264
|
@config.base_url = 'https://api.xero.com'
|
265
|
-
opts = { :header_params => {'Content-Type': 'application/json'}, :auth_names => ['OAuth2'] }
|
265
|
+
opts = { :header_params => { 'Content-Type': 'application/json' }, :auth_names => ['OAuth2'] }
|
266
266
|
call_api(:DELETE, "/connections/#{connection_id}", nil, opts)
|
267
267
|
connections
|
268
268
|
end
|
@@ -286,7 +286,7 @@ module XeroRuby
|
|
286
286
|
when "AssetApi"
|
287
287
|
method_base_url = @config.asset_url
|
288
288
|
when "FilesApi"
|
289
|
-
|
289
|
+
method_base_url = @config.files_url
|
290
290
|
when "PayrollAuApi"
|
291
291
|
method_base_url = @config.payroll_au_url
|
292
292
|
when "PayrollNzApi"
|
@@ -114,6 +114,9 @@ module XeroRuby::Accounting
|
|
114
114
|
# Displays array of warning messages from the API
|
115
115
|
attr_accessor :warnings
|
116
116
|
|
117
|
+
# An array of addresses used to auto calculate sales tax
|
118
|
+
attr_accessor :invoice_addresses
|
119
|
+
|
117
120
|
class EnumAttributeValidator
|
118
121
|
attr_reader :datatype
|
119
122
|
attr_reader :allowable_values
|
@@ -168,7 +171,8 @@ module XeroRuby::Accounting
|
|
168
171
|
:'has_attachments' => :'HasAttachments',
|
169
172
|
:'has_errors' => :'HasErrors',
|
170
173
|
:'validation_errors' => :'ValidationErrors',
|
171
|
-
:'warnings' => :'Warnings'
|
174
|
+
:'warnings' => :'Warnings',
|
175
|
+
:'invoice_addresses' => :'InvoiceAddresses'
|
172
176
|
}
|
173
177
|
end
|
174
178
|
|
@@ -204,7 +208,8 @@ module XeroRuby::Accounting
|
|
204
208
|
:'has_attachments' => :'Boolean',
|
205
209
|
:'has_errors' => :'Boolean',
|
206
210
|
:'validation_errors' => :'Array<ValidationError>',
|
207
|
-
:'warnings' => :'Array<ValidationError>'
|
211
|
+
:'warnings' => :'Array<ValidationError>',
|
212
|
+
:'invoice_addresses' => :'Array<InvoiceAddress>'
|
208
213
|
}
|
209
214
|
end
|
210
215
|
|
@@ -356,6 +361,12 @@ module XeroRuby::Accounting
|
|
356
361
|
self.warnings = value
|
357
362
|
end
|
358
363
|
end
|
364
|
+
|
365
|
+
if attributes.key?(:'invoice_addresses')
|
366
|
+
if (value = attributes[:'invoice_addresses']).is_a?(Array)
|
367
|
+
self.invoice_addresses = value
|
368
|
+
end
|
369
|
+
end
|
359
370
|
end
|
360
371
|
|
361
372
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -429,7 +440,8 @@ module XeroRuby::Accounting
|
|
429
440
|
has_attachments == o.has_attachments &&
|
430
441
|
has_errors == o.has_errors &&
|
431
442
|
validation_errors == o.validation_errors &&
|
432
|
-
warnings == o.warnings
|
443
|
+
warnings == o.warnings &&
|
444
|
+
invoice_addresses == o.invoice_addresses
|
433
445
|
end
|
434
446
|
|
435
447
|
# @see the `==` method
|
@@ -441,7 +453,7 @@ module XeroRuby::Accounting
|
|
441
453
|
# Calculates hash code according to all attributes.
|
442
454
|
# @return [Integer] Hash code
|
443
455
|
def hash
|
444
|
-
[type, contact, date, due_date, status, line_amount_types, line_items, sub_total, total_tax, total, cis_deduction, cis_rate, updated_date_utc, currency_code, fully_paid_on_date, credit_note_id, credit_note_number, reference, sent_to_contact, currency_rate, remaining_credit, allocations, applied_amount, payments, branding_theme_id, status_attribute_string, has_attachments, has_errors, validation_errors, warnings].hash
|
456
|
+
[type, contact, date, due_date, status, line_amount_types, line_items, sub_total, total_tax, total, cis_deduction, cis_rate, updated_date_utc, currency_code, fully_paid_on_date, credit_note_id, credit_note_number, reference, sent_to_contact, currency_rate, remaining_credit, allocations, applied_amount, payments, branding_theme_id, status_attribute_string, has_attachments, has_errors, validation_errors, warnings, invoice_addresses].hash
|
445
457
|
end
|
446
458
|
|
447
459
|
# Builds the object from hash
|
@@ -150,6 +150,9 @@ module XeroRuby::Accounting
|
|
150
150
|
# Displays array of warning messages from the API
|
151
151
|
attr_accessor :warnings
|
152
152
|
|
153
|
+
# An array of addresses used to auto calculate sales tax
|
154
|
+
attr_accessor :invoice_addresses
|
155
|
+
|
153
156
|
class EnumAttributeValidator
|
154
157
|
attr_reader :datatype
|
155
158
|
attr_reader :allowable_values
|
@@ -214,7 +217,8 @@ module XeroRuby::Accounting
|
|
214
217
|
:'has_errors' => :'HasErrors',
|
215
218
|
:'status_attribute_string' => :'StatusAttributeString',
|
216
219
|
:'validation_errors' => :'ValidationErrors',
|
217
|
-
:'warnings' => :'Warnings'
|
220
|
+
:'warnings' => :'Warnings',
|
221
|
+
:'invoice_addresses' => :'InvoiceAddresses'
|
218
222
|
}
|
219
223
|
end
|
220
224
|
|
@@ -260,7 +264,8 @@ module XeroRuby::Accounting
|
|
260
264
|
:'has_errors' => :'Boolean',
|
261
265
|
:'status_attribute_string' => :'String',
|
262
266
|
:'validation_errors' => :'Array<ValidationError>',
|
263
|
-
:'warnings' => :'Array<ValidationError>'
|
267
|
+
:'warnings' => :'Array<ValidationError>',
|
268
|
+
:'invoice_addresses' => :'Array<InvoiceAddress>'
|
264
269
|
}
|
265
270
|
end
|
266
271
|
|
@@ -458,6 +463,12 @@ module XeroRuby::Accounting
|
|
458
463
|
self.warnings = value
|
459
464
|
end
|
460
465
|
end
|
466
|
+
|
467
|
+
if attributes.key?(:'invoice_addresses')
|
468
|
+
if (value = attributes[:'invoice_addresses']).is_a?(Array)
|
469
|
+
self.invoice_addresses = value
|
470
|
+
end
|
471
|
+
end
|
461
472
|
end
|
462
473
|
|
463
474
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -556,7 +567,8 @@ module XeroRuby::Accounting
|
|
556
567
|
has_errors == o.has_errors &&
|
557
568
|
status_attribute_string == o.status_attribute_string &&
|
558
569
|
validation_errors == o.validation_errors &&
|
559
|
-
warnings == o.warnings
|
570
|
+
warnings == o.warnings &&
|
571
|
+
invoice_addresses == o.invoice_addresses
|
560
572
|
end
|
561
573
|
|
562
574
|
# @see the `==` method
|
@@ -568,7 +580,7 @@ module XeroRuby::Accounting
|
|
568
580
|
# Calculates hash code according to all attributes.
|
569
581
|
# @return [Integer] Hash code
|
570
582
|
def hash
|
571
|
-
[type, contact, line_items, date, due_date, line_amount_types, invoice_number, reference, branding_theme_id, url, currency_code, currency_rate, status, sent_to_contact, expected_payment_date, planned_payment_date, cis_deduction, cis_rate, sub_total, total_tax, total, total_discount, invoice_id, repeating_invoice_id, has_attachments, is_discounted, payments, prepayments, overpayments, amount_due, amount_paid, fully_paid_on_date, amount_credited, updated_date_utc, credit_notes, attachments, has_errors, status_attribute_string, validation_errors, warnings].hash
|
583
|
+
[type, contact, line_items, date, due_date, line_amount_types, invoice_number, reference, branding_theme_id, url, currency_code, currency_rate, status, sent_to_contact, expected_payment_date, planned_payment_date, cis_deduction, cis_rate, sub_total, total_tax, total, total_discount, invoice_id, repeating_invoice_id, has_attachments, is_discounted, payments, prepayments, overpayments, amount_due, amount_paid, fully_paid_on_date, amount_credited, updated_date_utc, credit_notes, attachments, has_errors, status_attribute_string, validation_errors, warnings, invoice_addresses].hash
|
572
584
|
end
|
573
585
|
|
574
586
|
# Builds the object from hash
|
@@ -0,0 +1,338 @@
|
|
1
|
+
=begin
|
2
|
+
#Xero Accounting API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
Contact: api@xero.com
|
7
|
+
Generated by: https://openapi-generator.tech
|
8
|
+
OpenAPI Generator version: 4.3.1
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'time'
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module XeroRuby::Accounting
|
16
|
+
require 'bigdecimal'
|
17
|
+
|
18
|
+
class InvoiceAddress
|
19
|
+
# Indicates whether the address is defined as origin (FROM) or destination (TO)
|
20
|
+
attr_accessor :invoice_address_type
|
21
|
+
FROM ||= "FROM".freeze
|
22
|
+
TO ||= "TO".freeze
|
23
|
+
|
24
|
+
# First line of a physical address
|
25
|
+
attr_accessor :address_line1
|
26
|
+
|
27
|
+
# Second line of a physical address
|
28
|
+
attr_accessor :address_line2
|
29
|
+
|
30
|
+
# Third line of a physical address
|
31
|
+
attr_accessor :address_line3
|
32
|
+
|
33
|
+
# Fourth line of a physical address
|
34
|
+
attr_accessor :address_line4
|
35
|
+
|
36
|
+
# City of a physical address
|
37
|
+
attr_accessor :city
|
38
|
+
|
39
|
+
# Region or state of a physical address
|
40
|
+
attr_accessor :region
|
41
|
+
|
42
|
+
# Postal code of a physical address
|
43
|
+
attr_accessor :postal_code
|
44
|
+
|
45
|
+
# Country of a physical address
|
46
|
+
attr_accessor :country
|
47
|
+
|
48
|
+
class EnumAttributeValidator
|
49
|
+
attr_reader :datatype
|
50
|
+
attr_reader :allowable_values
|
51
|
+
|
52
|
+
def initialize(datatype, allowable_values)
|
53
|
+
@allowable_values = allowable_values.map do |value|
|
54
|
+
case datatype.to_s
|
55
|
+
when /Integer/i
|
56
|
+
value.to_i
|
57
|
+
when /Float/i
|
58
|
+
value.to_f
|
59
|
+
else
|
60
|
+
value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def valid?(value)
|
66
|
+
!value || allowable_values.include?(value)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
71
|
+
def self.attribute_map
|
72
|
+
{
|
73
|
+
:'invoice_address_type' => :'InvoiceAddressType',
|
74
|
+
:'address_line1' => :'AddressLine1',
|
75
|
+
:'address_line2' => :'AddressLine2',
|
76
|
+
:'address_line3' => :'AddressLine3',
|
77
|
+
:'address_line4' => :'AddressLine4',
|
78
|
+
:'city' => :'City',
|
79
|
+
:'region' => :'Region',
|
80
|
+
:'postal_code' => :'PostalCode',
|
81
|
+
:'country' => :'Country'
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
# Attribute type mapping.
|
86
|
+
def self.openapi_types
|
87
|
+
{
|
88
|
+
:'invoice_address_type' => :'String',
|
89
|
+
:'address_line1' => :'String',
|
90
|
+
:'address_line2' => :'String',
|
91
|
+
:'address_line3' => :'String',
|
92
|
+
:'address_line4' => :'String',
|
93
|
+
:'city' => :'String',
|
94
|
+
:'region' => :'String',
|
95
|
+
:'postal_code' => :'String',
|
96
|
+
:'country' => :'String'
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
# Initializes the object
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
def initialize(attributes = {})
|
103
|
+
if (!attributes.is_a?(Hash))
|
104
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Accounting::InvoiceAddress` initialize method"
|
105
|
+
end
|
106
|
+
|
107
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
108
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
109
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
110
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Accounting::InvoiceAddress`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
111
|
+
end
|
112
|
+
h[k.to_sym] = v
|
113
|
+
}
|
114
|
+
|
115
|
+
if attributes.key?(:'invoice_address_type')
|
116
|
+
self.invoice_address_type = attributes[:'invoice_address_type']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'address_line1')
|
120
|
+
self.address_line1 = attributes[:'address_line1']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'address_line2')
|
124
|
+
self.address_line2 = attributes[:'address_line2']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'address_line3')
|
128
|
+
self.address_line3 = attributes[:'address_line3']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'address_line4')
|
132
|
+
self.address_line4 = attributes[:'address_line4']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'city')
|
136
|
+
self.city = attributes[:'city']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'region')
|
140
|
+
self.region = attributes[:'region']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:'postal_code')
|
144
|
+
self.postal_code = attributes[:'postal_code']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.key?(:'country')
|
148
|
+
self.country = attributes[:'country']
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
153
|
+
# @return Array for valid properties with the reasons
|
154
|
+
def list_invalid_properties
|
155
|
+
invalid_properties = Array.new
|
156
|
+
invalid_properties
|
157
|
+
end
|
158
|
+
|
159
|
+
# Check to see if the all the properties in the model are valid
|
160
|
+
# @return true if the model is valid
|
161
|
+
def valid?
|
162
|
+
invoice_address_type_validator = EnumAttributeValidator.new('String', ["FROM", "TO"])
|
163
|
+
return false unless invoice_address_type_validator.valid?(@invoice_address_type)
|
164
|
+
true
|
165
|
+
end
|
166
|
+
|
167
|
+
# Custom attribute writer method checking allowed values (enum).
|
168
|
+
# @param [Object] invoice_address_type Object to be assigned
|
169
|
+
def invoice_address_type=(invoice_address_type)
|
170
|
+
validator = EnumAttributeValidator.new('String', ["FROM", "TO"])
|
171
|
+
unless validator.valid?(invoice_address_type)
|
172
|
+
fail ArgumentError, "invalid value for \"invoice_address_type\", must be one of #{validator.allowable_values}."
|
173
|
+
end
|
174
|
+
@invoice_address_type = invoice_address_type
|
175
|
+
end
|
176
|
+
|
177
|
+
# Checks equality by comparing each attribute.
|
178
|
+
# @param [Object] Object to be compared
|
179
|
+
def ==(o)
|
180
|
+
return true if self.equal?(o)
|
181
|
+
self.class == o.class &&
|
182
|
+
invoice_address_type == o.invoice_address_type &&
|
183
|
+
address_line1 == o.address_line1 &&
|
184
|
+
address_line2 == o.address_line2 &&
|
185
|
+
address_line3 == o.address_line3 &&
|
186
|
+
address_line4 == o.address_line4 &&
|
187
|
+
city == o.city &&
|
188
|
+
region == o.region &&
|
189
|
+
postal_code == o.postal_code &&
|
190
|
+
country == o.country
|
191
|
+
end
|
192
|
+
|
193
|
+
# @see the `==` method
|
194
|
+
# @param [Object] Object to be compared
|
195
|
+
def eql?(o)
|
196
|
+
self == o
|
197
|
+
end
|
198
|
+
|
199
|
+
# Calculates hash code according to all attributes.
|
200
|
+
# @return [Integer] Hash code
|
201
|
+
def hash
|
202
|
+
[invoice_address_type, address_line1, address_line2, address_line3, address_line4, city, region, postal_code, country].hash
|
203
|
+
end
|
204
|
+
|
205
|
+
# Builds the object from hash
|
206
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
207
|
+
# @return [Object] Returns the model itself
|
208
|
+
def self.build_from_hash(attributes)
|
209
|
+
new.build_from_hash(attributes)
|
210
|
+
end
|
211
|
+
|
212
|
+
# Builds the object from hash
|
213
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
214
|
+
# @return [Object] Returns the model itself
|
215
|
+
def build_from_hash(attributes)
|
216
|
+
return nil unless attributes.is_a?(Hash)
|
217
|
+
self.class.openapi_types.each_pair do |key, type|
|
218
|
+
if type =~ /\AArray<(.*)>/i
|
219
|
+
# check to ensure the input is an array given that the attribute
|
220
|
+
# is documented as an array but the input is not
|
221
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
222
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
223
|
+
end
|
224
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
225
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
226
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
227
|
+
end
|
228
|
+
|
229
|
+
self
|
230
|
+
end
|
231
|
+
|
232
|
+
# Deserializes the data based on type
|
233
|
+
# @param string type Data type
|
234
|
+
# @param string value Value to be deserialized
|
235
|
+
# @return [Object] Deserialized data
|
236
|
+
def _deserialize(type, value)
|
237
|
+
case type.to_sym
|
238
|
+
when :DateTime
|
239
|
+
DateTime.parse(parse_date(value))
|
240
|
+
when :Date
|
241
|
+
Date.parse(parse_date(value))
|
242
|
+
when :String
|
243
|
+
value.to_s
|
244
|
+
when :Integer
|
245
|
+
value.to_i
|
246
|
+
when :Float
|
247
|
+
value.to_f
|
248
|
+
when :BigDecimal
|
249
|
+
BigDecimal(value.to_s)
|
250
|
+
when :Boolean
|
251
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
252
|
+
true
|
253
|
+
else
|
254
|
+
false
|
255
|
+
end
|
256
|
+
when :Object
|
257
|
+
# generic object (usually a Hash), return directly
|
258
|
+
value
|
259
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
260
|
+
inner_type = Regexp.last_match[:inner_type]
|
261
|
+
value.map { |v| _deserialize(inner_type, v) }
|
262
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
263
|
+
k_type = Regexp.last_match[:k_type]
|
264
|
+
v_type = Regexp.last_match[:v_type]
|
265
|
+
{}.tap do |hash|
|
266
|
+
value.each do |k, v|
|
267
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
else # model
|
271
|
+
XeroRuby::Accounting.const_get(type).build_from_hash(value)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
# Returns the string representation of the object
|
276
|
+
# @return [String] String presentation of the object
|
277
|
+
def to_s
|
278
|
+
to_hash.to_s
|
279
|
+
end
|
280
|
+
|
281
|
+
# to_body is an alias to to_hash (backward compatibility)
|
282
|
+
# @return [Hash] Returns the object in the form of hash
|
283
|
+
def to_body
|
284
|
+
to_hash
|
285
|
+
end
|
286
|
+
|
287
|
+
# Returns the object in the form of hash
|
288
|
+
# @return [Hash] Returns the object in the form of hash
|
289
|
+
def to_hash(downcase: false)
|
290
|
+
hash = {}
|
291
|
+
self.class.attribute_map.each_pair do |attr, param|
|
292
|
+
value = self.send(attr)
|
293
|
+
next if value.nil?
|
294
|
+
key = downcase ? attr : param
|
295
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
296
|
+
end
|
297
|
+
hash
|
298
|
+
end
|
299
|
+
|
300
|
+
# Returns the object in the form of hash with snake_case
|
301
|
+
def to_attributes
|
302
|
+
to_hash(downcase: true)
|
303
|
+
end
|
304
|
+
|
305
|
+
# Outputs non-array value in the form of hash
|
306
|
+
# For object, use to_hash. Otherwise, just return the value
|
307
|
+
# @param [Object] value Any valid value
|
308
|
+
# @return [Hash] Returns the value in the form of hash
|
309
|
+
def _to_hash(value, downcase: false)
|
310
|
+
if value.is_a?(Array)
|
311
|
+
value.map do |v|
|
312
|
+
v.to_hash(downcase: downcase)
|
313
|
+
end
|
314
|
+
elsif value.is_a?(Hash)
|
315
|
+
{}.tap do |hash|
|
316
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
317
|
+
end
|
318
|
+
elsif value.respond_to? :to_hash
|
319
|
+
value.to_hash(downcase: downcase)
|
320
|
+
else
|
321
|
+
value
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
def parse_date(datestring)
|
326
|
+
if datestring.include?('Date')
|
327
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
328
|
+
original, date, timezone = *date_pattern.match(datestring)
|
329
|
+
date = (date.to_i / 1000)
|
330
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
331
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
332
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
333
|
+
else # handle date 'types' for small subset of payroll API's
|
334
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
@@ -61,6 +61,42 @@ module XeroRuby::Accounting
|
|
61
61
|
# The Xero identifier for a Repeating Invoice
|
62
62
|
attr_accessor :repeating_invoice_id
|
63
63
|
|
64
|
+
# The type of taxability
|
65
|
+
attr_accessor :taxability
|
66
|
+
TAXABLE ||= "TAXABLE".freeze
|
67
|
+
NON_TAXABLE ||= "NON_TAXABLE".freeze
|
68
|
+
EXEMPT ||= "EXEMPT".freeze
|
69
|
+
PART_TAXABLE ||= "PART_TAXABLE".freeze
|
70
|
+
NOT_APPLICABLE ||= "NOT_APPLICABLE".freeze
|
71
|
+
|
72
|
+
# The ID of the sales tax code
|
73
|
+
attr_accessor :sales_tax_code_id
|
74
|
+
|
75
|
+
# An array of tax components defined for this line item
|
76
|
+
attr_accessor :tax_breakdown
|
77
|
+
|
78
|
+
class EnumAttributeValidator
|
79
|
+
attr_reader :datatype
|
80
|
+
attr_reader :allowable_values
|
81
|
+
|
82
|
+
def initialize(datatype, allowable_values)
|
83
|
+
@allowable_values = allowable_values.map do |value|
|
84
|
+
case datatype.to_s
|
85
|
+
when /Integer/i
|
86
|
+
value.to_i
|
87
|
+
when /Float/i
|
88
|
+
value.to_f
|
89
|
+
else
|
90
|
+
value
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def valid?(value)
|
96
|
+
!value || allowable_values.include?(value)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
64
100
|
# Attribute mapping from ruby-style variable name to JSON key.
|
65
101
|
def self.attribute_map
|
66
102
|
{
|
@@ -78,7 +114,10 @@ module XeroRuby::Accounting
|
|
78
114
|
:'tracking' => :'Tracking',
|
79
115
|
:'discount_rate' => :'DiscountRate',
|
80
116
|
:'discount_amount' => :'DiscountAmount',
|
81
|
-
:'repeating_invoice_id' => :'RepeatingInvoiceID'
|
117
|
+
:'repeating_invoice_id' => :'RepeatingInvoiceID',
|
118
|
+
:'taxability' => :'Taxability',
|
119
|
+
:'sales_tax_code_id' => :'SalesTaxCodeId',
|
120
|
+
:'tax_breakdown' => :'TaxBreakdown'
|
82
121
|
}
|
83
122
|
end
|
84
123
|
|
@@ -99,7 +138,10 @@ module XeroRuby::Accounting
|
|
99
138
|
:'tracking' => :'Array<LineItemTracking>',
|
100
139
|
:'discount_rate' => :'BigDecimal',
|
101
140
|
:'discount_amount' => :'BigDecimal',
|
102
|
-
:'repeating_invoice_id' => :'String'
|
141
|
+
:'repeating_invoice_id' => :'String',
|
142
|
+
:'taxability' => :'String',
|
143
|
+
:'sales_tax_code_id' => :'Float',
|
144
|
+
:'tax_breakdown' => :'Array<TaxBreakdownComponent>'
|
103
145
|
}
|
104
146
|
end
|
105
147
|
|
@@ -179,6 +221,20 @@ module XeroRuby::Accounting
|
|
179
221
|
if attributes.key?(:'repeating_invoice_id')
|
180
222
|
self.repeating_invoice_id = attributes[:'repeating_invoice_id']
|
181
223
|
end
|
224
|
+
|
225
|
+
if attributes.key?(:'taxability')
|
226
|
+
self.taxability = attributes[:'taxability']
|
227
|
+
end
|
228
|
+
|
229
|
+
if attributes.key?(:'sales_tax_code_id')
|
230
|
+
self.sales_tax_code_id = attributes[:'sales_tax_code_id']
|
231
|
+
end
|
232
|
+
|
233
|
+
if attributes.key?(:'tax_breakdown')
|
234
|
+
if (value = attributes[:'tax_breakdown']).is_a?(Array)
|
235
|
+
self.tax_breakdown = value
|
236
|
+
end
|
237
|
+
end
|
182
238
|
end
|
183
239
|
|
184
240
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -191,9 +247,21 @@ module XeroRuby::Accounting
|
|
191
247
|
# Check to see if the all the properties in the model are valid
|
192
248
|
# @return true if the model is valid
|
193
249
|
def valid?
|
250
|
+
taxability_validator = EnumAttributeValidator.new('String', ["TAXABLE", "NON_TAXABLE", "EXEMPT", "PART_TAXABLE", "NOT_APPLICABLE"])
|
251
|
+
return false unless taxability_validator.valid?(@taxability)
|
194
252
|
true
|
195
253
|
end
|
196
254
|
|
255
|
+
# Custom attribute writer method checking allowed values (enum).
|
256
|
+
# @param [Object] taxability Object to be assigned
|
257
|
+
def taxability=(taxability)
|
258
|
+
validator = EnumAttributeValidator.new('String', ["TAXABLE", "NON_TAXABLE", "EXEMPT", "PART_TAXABLE", "NOT_APPLICABLE"])
|
259
|
+
unless validator.valid?(taxability)
|
260
|
+
fail ArgumentError, "invalid value for \"taxability\", must be one of #{validator.allowable_values}."
|
261
|
+
end
|
262
|
+
@taxability = taxability
|
263
|
+
end
|
264
|
+
|
197
265
|
# Checks equality by comparing each attribute.
|
198
266
|
# @param [Object] Object to be compared
|
199
267
|
def ==(o)
|
@@ -213,7 +281,10 @@ module XeroRuby::Accounting
|
|
213
281
|
tracking == o.tracking &&
|
214
282
|
discount_rate == o.discount_rate &&
|
215
283
|
discount_amount == o.discount_amount &&
|
216
|
-
repeating_invoice_id == o.repeating_invoice_id
|
284
|
+
repeating_invoice_id == o.repeating_invoice_id &&
|
285
|
+
taxability == o.taxability &&
|
286
|
+
sales_tax_code_id == o.sales_tax_code_id &&
|
287
|
+
tax_breakdown == o.tax_breakdown
|
217
288
|
end
|
218
289
|
|
219
290
|
# @see the `==` method
|
@@ -225,7 +296,7 @@ module XeroRuby::Accounting
|
|
225
296
|
# Calculates hash code according to all attributes.
|
226
297
|
# @return [Integer] Hash code
|
227
298
|
def hash
|
228
|
-
[line_item_id, description, quantity, unit_amount, item_code, account_code, account_id, tax_type, tax_amount, item, line_amount, tracking, discount_rate, discount_amount, repeating_invoice_id].hash
|
299
|
+
[line_item_id, description, quantity, unit_amount, item_code, account_code, account_id, tax_type, tax_amount, item, line_amount, tracking, discount_rate, discount_amount, repeating_invoice_id, taxability, sales_tax_code_id, tax_breakdown].hash
|
229
300
|
end
|
230
301
|
|
231
302
|
# Builds the object from hash
|