xero-ruby 2.8.0 → 2.10.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.
- checksums.yaml +4 -4
- data/README.md +158 -117
- data/lib/xero-ruby.rb +1 -1
- data/lib/xero-ruby/api/accounting_api.rb +573 -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 +96 -14
- 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/models/projects/time_entry.rb +3 -2
- data/lib/xero-ruby/version.rb +2 -2
- data/spec/api_client_spec.rb +174 -7
- 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 +23 -3
@@ -97,10 +97,6 @@ module XeroRuby::PayrollAu
|
|
97
97
|
invalid_properties.push('invalid value for "deduction_type_id", deduction_type_id cannot be nil.')
|
98
98
|
end
|
99
99
|
|
100
|
-
if @calculation_type.nil?
|
101
|
-
invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.')
|
102
|
-
end
|
103
|
-
|
104
100
|
invalid_properties
|
105
101
|
end
|
106
102
|
|
@@ -108,7 +104,6 @@ module XeroRuby::PayrollAu
|
|
108
104
|
# @return true if the model is valid
|
109
105
|
def valid?
|
110
106
|
return false if @deduction_type_id.nil?
|
111
|
-
return false if @calculation_type.nil?
|
112
107
|
true
|
113
108
|
end
|
114
109
|
|
@@ -44,6 +44,7 @@ module XeroRuby::PayrollNz
|
|
44
44
|
attr_accessor :status
|
45
45
|
ACTIVE = "Active".freeze
|
46
46
|
PENDING = "Pending".freeze
|
47
|
+
HISTORY = "History".freeze
|
47
48
|
|
48
49
|
# The type of the payment of the corresponding salary and wages
|
49
50
|
attr_accessor :payment_type
|
@@ -204,7 +205,7 @@ module XeroRuby::PayrollNz
|
|
204
205
|
return false if @effective_from.nil?
|
205
206
|
return false if @annual_salary.nil?
|
206
207
|
return false if @status.nil?
|
207
|
-
status_validator = EnumAttributeValidator.new('String', ["Active", "Pending"])
|
208
|
+
status_validator = EnumAttributeValidator.new('String', ["Active", "Pending", "History"])
|
208
209
|
return false unless status_validator.valid?(@status)
|
209
210
|
return false if @payment_type.nil?
|
210
211
|
payment_type_validator = EnumAttributeValidator.new('String', ["Salary", "Hourly"])
|
@@ -215,7 +216,7 @@ module XeroRuby::PayrollNz
|
|
215
216
|
# Custom attribute writer method checking allowed values (enum).
|
216
217
|
# @param [Object] status Object to be assigned
|
217
218
|
def status=(status)
|
218
|
-
validator = EnumAttributeValidator.new('String', ["Active", "Pending"])
|
219
|
+
validator = EnumAttributeValidator.new('String', ["Active", "Pending", "History"])
|
219
220
|
unless validator.valid?(status)
|
220
221
|
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
221
222
|
end
|
@@ -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
|
@@ -44,6 +44,7 @@ module XeroRuby::Projects
|
|
44
44
|
attr_accessor :status
|
45
45
|
ACTIVE = "ACTIVE".freeze
|
46
46
|
LOCKED = "LOCKED".freeze
|
47
|
+
INVOICED = "INVOICED".freeze
|
47
48
|
|
48
49
|
class EnumAttributeValidator
|
49
50
|
attr_reader :datatype
|
@@ -159,7 +160,7 @@ module XeroRuby::Projects
|
|
159
160
|
# Check to see if the all the properties in the model are valid
|
160
161
|
# @return true if the model is valid
|
161
162
|
def valid?
|
162
|
-
status_validator = EnumAttributeValidator.new('String', ["ACTIVE", "LOCKED"])
|
163
|
+
status_validator = EnumAttributeValidator.new('String', ["ACTIVE", "LOCKED", "INVOICED"])
|
163
164
|
return false unless status_validator.valid?(@status)
|
164
165
|
true
|
165
166
|
end
|
@@ -167,7 +168,7 @@ module XeroRuby::Projects
|
|
167
168
|
# Custom attribute writer method checking allowed values (enum).
|
168
169
|
# @param [Object] status Object to be assigned
|
169
170
|
def status=(status)
|
170
|
-
validator = EnumAttributeValidator.new('String', ["ACTIVE", "LOCKED"])
|
171
|
+
validator = EnumAttributeValidator.new('String', ["ACTIVE", "LOCKED", "INVOICED"])
|
171
172
|
unless validator.valid?(status)
|
172
173
|
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
173
174
|
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.11.0
|
11
11
|
=end
|
12
12
|
|
13
13
|
module XeroRuby
|
14
|
-
VERSION = '2.
|
14
|
+
VERSION = '2.10.0'
|
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,20 @@ 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
|
+
end
|
63
|
+
|
64
|
+
it "Validates state on callback matches @config.state" do
|
65
|
+
creds = {
|
66
|
+
client_id: 'abc',
|
67
|
+
client_secret: '123',
|
68
|
+
redirect_uri: 'https://mydomain.com/callback',
|
69
|
+
scopes: 'openid profile email accounting.transactions accounting.settings',
|
70
|
+
state: "custom-state"
|
71
|
+
}
|
72
|
+
api_client = XeroRuby::ApiClient.new(credentials: creds)
|
73
|
+
altered_state = {'state': 'not-original-state'}
|
74
|
+
expect{api_client.validate_state(altered_state)}.to raise_error(StandardError, 'WARNING: @config.state: custom-state and OAuth callback state: do not match!')
|
62
75
|
end
|
63
76
|
end
|
64
77
|
end
|
@@ -66,7 +79,7 @@ describe XeroRuby::ApiClient do
|
|
66
79
|
|
67
80
|
describe 'api_client helper functions' do
|
68
81
|
let(:api_client) { XeroRuby::ApiClient.new }
|
69
|
-
let(:token_set) { {access_token: 'eyx.
|
82
|
+
let(:token_set) { {'access_token': 'eyx.authorization.data', 'id_token': 'eyx.authentication.data', 'refresh_token': 'REFRESHMENTS'} }
|
70
83
|
let(:connections) {
|
71
84
|
[{
|
72
85
|
"id" => "xxx-yyy-zzz",
|
@@ -84,12 +97,17 @@ describe XeroRuby::ApiClient do
|
|
84
97
|
|
85
98
|
it "#set_token_set" do
|
86
99
|
api_client.set_token_set(token_set)
|
87
|
-
expect(api_client.token_set).to eq(token_set)
|
100
|
+
expect(api_client.token_set).to eq(token_set.with_indifferent_access)
|
88
101
|
end
|
89
102
|
|
90
103
|
it "#set_access_token" do
|
91
|
-
api_client.set_access_token(token_set[
|
92
|
-
expect(api_client.access_token).to eq(token_set[
|
104
|
+
api_client.set_access_token(token_set['access_token'])
|
105
|
+
expect(api_client.access_token).to eq(token_set['access_token'])
|
106
|
+
end
|
107
|
+
|
108
|
+
it "#set_id_token" do
|
109
|
+
api_client.set_id_token(token_set['id_token'])
|
110
|
+
expect(api_client.id_token).to eq(token_set['id_token'])
|
93
111
|
end
|
94
112
|
|
95
113
|
it "#refresh_token_set" do
|
@@ -137,6 +155,17 @@ describe XeroRuby::ApiClient do
|
|
137
155
|
api_client.connections
|
138
156
|
expect(api_client.config.base_url).to eq('https://api.xero.com')
|
139
157
|
end
|
158
|
+
|
159
|
+
it "does not mutate the original opts hash" do
|
160
|
+
expect(api_client).to receive(:call_api).and_return('')
|
161
|
+
opts = {
|
162
|
+
where: {
|
163
|
+
invoice_number: ['=', "INV-0060"]
|
164
|
+
}
|
165
|
+
}
|
166
|
+
api_client.accounting_api.get_invoices('active_tenant_id', opts)
|
167
|
+
expect(opts).to eq({:where=>{:invoice_number=>["=", "INV-0060"]}})
|
168
|
+
end
|
140
169
|
end
|
141
170
|
|
142
171
|
describe '#deserialize' do
|
@@ -360,4 +389,142 @@ describe XeroRuby::ApiClient do
|
|
360
389
|
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
361
390
|
end
|
362
391
|
end
|
392
|
+
|
393
|
+
describe 'token helper methods' do
|
394
|
+
let(:api_client) { XeroRuby::ApiClient.new }
|
395
|
+
let(:id_token){'eyJhbGciOiJSUzI1NiIsImtpZCI6IjFDQUY4RTY2NzcyRDZEQzAyOEQ2NzI2RkQwMjYxNTgxNTcwRUZDMTkiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJISy1PWm5jdGJjQW8xbkp2MENZVmdWY09fQmsifQ.eyJuYmYiOjE2MTk3MTQwNDMsImV4cCI6MTYxOTcxNDM0MywiaXNzIjoiaHR0cHM6Ly9pZGVudGl0eS54ZXJvLmNvbSIsImF1ZCI6IkFEQjVBNzdEQTZCNjRFOTI4RDg0MDkwOTlBMzlDQTdCIiwiaWF0IjoxNjE5NzE0MDQzLCJhdF9oYXNoIjoiMXJNamVvUTJiOUxUNFU0ZlBXbEZJZyIsInNpZCI6ImY0YTY4ZDc0ZmM3OTQzMjc4YTgzMTg0NGM5ZWRmNzFiIiwic3ViIjoiZGI0ZjBmMzdiNTg1NTMwZTkxZjNiOWNiYjUwMzQwZTgiLCJhdXRoX3RpbWUiOjE2MTk3MTM5ODcsInhlcm9fdXNlcmlkIjoiZmFhODNlYzktZjZhNy00ODlmLTg5MTEtZTNmY2UwM2ExMTg2IiwiZ2xvYmFsX3Nlc3Npb25faWQiOiJmNGE2OGQ3NGZjNzk0MzI3OGE4MzE4NDRjOWVkZjcxYiIsInByZWZlcnJlZF91c2VybmFtZSI6ImNocmlzLmtuaWdodEB4ZXJvLmNvbSIsImVtYWlsIjoiY2hyaXMua25pZ2h0QHhlcm8uY29tIiwiZ2l2ZW5fbmFtZSI6IkNocmlzdG9waGVyIiwiZmFtaWx5X25hbWUiOiJLbmlnaHQifQ.hF04tCE1Qd-al355fQyCjWqTVWKnguor4RD1sC7rKH7zV3r3_nGwnGLMm2A96fov06fig0zusTX8onev0qFLZy-jlEXDp1f19LHhT15sBy0KH6dB0lGMrM14BnDuEP4NUGeP06nAPhQHHLw2oCc9hzYXorRVOSFDw43jgAC0vxRgDvJwgKgv6TDVEmpvwP0S4R7A0VbnFemHP_HY8gLHd7RpN7rrYmpJC4cofztdptDNLTF8Qup8qVlFdQgpJPQEQ95N1m6W-unvrh_dlO6AVMjXBjC1BJ10IGzoCCr8DSVyz2UMPnUT3oIYFVTlDc2K-ZJYkW86pigITMCdvR1hKg'}
|
396
|
+
let(:access_token){'eyJhbGciOiJSUzI1NiIsImtpZCI6IjFDQUY4RTY2NzcyRDZEQzAyOEQ2NzI2RkQwMjYxNTgxNTcwRUZDMTkiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJISy1PWm5jdGJjQW8xbkp2MENZVmdWY09fQmsifQ.eyJuYmYiOjE2MTk3MTQwNDMsImV4cCI6MTYxOTcxNTg0MywiaXNzIjoiaHR0cHM6Ly9pZGVudGl0eS54ZXJvLmNvbSIsImF1ZCI6Imh0dHBzOi8vaWRlbnRpdHkueGVyby5jb20vcmVzb3VyY2VzIiwiY2xpZW50X2lkIjoiQURCNUE3N0RBNkI2NEU5MjhEODQwOTA5OUEzOUNBN0IiLCJzdWIiOiJkYjRmMGYzN2I1ODU1MzBlOTFmM2I5Y2JiNTAzNDBlOCIsImF1dGhfdGltZSI6MTYxOTcxMzk4NywieGVyb191c2VyaWQiOiJmYWE4M2VjOS1mNmE3LTQ4OWYtODkxMS1lM2ZjZTAzYTExODYiLCJnbG9iYWxfc2Vzc2lvbl9pZCI6ImY0YTY4ZDc0ZmM3OTQzMjc4YTgzMTg0NGM5ZWRmNzFiIiwianRpIjoiZmFmNGNkYzQ5MjM0YzhmZDE0OTA0ZjRlOWEyMWY4YmYiLCJhdXRoZW50aWNhdGlvbl9ldmVudF9pZCI6IjI0MmRjNWIyLTIwZTMtNGFjNS05NjU3LWExMGI5ZTI0ZGI1NSIsInNjb3BlIjpbImVtYWlsIiwicHJvZmlsZSIsIm9wZW5pZCIsImFjY291bnRpbmcucmVwb3J0cy5yZWFkIiwiZmlsZXMiLCJwYXlyb2xsLmVtcGxveWVlcyIsInBheXJvbGwucGF5cnVucyIsInBheXJvbGwucGF5c2xpcCIsInBheXJvbGwudGltZXNoZWV0cyIsInByb2plY3RzLnJlYWQiLCJwcm9qZWN0cyIsImFjY291bnRpbmcuc2V0dGluZ3MiLCJhY2NvdW50aW5nLmF0dGFjaG1lbnRzIiwiYWNjb3VudGluZy50cmFuc2FjdGlvbnMiLCJhY2NvdW50aW5nLmpvdXJuYWxzLnJlYWQiLCJhc3NldHMucmVhZCIsImFzc2V0cyIsImFjY291bnRpbmcuY29udGFjdHMiLCJwYXlyb2xsLnNldHRpbmdzIiwib2ZmbGluZV9hY2Nlc3MiXX0.vNV-YsgHFWKFBmyYdhg7tztdsPc9ykObadQcGFoFXJ8qCBerR3h7XXKzWAP3KzFzhOCcIpWU8Q081zuYBNxahPeeLRLUuc_3MwgwE72esE5vGuxa2_-_QidtNvMCgsX-ie_LcX7FE_KI-sXB_EZ8fDk6WAMIPC9d3GejgeuH5Uh6rZkhowN2jm5pZjEOEy_QE7PScBO0XEbiZNUsarvBUSdKuSTvVVLHzHzs0bHMRfgKEkqZySNtZlac-oyaL3PVba1S7A_vbRcNWpYR_VrKGf2g9LHSI3EA5j3Beto4pKukU-bk6rLBGul37u4tM17U-wyJLsFmt6ZC_SEJKgmluQ'}
|
397
|
+
let(:tkn_set) {{'id_token': id_token, 'access_token': access_token, 'refresh_token': 'abc123xyz'}}
|
398
|
+
|
399
|
+
before do
|
400
|
+
api_client.set_token_set(tkn_set)
|
401
|
+
end
|
402
|
+
|
403
|
+
it '#token_expired? for an expired token' do
|
404
|
+
expect(api_client.token_expired?).to eq(true)
|
405
|
+
end
|
406
|
+
|
407
|
+
it '#token_expired? for a just expired token' do
|
408
|
+
allow(api_client).to receive(:decoded_access_token).and_return({"exp"=>Time.now.to_i})
|
409
|
+
expect(api_client.token_expired?).to eq(true)
|
410
|
+
end
|
411
|
+
|
412
|
+
it '#token_expired? for a non-expired token' do
|
413
|
+
allow(api_client).to receive(:decoded_access_token).and_return({"exp"=>(Time.now + 30.minutes).to_i})
|
414
|
+
expect(api_client.token_expired?).to eq(false)
|
415
|
+
end
|
416
|
+
|
417
|
+
it '#token_expired? for an almost expired token' do
|
418
|
+
allow(api_client).to receive(:decoded_access_token).and_return({"exp"=>(Time.now + 30.seconds).to_i})
|
419
|
+
expect(api_client.token_expired?).to eq(false)
|
420
|
+
end
|
421
|
+
|
422
|
+
it '#validate_tokens' do
|
423
|
+
expect(api_client.validate_tokens(tkn_set)).to eq(true)
|
424
|
+
end
|
425
|
+
it '#access_token' do
|
426
|
+
expect(api_client.access_token).to eq(access_token)
|
427
|
+
end
|
428
|
+
it '#decoded_access_token' do
|
429
|
+
expect(api_client.decoded_access_token['aud']).to eq("https://identity.xero.com/resources")
|
430
|
+
end
|
431
|
+
it '#id_token' do
|
432
|
+
expect(api_client.id_token).to eq(tkn_set[:id_token])
|
433
|
+
end
|
434
|
+
it '#decoded_id_token' do
|
435
|
+
expect(api_client.decoded_id_token['email']).to eq('chris.knight@xero.com')
|
436
|
+
end
|
437
|
+
|
438
|
+
it 'decoding an invalid access_token' do
|
439
|
+
api_client.set_access_token("#{access_token}.NotAValidJWTstring")
|
440
|
+
expect{api_client.decoded_access_token}.to raise_error(JSON::JWT::InvalidFormat)
|
441
|
+
end
|
442
|
+
|
443
|
+
it 'decoding an invalid id_token' do
|
444
|
+
api_client.set_id_token("#{id_token}.NotAValidJWTstring")
|
445
|
+
expect{api_client.decoded_id_token}.to raise_error(JSON::JWT::InvalidFormat)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
|
450
|
+
describe 'thread safety in the XeroClient' do
|
451
|
+
let(:creds) {{
|
452
|
+
client_id: 'abc',
|
453
|
+
client_secret: '123',
|
454
|
+
redirect_uri: 'https://mydomain.com/callback',
|
455
|
+
scopes: 'openid profile email accounting.transactions'
|
456
|
+
}}
|
457
|
+
let(:api_client_1) {XeroRuby::ApiClient.new(credentials: creds)}
|
458
|
+
let(:api_client_2) {XeroRuby::ApiClient.new(credentials: creds)}
|
459
|
+
let(:api_client_3) {XeroRuby::ApiClient.new(credentials: creds)}
|
460
|
+
|
461
|
+
let(:tkn_set_1){{'id_token': "abc.123.1", 'access_token': "xxx.yyy.zzz.111"}}
|
462
|
+
let(:tkn_set_2){{'id_token': "efg.456.2", 'access_token': "xxx.yyy.zzz.222"}}
|
463
|
+
|
464
|
+
describe 'when configuration is changed, other instantiations of the client are not affected' do
|
465
|
+
it 'applies to #set_access_token' do
|
466
|
+
expect(api_client_1.access_token).to eq(nil)
|
467
|
+
expect(api_client_2.access_token).to eq(nil)
|
468
|
+
expect(api_client_3.access_token).to eq(nil)
|
469
|
+
|
470
|
+
api_client_1.set_access_token("ACCESS_TOKEN_1")
|
471
|
+
expect(api_client_1.access_token).to eq("ACCESS_TOKEN_1")
|
472
|
+
expect(api_client_2.access_token).to eq(nil)
|
473
|
+
expect(api_client_3.access_token).to eq(nil)
|
474
|
+
|
475
|
+
api_client_2.set_access_token("ACCESS_TOKEN_2")
|
476
|
+
expect(api_client_1.access_token).to eq("ACCESS_TOKEN_1")
|
477
|
+
expect(api_client_2.access_token).to eq("ACCESS_TOKEN_2")
|
478
|
+
expect(api_client_3.access_token).to eq(nil)
|
479
|
+
|
480
|
+
api_client_3.set_access_token("ACCESS_TOKEN_3")
|
481
|
+
expect(api_client_1.access_token).to eq("ACCESS_TOKEN_1")
|
482
|
+
expect(api_client_2.access_token).to eq("ACCESS_TOKEN_2")
|
483
|
+
expect(api_client_3.access_token).to eq("ACCESS_TOKEN_3")
|
484
|
+
end
|
485
|
+
|
486
|
+
it 'applies to #set_id_token' do
|
487
|
+
expect(api_client_1.id_token).to eq(nil)
|
488
|
+
expect(api_client_2.id_token).to eq(nil)
|
489
|
+
|
490
|
+
api_client_1.set_id_token("id_token_1")
|
491
|
+
expect(api_client_1.id_token).to eq("id_token_1")
|
492
|
+
expect(api_client_2.id_token).to eq(nil)
|
493
|
+
|
494
|
+
api_client_2.set_id_token("id_token_2")
|
495
|
+
expect(api_client_1.id_token).to eq("id_token_1")
|
496
|
+
expect(api_client_2.id_token).to eq("id_token_2")
|
497
|
+
end
|
498
|
+
|
499
|
+
it 'applies to #set_token_set' do
|
500
|
+
expect(api_client_1.token_set).to eq(nil)
|
501
|
+
expect(api_client_2.token_set).to eq(nil)
|
502
|
+
|
503
|
+
api_client_1.set_token_set(tkn_set_1)
|
504
|
+
expect(api_client_1.token_set).to eq(tkn_set_1.with_indifferent_access)
|
505
|
+
expect(api_client_2.token_set).to eq(nil)
|
506
|
+
|
507
|
+
api_client_2.set_token_set(tkn_set_2)
|
508
|
+
expect(api_client_1.token_set).to eq(tkn_set_1.with_indifferent_access)
|
509
|
+
expect(api_client_2.token_set).to eq(tkn_set_2.with_indifferent_access)
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'applies to #base_url' do
|
513
|
+
expect(api_client_1.config.base_url).to eq(nil)
|
514
|
+
expect(api_client_2.config.base_url).to eq(nil)
|
515
|
+
|
516
|
+
api_client_1.accounting_api
|
517
|
+
expect(api_client_1.config.base_url).to eq(api_client_1.config.accounting_url)
|
518
|
+
expect(api_client_2.config.base_url).to eq(nil)
|
519
|
+
|
520
|
+
api_client_2.files_api
|
521
|
+
expect(api_client_1.config.base_url).to eq(api_client_1.config.accounting_url)
|
522
|
+
expect(api_client_2.config.base_url).to eq(api_client_1.config.files_url)
|
523
|
+
|
524
|
+
api_client_2.project_api
|
525
|
+
expect(api_client_1.config.base_url).to eq(api_client_1.config.accounting_url)
|
526
|
+
expect(api_client_2.config.base_url).to eq(api_client_1.config.project_url)
|
527
|
+
end
|
528
|
+
end
|
529
|
+
end
|
363
530
|
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.10.0
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -50,6 +50,26 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 2.1.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: json-jwt
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.5'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.5.2
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.5'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.5.2
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: rspec
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,9 +252,9 @@ files:
|
|
232
252
|
- lib/xero-ruby/models/files/files.rb
|
233
253
|
- lib/xero-ruby/models/files/folder.rb
|
234
254
|
- lib/xero-ruby/models/files/folders.rb
|
235
|
-
- lib/xero-ruby/models/files/inline_object.rb
|
236
255
|
- lib/xero-ruby/models/files/object_group.rb
|
237
256
|
- lib/xero-ruby/models/files/object_type.rb
|
257
|
+
- lib/xero-ruby/models/files/upload_object.rb
|
238
258
|
- lib/xero-ruby/models/files/user.rb
|
239
259
|
- lib/xero-ruby/models/payroll_au/account.rb
|
240
260
|
- lib/xero-ruby/models/payroll_au/account_type.rb
|