xero-ruby 9.2.0 → 9.3.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,8 +70,8 @@ describe XeroRuby::ApiClient do
70
70
  state: "custom-state"
71
71
  }
72
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!')
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!')
75
75
  end
76
76
  end
77
77
 
@@ -102,16 +102,16 @@ describe XeroRuby::ApiClient do
102
102
 
103
103
  describe 'api_client helper functions' do
104
104
  let(:api_client) { XeroRuby::ApiClient.new }
105
- let(:token_set) { {'access_token': 'eyx.authorization.data', 'id_token': 'eyx.authentication.data', 'refresh_token': 'REFRESHMENTS'} }
105
+ let(:token_set) { { 'access_token': 'eyx.authorization.data', 'id_token': 'eyx.authentication.data', 'refresh_token': 'REFRESHMENTS' } }
106
106
  let(:connections) {
107
- [{
108
- "id" => "xxx-yyy-zzz",
109
- "tenantId" => "xxx-yyy-zzz",
110
- "tenantType" => "ORGANISATION",
111
- "tenantName" => "Demo Company (US)",
112
- "createdDateUtc" => "2019-11-01T20:08:03.0766400",
113
- "updatedDateUtc" => "2020-04-15T22:37:10.4943410"
114
- }]
107
+ [{
108
+ "id" => "xxx-yyy-zzz",
109
+ "tenantId" => "xxx-yyy-zzz",
110
+ "tenantType" => "ORGANISATION",
111
+ "tenantName" => "Demo Company (US)",
112
+ "createdDateUtc" => "2019-11-01T20:08:03.0766400",
113
+ "updatedDateUtc" => "2020-04-15T22:37:10.4943410"
114
+ }]
115
115
  }
116
116
 
117
117
  before do
@@ -190,7 +190,7 @@ describe XeroRuby::ApiClient do
190
190
  }
191
191
  }
192
192
  api_client.accounting_api.get_invoices('active_tenant_id', opts)
193
- expect(opts).to eq({:where=>{:invoice_number=>["=", "INV-0060"]}})
193
+ expect(opts).to eq({ :where => { :invoice_number => ["=", "INV-0060"] } })
194
194
  end
195
195
  end
196
196
 
@@ -224,10 +224,10 @@ describe XeroRuby::ApiClient do
224
224
  end
225
225
 
226
226
  describe "#object_to_hash modifies a hash from snake_case to PascalCase" do
227
- contact_after = {:Contacts=>[{:Name=>"Bruce Banner", :EmailAddress=>"hulk@avengers.com", :Phones=>[{:PhoneType=>"MOBILE", :PhoneNumber=>"555-1212", :PhoneAreaCode=>"415"}], :PaymentTerms=>{:Bills=>{:Day=>15, :Type=>"OFCURRENTMONTH"}, :Sales=>{:Day=>10, :Type=>"DAYSAFTERBILLMONTH"}}}]}
227
+ contact_after = { :Contacts => [{ :Name => "Bruce Banner", :EmailAddress => "hulk@avengers.com", :Phones => [{ :PhoneType => "MOBILE", :PhoneNumber => "555-1212", :PhoneAreaCode => "415" }], :PaymentTerms => { :Bills => { :Day => 15, :Type => "OFCURRENTMONTH" }, :Sales => { :Day => 10, :Type => "DAYSAFTERBILLMONTH" } } }] }
228
228
 
229
229
  it 'Serializes snake_case object correctly' do
230
- contact_before = {:contacts=>[{:name=>"Bruce Banner", :email_address=>"hulk@avengers.com", :phones=>[{:phone_type=>"MOBILE", :phone_number=>"555-1212", :phone_area_code=>"415"}], :payment_terms=>{:bills=>{:day=>15, :type=>"OFCURRENTMONTH"}, :sales=>{:day=>10, :type=>"DAYSAFTERBILLMONTH"}}}]}
230
+ contact_before = { :contacts => [{ :name => "Bruce Banner", :email_address => "hulk@avengers.com", :phones => [{ :phone_type => "MOBILE", :phone_number => "555-1212", :phone_area_code => "415" }], :payment_terms => { :bills => { :day => 15, :type => "OFCURRENTMONTH" }, :sales => { :day => 10, :type => "DAYSAFTERBILLMONTH" } } }] }
231
231
  api_client = XeroRuby::ApiClient.new
232
232
  expect(api_client.object_to_hash(contact_before)).to eq(contact_after)
233
233
  end
@@ -255,26 +255,26 @@ describe XeroRuby::ApiClient do
255
255
 
256
256
  it 'Serializes json with multiple nested objects correctly' do
