xero-ruby 2.8.0 → 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -38
- data/lib/xero-ruby.rb +1 -1
- data/lib/xero-ruby/api/accounting_api.rb +570 -346
- data/lib/xero-ruby/api/asset_api.rb +12 -6
- data/lib/xero-ruby/api/files_api.rb +158 -32
- data/lib/xero-ruby/api/payroll_au_api.rb +58 -29
- data/lib/xero-ruby/api/payroll_nz_api.rb +136 -68
- data/lib/xero-ruby/api/payroll_uk_api.rb +146 -82
- data/lib/xero-ruby/api/project_api.rb +26 -13
- data/lib/xero-ruby/api_client.rb +48 -8
- data/lib/xero-ruby/configuration.rb +14 -1
- data/lib/xero-ruby/models/accounting/batch_payment.rb +16 -4
- data/lib/xero-ruby/models/accounting/import_summary_accounts.rb +8 -8
- data/lib/xero-ruby/models/files/{inline_object.rb → upload_object.rb} +18 -3
- data/lib/xero-ruby/models/payroll_au/deduction_line.rb +0 -5
- data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +3 -2
- data/lib/xero-ruby/models/payroll_nz/timesheet.rb +3 -2
- data/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +3 -2
- data/lib/xero-ruby/version.rb +2 -2
- data/spec/api_client_spec.rb +95 -3
- data/spec/api_error_spec.rb +1 -1
- data/spec/configuration_spec.rb +17 -0
- data/spec/files/models/inline_object_spec.rb +3 -3
- data/spec/helper_methods_spec.rb +2 -2
- metadata +3 -3
@@ -36,6 +36,7 @@ module XeroRuby::PayrollNz
|
|
36
36
|
DRAFT = "Draft".freeze
|
37
37
|
APPROVED = "Approved".freeze
|
38
38
|
COMPLETED = "Completed".freeze
|
39
|
+
REQUESTED = "Requested".freeze
|
39
40
|
|
40
41
|
# The Total Hours of the Timesheet
|
41
42
|
attr_accessor :total_hours
|
@@ -182,7 +183,7 @@ module XeroRuby::PayrollNz
|
|
182
183
|
return false if @employee_id.nil?
|
183
184
|
return false if @start_date.nil?
|
184
185
|
return false if @end_date.nil?
|
185
|
-
status_validator = EnumAttributeValidator.new('String', ["Draft", "Approved", "Completed"])
|
186
|
+
status_validator = EnumAttributeValidator.new('String', ["Draft", "Approved", "Completed", "Requested"])
|
186
187
|
return false unless status_validator.valid?(@status)
|
187
188
|
true
|
188
189
|
end
|
@@ -190,7 +191,7 @@ module XeroRuby::PayrollNz
|
|
190
191
|
# Custom attribute writer method checking allowed values (enum).
|
191
192
|
# @param [Object] status Object to be assigned
|
192
193
|
def status=(status)
|
193
|
-
validator = EnumAttributeValidator.new('String', ["Draft", "Approved", "Completed"])
|
194
|
+
validator = EnumAttributeValidator.new('String', ["Draft", "Approved", "Completed", "Requested"])
|
194
195
|
unless validator.valid?(status)
|
195
196
|
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
196
197
|
end
|
@@ -46,6 +46,7 @@ module XeroRuby::PayrollUk
|
|
46
46
|
# The type of the payment of the corresponding salary and wages
|
47
47
|
attr_accessor :payment_type
|
48
48
|
SALARY = "Salary".freeze
|
49
|
+
HOURLY = "Hourly".freeze
|
49
50
|
|
50
51
|
class EnumAttributeValidator
|
51
52
|
attr_reader :datatype
|
@@ -193,7 +194,7 @@ module XeroRuby::PayrollUk
|
|
193
194
|
status_validator = EnumAttributeValidator.new('String', ["Active", "Pending", "History"])
|
194
195
|
return false unless status_validator.valid?(@status)
|
195
196
|
return false if @payment_type.nil?
|
196
|
-
payment_type_validator = EnumAttributeValidator.new('String', ["Salary"])
|
197
|
+
payment_type_validator = EnumAttributeValidator.new('String', ["Salary", "Hourly"])
|
197
198
|
return false unless payment_type_validator.valid?(@payment_type)
|
198
199
|
true
|
199
200
|
end
|
@@ -211,7 +212,7 @@ module XeroRuby::PayrollUk
|
|
211
212
|
# Custom attribute writer method checking allowed values (enum).
|
212
213
|
# @param [Object] payment_type Object to be assigned
|
213
214
|
def payment_type=(payment_type)
|
214
|
-
validator = EnumAttributeValidator.new('String', ["Salary"])
|
215
|
+
validator = EnumAttributeValidator.new('String', ["Salary", "Hourly"])
|
215
216
|
unless validator.valid?(payment_type)
|
216
217
|
fail ArgumentError, "invalid value for \"payment_type\", must be one of #{validator.allowable_values}."
|
217
218
|
end
|
data/lib/xero-ruby/version.rb
CHANGED
@@ -7,9 +7,9 @@ Contact: api@xero.com
|
|
7
7
|
Generated by: https://openapi-generator.tech
|
8
8
|
OpenAPI Generator version: 4.3.1
|
9
9
|
|
10
|
-
The version of the XeroOpenAPI document: 2.
|
10
|
+
The version of the XeroOpenAPI document: 2.10.5
|
11
11
|
=end
|
12
12
|
|
13
13
|
module XeroRuby
|
14
|
-
VERSION = '2.
|
14
|
+
VERSION = '2.9.1'
|
15
15
|
end
|
data/spec/api_client_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe XeroRuby::ApiClient do
|
4
4
|
context 'initialization' do
|
@@ -47,7 +47,7 @@ describe XeroRuby::ApiClient do
|
|
47
47
|
state: 'i-am-customer-state'
|
48
48
|
}
|
49
49
|
api_client = XeroRuby::ApiClient.new(credentials: creds)
|
50
|
-
expect(api_client.authorization_url).to eq('https://login.xero.com/identity/connect/authorize?response_type=code&client_id=abc&redirect_uri=https://mydomain.com/callback&scope=openid
|
50
|
+
expect(api_client.authorization_url).to eq('https://login.xero.com/identity/connect/authorize?response_type=code&client_id=abc&redirect_uri=https://mydomain.com/callback&scope=openid+profile+email+accounting.transactions+accounting.settings&state=i-am-customer-state')
|
51
51
|
end
|
52
52
|
|
53
53
|
it "Does not append state if it is not provided" do
|
@@ -58,7 +58,7 @@ describe XeroRuby::ApiClient do
|
|
58
58
|
scopes: 'openid profile email accounting.transactions accounting.settings'
|
59
59
|
}
|
60
60
|
api_client = XeroRuby::ApiClient.new(credentials: creds)
|
61
|
-
expect(api_client.authorization_url).to eq('https://login.xero.com/identity/connect/authorize?response_type=code&client_id=abc&redirect_uri=https://mydomain.com/callback&scope=openid
|
61
|
+
expect(api_client.authorization_url).to eq('https://login.xero.com/identity/connect/authorize?response_type=code&client_id=abc&redirect_uri=https://mydomain.com/callback&scope=openid+profile+email+accounting.transactions+accounting.settings')
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -137,6 +137,17 @@ describe XeroRuby::ApiClient do
|
|
137
137
|
api_client.connections
|
138
138
|
expect(api_client.config.base_url).to eq('https://api.xero.com')
|
139
139
|
end
|
140
|
+
|
141
|
+
it "does not mutate the original opts hash" do
|
142
|
+
expect(api_client).to receive(:call_api).and_return('')
|
143
|
+
opts = {
|
144
|
+
where: {
|
145
|
+
invoice_number: ['=', "INV-0060"]
|
146
|
+
}
|
147
|
+
}
|
148
|
+
api_client.accounting_api.get_invoices('active_tenant_id', opts)
|
149
|
+
expect(opts).to eq({:where=>{:invoice_number=>["=", "INV-0060"]}})
|
150
|
+
end
|
140
151
|
end
|
141
152
|
|
142
153
|
describe '#deserialize' do
|
@@ -360,4 +371,85 @@ describe XeroRuby::ApiClient do
|
|
360
371
|
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
361
372
|
end
|
362
373
|
end
|
374
|
+
|
375
|
+
describe 'thread safety in the XeroClient' do
|
376
|
+
let(:creds) {{
|
377
|
+
client_id: 'abc',
|
378
|
+
client_secret: '123',
|
379
|
+
redirect_uri: 'https://mydomain.com/callback',
|
380
|
+
scopes: 'openid profile email accounting.transactions'
|
381
|
+
}}
|
382
|
+
let(:api_client_1) {XeroRuby::ApiClient.new(credentials: creds)}
|
383
|
+
let(:api_client_2) {XeroRuby::ApiClient.new(credentials: creds)}
|
384
|
+
let(:api_client_3) {XeroRuby::ApiClient.new(credentials: creds)}
|
385
|
+
|
386
|
+
let(:tkn_set_1){{id_token: "abc.123.1", access_token: "xxx.yyy.zzz.111"}}
|
387
|
+
let(:tkn_set_2){{id_token: "efg.456.2", access_token: "xxx.yyy.zzz.222"}}
|
388
|
+
|
389
|
+
describe 'when configuration is changed, other instantiations of the client are not affected' do
|
390
|
+
it 'applies to #set_access_token' do
|
391
|
+
expect(api_client_1.access_token).to eq(nil)
|
392
|
+
expect(api_client_2.access_token).to eq(nil)
|
393
|
+
expect(api_client_3.access_token).to eq(nil)
|
394
|
+
|
395
|
+
api_client_1.set_access_token("ACCESS_TOKEN_1")
|
396
|
+
expect(api_client_1.access_token).to eq("ACCESS_TOKEN_1")
|
397
|
+
expect(api_client_2.access_token).to eq(nil)
|
398
|
+
expect(api_client_3.access_token).to eq(nil)
|
399
|
+
|
400
|
+
api_client_2.set_access_token("ACCESS_TOKEN_2")
|
401
|
+
expect(api_client_1.access_token).to eq("ACCESS_TOKEN_1")
|
402
|
+
expect(api_client_2.access_token).to eq("ACCESS_TOKEN_2")
|
403
|
+
expect(api_client_3.access_token).to eq(nil)
|
404
|
+
|
405
|
+
api_client_3.set_access_token("ACCESS_TOKEN_3")
|
406
|
+
expect(api_client_1.access_token).to eq("ACCESS_TOKEN_1")
|
407
|
+
expect(api_client_2.access_token).to eq("ACCESS_TOKEN_2")
|
408
|
+
expect(api_client_3.access_token).to eq("ACCESS_TOKEN_3")
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'applies to #set_id_token' do
|
412
|
+
expect(api_client_1.id_token).to eq(nil)
|
413
|
+
expect(api_client_2.id_token).to eq(nil)
|
414
|
+
|
415
|
+
api_client_1.set_id_token("id_token_1")
|
416
|
+
expect(api_client_1.id_token).to eq("id_token_1")
|
417
|
+
expect(api_client_2.id_token).to eq(nil)
|
418
|
+
|
419
|
+
api_client_2.set_id_token("id_token_2")
|
420
|
+
expect(api_client_1.id_token).to eq("id_token_1")
|
421
|
+
expect(api_client_2.id_token).to eq("id_token_2")
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'applies to #set_token_set' do
|
425
|
+
expect(api_client_1.token_set).to eq(nil)
|
426
|
+
expect(api_client_2.token_set).to eq(nil)
|
427
|
+
|
428
|
+
api_client_1.set_token_set(tkn_set_1)
|
429
|
+
expect(api_client_1.token_set).to eq(tkn_set_1)
|
430
|
+
expect(api_client_2.token_set).to eq(nil)
|
431
|
+
|
432
|
+
api_client_2.set_token_set(tkn_set_2)
|
433
|
+
expect(api_client_1.token_set).to eq(tkn_set_1)
|
434
|
+
expect(api_client_2.token_set).to eq(tkn_set_2)
|
435
|
+
end
|
436
|
+
|
437
|
+
it 'applies to #base_url' do
|
438
|
+
expect(api_client_1.config.base_url).to eq(nil)
|
439
|
+
expect(api_client_2.config.base_url).to eq(nil)
|
440
|
+
|
441
|
+
api_client_1.accounting_api
|
442
|
+
expect(api_client_1.config.base_url).to eq(api_client_1.config.accounting_url)
|
443
|
+
expect(api_client_2.config.base_url).to eq(nil)
|
444
|
+
|
445
|
+
api_client_2.files_api
|
446
|
+
expect(api_client_1.config.base_url).to eq(api_client_1.config.accounting_url)
|
447
|
+
expect(api_client_2.config.base_url).to eq(api_client_1.config.files_url)
|
448
|
+
|
449
|
+
api_client_2.project_api
|
450
|
+
expect(api_client_1.config.base_url).to eq(api_client_1.config.accounting_url)
|
451
|
+
expect(api_client_2.config.base_url).to eq(api_client_1.config.project_url)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
363
455
|
end
|
data/spec/api_error_spec.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -16,4 +16,21 @@ describe XeroRuby::Configuration do
|
|
16
16
|
expect(config.payroll_uk_url).to eq('https://api.xero.com/payroll.xro/2.0/')
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
describe 'config' do
|
21
|
+
it 'should apply the default configuration options' do
|
22
|
+
client = XeroRuby::ApiClient.new(credentials: {})
|
23
|
+
expect(client.config.login_url).to eq('https://login.xero.com/identity/connect/authorize')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should allow you to overwrite the default configuration options' do
|
27
|
+
client = XeroRuby::ApiClient.new(credentials: {}, config: {login_url: 'ngrok.login.xero.test'})
|
28
|
+
expect(client.config.login_url).to eq('ngrok.login.xero.test')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should allow you to set the timeout config option' do
|
32
|
+
client = XeroRuby::ApiClient.new(credentials: {}, config: {timeout: 30})
|
33
|
+
expect(client.config.timeout).to eq(30)
|
34
|
+
end
|
35
|
+
end
|
19
36
|
end
|
@@ -14,13 +14,13 @@ require 'spec_helper'
|
|
14
14
|
require 'json'
|
15
15
|
require 'date'
|
16
16
|
|
17
|
-
# Unit tests for XeroRuby::Files::
|
17
|
+
# Unit tests for XeroRuby::Files::FileObject
|
18
18
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
19
19
|
# Please update as you see appropriate
|
20
20
|
describe 'InlineObject' do
|
21
21
|
before do
|
22
22
|
# run before each test
|
23
|
-
@instance = XeroRuby::Files::
|
23
|
+
@instance = XeroRuby::Files::FileObject.new
|
24
24
|
end
|
25
25
|
|
26
26
|
after do
|
@@ -29,7 +29,7 @@ describe 'InlineObject' do
|
|
29
29
|
|
30
30
|
describe 'test an instance of InlineObject' do
|
31
31
|
it 'should create an instance of InlineObject' do
|
32
|
-
expect(@instance).to be_instance_of(XeroRuby::Files::
|
32
|
+
expect(@instance).to be_instance_of(XeroRuby::Files::FileObject)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
describe 'test attribute "body"' do
|
data/spec/helper_methods_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xero-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xero API Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -232,9 +232,9 @@ files:
|
|
232
232
|
- lib/xero-ruby/models/files/files.rb
|
233
233
|
- lib/xero-ruby/models/files/folder.rb
|
234
234
|
- lib/xero-ruby/models/files/folders.rb
|
235
|
-
- lib/xero-ruby/models/files/inline_object.rb
|
236
235
|
- lib/xero-ruby/models/files/object_group.rb
|
237
236
|
- lib/xero-ruby/models/files/object_type.rb
|
237
|
+
- lib/xero-ruby/models/files/upload_object.rb
|
238
238
|
- lib/xero-ruby/models/files/user.rb
|
239
239
|
- lib/xero-ruby/models/payroll_au/account.rb
|
240
240
|
- lib/xero-ruby/models/payroll_au/account_type.rb
|