257
257
  json_before = {
258
- "line_Items":[
258
+ "line_Items": [
259
259
  {
260
- "quantity":1.0,
261
- "unit_amount":20,
262
- "sub_Items":[
260
+ "quantity": 1.0,
261
+ "unit_amount": 20,
262
+ "sub_Items": [
263
263
  {
264
- "quantity":1.0,
265
- "unit_amount":20
264
+ "quantity": 1.0,
265
+ "unit_amount": 20
266
266
  },
267
267
  {
268
- "quantity":1.0,
269
- "Unit_amount":20,
270
- "Deep_Items":[
268
+ "quantity": 1.0,
269
+ "Unit_amount": 20,
270
+ "Deep_Items": [
271
271
  {
272
- "quantity":1.0,
273
- "unit_amount":20
272
+ "quantity": 1.0,
273
+ "unit_amount": 20
274
274
  },
275
275
  {
276
- "quantity":1.0,
277
- "unit_Amount":20
276
+ "quantity": 1.0,
277
+ "unit_Amount": 20
278
278
  }
279
279
  ]
280
280
  }
@@ -284,26 +284,26 @@ describe XeroRuby::ApiClient do
284
284
  }
285
285
 
286
286
  json_after = {
287
- "LineItems":[
287
+ "LineItems": [
288
288
  {
289
- "UnitAmount":20,
290
- "Quantity":1.0,
291
- "SubItems":[
289
+ "UnitAmount": 20,
290
+ "Quantity": 1.0,
291
+ "SubItems": [
292
292
  {
293
- "UnitAmount":20,
294
- "Quantity":1.0
293
+ "UnitAmount": 20,
294
+ "Quantity": 1.0
295
295
  },
296
296
  {
297
- "UnitAmount":20,
298
- "Quantity":1.0,
299
- "DeepItems":[
297
+ "UnitAmount": 20,
298
+ "Quantity": 1.0,
299
+ "DeepItems": [
300
300
  {
301
- "UnitAmount":20,
302
- "Quantity":1.0
301
+ "UnitAmount": 20,
302
+ "Quantity": 1.0
303
303
  },
304
304
  {
305
- "UnitAmount":20,
306
- "Quantity":1.0
305
+ "UnitAmount": 20,
306
+ "Quantity": 1.0
307
307
  }
308
308
  ]
309
309
  }
@@ -316,8 +316,8 @@ describe XeroRuby::ApiClient do
316
316
  end
317
317
 
318
318
  it 'Serializes mixed cased keys correctly' do
319
- contact_after = { :Contacts=>[{:Name=>"Bruce Banner", :EmailAddress=>"hulk@avengers.com", :Phones=>[{:PhoneType=>"MOBILE", :PhoneNumber=>"555-1212", :PhoneAreaCode=>"415"}], :PaymentTerms=>{:Bills=>{:Day=>15, :Type=>"OFCURRENTMONTH"}, :Sales=>{:Day=>10, :Type=>"DAYSAFTERBILLMONTH"}}}]}
320
- contact_before = {:contacts=>[{:name=>"Bruce Banner", :emailAddress=>"hulk@avengers.com", :phones=>[{:phoneType=>"MOBILE", :phone_number=>"555-1212", :phone_areaCode=>"415"}], :Payment_terms=>{:bills=>{:day=>15, :type=>"OFCURRENTMONTH"}, :sales=>{:day=>10, :type=>"DAYSAFTERBILLMONTH"}}}]}
319
+ contact_after = { :Contacts => [{ :Name => "Bruce Banner", :EmailAddress => "hulk@avengers.com", :Phones => [{ :PhoneType => "MOBILE", :PhoneNumber => "555-1212", :PhoneAreaCode => "415" }], :PaymentTerms => { :Bills => { :Day => 15, :Type => "OFCURRENTMONTH" }, :Sales => { :Day => 10, :Type => "DAYSAFTERBILLMONTH" } } }] }
320
+ contact_before = { :contacts => [{ :name => "Bruce Banner", :emailAddress => "hulk@avengers.com", :phones => [{ :phoneType => "MOBILE", :phone_number => "555-1212", :phone_areaCode => "415" }], :Payment_terms => { :bills => { :day => 15, :type => "OFCURRENTMONTH" }, :sales => { :day => 10, :type => "DAYSAFTERBILLMONTH" } } }] }
321
321
  api_client = XeroRuby::ApiClient.new
322
322
  expect(api_client.object_to_hash(contact_before)).to eq(contact_after)
323
323
  end
@@ -418,9 +418,9 @@ describe XeroRuby::ApiClient do
418
418
 
419
419
  describe 'token helper methods' do
420
420
  let(:api_client) { XeroRuby::ApiClient.new }
421
- let(:id_token){'eyJhbGciOiJSUzI1NiIsImtpZCI6IjFDQUY4RTY2NzcyRDZEQzAyOEQ2NzI2RkQwMjYxNTgxNTcwRUZDMTkiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJISy1PWm5jdGJjQW8xbkp2MENZVmdWY09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HSI3EA5j3Beto4pKukU-bk6rLBGul37u4tM17U-wyJLsFmt6ZC_SEJKgmluQ' }
423
+ let(:tkn_set) { { 'id_token': id_token, 'access_token': access_token, 'refresh_token': 'abc123xyz' } }
424
424
 
425
425
  before do
426
426
  api_client.set_token_set(tkn_set)
@@ -431,17 +431,17 @@ describe XeroRuby::ApiClient do
431
431
  end
432
432
 
433
433
  it '#token_expired? for a just expired token' do
434
- allow(api_client).to receive(:decoded_access_token).and_return({"exp"=>Time.now.to_i})
434
+ allow(api_client).to receive(:decoded_access_token).and_return({ "exp" => Time.now.to_i })
435
435
  expect(api_client.token_expired?).to eq(true)
436
436
  end
437
437
 
438
438
  it '#token_expired? for a non-expired token' do
439
- allow(api_client).to receive(:decoded_access_token).and_return({"exp"=>(Time.now + 30.minutes).to_i})
439
+ allow(api_client).to receive(:decoded_access_token).and_return({ "exp" => (Time.now + 30.minutes).to_i })
440
440
  expect(api_client.token_expired?).to eq(false)
441
441
  end
442
442
 
443
443
  it '#token_expired? for an almost expired token' do
444
- allow(api_client).to receive(:decoded_access_token).and_return({"exp"=>(Time.now + 30.seconds).to_i})
444
+ allow(api_client).to receive(:decoded_access_token).and_return({ "exp" => (Time.now + 30.seconds).to_i })
445
445
  expect(api_client.token_expired?).to eq(false)
446
446
  end
447
447
 
@@ -463,29 +463,29 @@ describe XeroRuby::ApiClient do
463
463
 
464
464
  it 'decoding an invalid access_token' do
465
465
  api_client.set_access_token("#{access_token}.NotAValidJWTstring")
466
- expect{api_client.decoded_access_token}.to raise_error(JSON::JWT::InvalidFormat)
466
+ expect { api_client.decoded_access_token }.to raise_error(JSON::JWT::InvalidFormat)
467
467
  end
468
468
 
469
469
  it 'decoding an invalid id_token' do
470
470
  api_client.set_id_token("#{id_token}.NotAValidJWTstring")
471
- expect{api_client.decoded_id_token}.to raise_error(JSON::JWT::InvalidFormat)
471
+ expect { api_client.decoded_id_token }.to raise_error(JSON::JWT::InvalidFormat)
472
472
  end
473
473
  end
474
474
 
475
475
 
476
476
  describe 'thread safety in the XeroClient' do
477
- let(:creds) {{
477
+ let(:creds) { {
478
478
  client_id: 'abc',
479
479
  client_secret: '123',
480
480
  redirect_uri: 'https://mydomain.com/callback',
481
481
  scopes: 'openid profile email accounting.transactions'
482
482
  }}
483
- let(:api_client_1) {XeroRuby::ApiClient.new(credentials: creds)}
484
- let(:api_client_2) {XeroRuby::ApiClient.new(credentials: creds)}
485
- let(:api_client_3) {XeroRuby::ApiClient.new(credentials: creds)}
483
+ let(:api_client_1) { XeroRuby::ApiClient.new(credentials: creds) }
484
+ let(:api_client_2) { XeroRuby::ApiClient.new(credentials: creds) }
485
+ let(:api_client_3) { XeroRuby::ApiClient.new(credentials: creds) }
486
486
 
487
- let(:tkn_set_1){{'id_token': "abc.123.1", 'access_token': "xxx.yyy.zzz.111"}}
488
- let(:tkn_set_2){{'id_token': "efg.456.2", 'access_token': "xxx.yyy.zzz.222"}}
487
+ let(:tkn_set_1) { { 'id_token': "abc.123.1", 'access_token': "xxx.yyy.zzz.111" } }
488
+ let(:tkn_set_2) { { 'id_token': "efg.456.2", 'access_token': "xxx.yyy.zzz.222" } }
489
489
 
490
490
  describe 'when configuration is changed, other instantiations of the client are not affected' do
491
491
  it 'applies to #set_access_token' do
@@ -29,7 +29,7 @@ describe XeroRuby::ApiError do
29
29
  }
30
30
  api_error = XeroRuby::ApiError.new(
31
31
  :code => 400,
32
- :response_headers => {"content-type"=>"application/json; charset=utf-8", "content-length"=>"1700", "server"=>"nginx", "xero-correlation-id"=>"31e2c94e-3ae4-402a-a374-b7a94ef9445c", "x-appminlimit-remaining"=>"9988", "x-minlimit-remaining"=>"58", "x-daylimit-remaining"=>"4998", "expires"=>"Fri, 18 Dec 2020 17:56:29 GMT", "cache-control"=>"max-age=0, no-cache, no-store", "pragma"=>"no-cache", "date"=>"Fri, 18 Dec 2020 17:56:29 GMT", "connection"=>"close", "x-client-tls-ver"=>"tls1.3"},
32
+ :response_headers => { "content-type" => "application/json; charset=utf-8", "content-length" => "1700", "server" => "nginx", "xero-correlation-id" => "31e2c94e-3ae4-402a-a374-b7a94ef9445c", "x-appminlimit-remaining" => "9988", "x-minlimit-remaining" => "58", "x-daylimit-remaining" => "4998", "expires" => "Fri, 18 Dec 2020 17:56:29 GMT", "cache-control" => "max-age=0, no-cache, no-store", "pragma" => "no-cache", "date" => "Fri, 18 Dec 2020 17:56:29 GMT", "connection" => "close", "x-client-tls-ver" => "tls1.3" },
33
33
  :response_body => error_body
34
34
  )
35
35
  expect(api_error.message).to include("The TaxType code NONE does not exist or cannot be used for this type of transaction")
@@ -25,12 +25,12 @@ describe XeroRuby::Configuration do
25
25
  end
26
26
 
27
27
  it 'should allow you to overwrite the default configuration options' do
28
- client = XeroRuby::ApiClient.new(credentials: {}, config: {login_url: 'ngrok.login.xero.test'})
28
+ client = XeroRuby::ApiClient.new(credentials: {}, config: { login_url: 'ngrok.login.xero.test' })
29
29
  expect(client.config.login_url).to eq('ngrok.login.xero.test')
30
30
  end
31
31
 
32
32
  it 'should allow you to set the timeout config option' do
33
- client = XeroRuby::ApiClient.new(credentials: {}, config: {timeout: 30})
33
+ client = XeroRuby::ApiClient.new(credentials: {}, config: { timeout: 30 })
34
34
  expect(client.config.timeout).to eq(30)
35
35
  end
36
36
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe 'shared helper methods' do
4
4
 
5
5
  describe '#parse_date' do
6
- let(:model_instance) {XeroRuby::Accounting::Account.new}
6
+ let(:model_instance) { XeroRuby::Accounting::Account.new }
7
7
 
8
8
  it 'can parse from ms date with backslash' do
9
9
  datestring = "\/Date(1519851689297+0000)\/"
@@ -85,11 +85,11 @@ describe 'shared helper methods' do
85
85
 
86
86
  describe '#attributes' do
87
87
  it 'can serialize invoice attributes into a snake_case hash' do
88
- expect(invoice.to_attributes).to eq({currency_code: "USD", has_attachments: false, has_errors: false, invoice_number: "abc-123", total_discount: 100, type: "ACCPAY"})
88
+ expect(invoice.to_attributes).to eq({ currency_code: "USD", has_attachments: false, has_errors: false, invoice_number: "abc-123", total_discount: 100, type: "ACCPAY" })
89
89
  end
90
90
 
91
91
  it 'can serialize contact attributes into a snake_case hash' do
92
- expect(contact.to_attributes).to eq({account_number: "abc-123", contact_status: "ACTIVE", email_address: "email@gmail.com", first_name: 'Contact', has_attachments: false, has_validation_errors: false, last_name: "Name", name: "Contact Name"})
92
+ expect(contact.to_attributes).to eq({ account_number: "abc-123", contact_status: "ACTIVE", email_address: "email@gmail.com", first_name: 'Contact', has_attachments: false, has_validation_errors: false, last_name: "Name", name: "Contact Name" })
93
93
  end
94
94
 
95
95
  it 'can serialize nested attributes into a snake_case hash' do
data/spec/where_spec.rb CHANGED
@@ -69,13 +69,13 @@ describe XeroRuby::Where do
69
69
  end
70
70
 
71
71
  describe "operators starting with a dot" do
72
- let(:opts) { {a: '.Test("Hello")' } }
72
+ let(:opts) { { a: '.Test("Hello")' } }
73
73
 
74
74
  it { is_expected.to eq %{A.Test("Hello")} }
75
75
  end
76
76
 
77
77
  describe "unmatched operators" do
78
- let(:opts) { {a: 'something unusual'} }
78
+ let(:opts) { { a: 'something unusual' } }
79
79
 
80
80
  it { is_expected.to eq %{A something unusual} }
81
81
  end