xeroizer 2.18.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +199 -223
  3. data/lib/xeroizer/connection.rb +49 -0
  4. data/lib/xeroizer/exceptions.rb +2 -0
  5. data/lib/xeroizer/generic_application.rb +12 -5
  6. data/lib/xeroizer/http.rb +5 -78
  7. data/lib/xeroizer/http_response.rb +157 -0
  8. data/lib/xeroizer/models/bank_account.rb +1 -0
  9. data/lib/xeroizer/models/bank_transaction.rb +1 -0
  10. data/lib/xeroizer/models/batch_payment.rb +27 -0
  11. data/lib/xeroizer/models/branding_theme.rb +49 -9
  12. data/lib/xeroizer/models/contact.rb +10 -4
  13. data/lib/xeroizer/models/contact_group.rb +45 -0
  14. data/lib/xeroizer/models/credit_note.rb +23 -22
  15. data/lib/xeroizer/models/from_bank_account.rb +1 -0
  16. data/lib/xeroizer/models/history_record.rb +72 -0
  17. data/lib/xeroizer/models/invoice.rb +14 -3
  18. data/lib/xeroizer/models/line_item.rb +17 -5
  19. data/lib/xeroizer/models/manual_journal.rb +2 -1
  20. data/lib/xeroizer/models/option.rb +1 -1
  21. data/lib/xeroizer/models/organisation.rb +2 -0
  22. data/lib/xeroizer/models/payment_service.rb +22 -0
  23. data/lib/xeroizer/models/payroll/address.rb +53 -0
  24. data/lib/xeroizer/models/payroll/bank_account.rb +18 -6
  25. data/lib/xeroizer/models/payroll/benefit_line.rb +26 -0
  26. data/lib/xeroizer/models/payroll/benefit_type.rb +45 -0
  27. data/lib/xeroizer/models/payroll/deduction_line.rb +32 -0
  28. data/lib/xeroizer/models/payroll/deduction_type.rb +49 -0
  29. data/lib/xeroizer/models/payroll/earnings_line.rb +39 -0
  30. data/lib/xeroizer/models/payroll/earnings_type.rb +53 -0
  31. data/lib/xeroizer/models/payroll/employee.rb +30 -8
  32. data/lib/xeroizer/models/payroll/leave_application.rb +27 -0
  33. data/lib/xeroizer/models/payroll/leave_line.rb +30 -0
  34. data/lib/xeroizer/models/payroll/leave_period.rb +15 -0
  35. data/lib/xeroizer/models/payroll/pay_items.rb +22 -0
  36. data/lib/xeroizer/models/payroll/pay_run.rb +33 -0
  37. data/lib/xeroizer/models/payroll/pay_schedule.rb +40 -0
  38. data/lib/xeroizer/models/payroll/pay_template.rb +24 -0
  39. data/lib/xeroizer/models/payroll/payment_method.rb +24 -0
  40. data/lib/xeroizer/models/payroll/paystub.rb +44 -0
  41. data/lib/xeroizer/models/payroll/reimbursement_line.rb +21 -0
  42. data/lib/xeroizer/models/payroll/reimbursement_type.rb +22 -0
  43. data/lib/xeroizer/models/payroll/salary_and_wage.rb +29 -0
  44. data/lib/xeroizer/models/payroll/super_line.rb +40 -0
  45. data/lib/xeroizer/models/payroll/tax_declaration.rb +50 -0
  46. data/lib/xeroizer/models/payroll/time_off_line.rb +20 -0
  47. data/lib/xeroizer/models/payroll/time_off_type.rb +32 -0
  48. data/lib/xeroizer/models/payroll/work_location.rb +25 -0
  49. data/lib/xeroizer/models/prepayment.rb +1 -0
  50. data/lib/xeroizer/models/purchase_order.rb +6 -6
  51. data/lib/xeroizer/models/quote.rb +76 -0
  52. data/lib/xeroizer/models/schedule.rb +1 -0
  53. data/lib/xeroizer/models/tax_component.rb +1 -0
  54. data/lib/xeroizer/models/to_bank_account.rb +1 -0
  55. data/lib/xeroizer/oauth.rb +12 -1
  56. data/lib/xeroizer/oauth2.rb +82 -0
  57. data/lib/xeroizer/oauth2_application.rb +49 -0
  58. data/lib/xeroizer/payroll_application.rb +8 -3
  59. data/lib/xeroizer/record/base.rb +1 -1
  60. data/lib/xeroizer/record/base_model.rb +1 -1
  61. data/lib/xeroizer/record/base_model_http_proxy.rb +4 -0
  62. data/lib/xeroizer/record/model_definition_helper.rb +1 -1
  63. data/lib/xeroizer/record/payroll_base.rb +4 -0
  64. data/lib/xeroizer/record/record_association_helper.rb +4 -4
  65. data/lib/xeroizer/record/validators/associated_validator.rb +1 -0
  66. data/lib/xeroizer/record/xml_helper.rb +18 -18
  67. data/lib/xeroizer/report/aged_receivables_by_contact.rb +1 -1
  68. data/lib/xeroizer/report/cell_xml_helper.rb +13 -13
  69. data/lib/xeroizer/response.rb +22 -17
  70. data/lib/xeroizer/version.rb +1 -1
  71. data/lib/xeroizer.rb +33 -4
  72. data/test/acceptance/about_creating_bank_transactions_test.rb +80 -82
  73. data/test/acceptance/about_creating_prepayment_test.rb +25 -30
  74. data/test/acceptance/about_fetching_bank_transactions_test.rb +12 -12
  75. data/test/acceptance/about_online_invoice_test.rb +6 -10
  76. data/test/acceptance/acceptance_test.rb +28 -26
  77. data/test/acceptance/bank_transfer_test.rb +12 -17
  78. data/test/acceptance/bulk_operations_test.rb +18 -16
  79. data/test/acceptance/connections_test.rb +11 -0
  80. data/test/stub_responses/bad_request.json +6 -0
  81. data/test/stub_responses/connections.json +16 -0
  82. data/test/stub_responses/expired_oauth2_token.json +6 -0
  83. data/test/stub_responses/generic_response_error.json +6 -0
  84. data/test/stub_responses/invalid_oauth2_request_token.json +6 -0
  85. data/test/stub_responses/invalid_tenant_header.json +6 -0
  86. data/test/stub_responses/object_not_found.json +6 -0
  87. data/test/stub_responses/organisations.xml +10 -0
  88. data/test/stub_responses/payment_service.xml +15 -0
  89. data/test/test_helper.rb +16 -11
  90. data/test/unit/generic_application_test.rb +21 -10
  91. data/test/unit/http_test.rb +284 -10
  92. data/test/unit/models/address_test.rb +2 -2
  93. data/test/unit/models/bank_transaction_model_parsing_test.rb +2 -2
  94. data/test/unit/models/bank_transaction_test.rb +1 -1
  95. data/test/unit/models/bank_transaction_validation_test.rb +1 -1
  96. data/test/unit/models/contact_test.rb +2 -2
  97. data/test/unit/models/credit_note_test.rb +8 -8
  98. data/test/unit/models/employee_test.rb +4 -4
  99. data/test/unit/models/invoice_test.rb +12 -12
  100. data/test/unit/models/journal_line_test.rb +6 -6
  101. data/test/unit/models/journal_test.rb +4 -4
  102. data/test/unit/models/line_item_sum_test.rb +1 -1
  103. data/test/unit/models/line_item_test.rb +26 -28
  104. data/test/unit/models/manual_journal_test.rb +3 -3
  105. data/test/unit/models/organisation_test.rb +16 -2
  106. data/test/unit/models/payment_service_test.rb +29 -0
  107. data/test/unit/models/phone_test.rb +7 -7
  108. data/test/unit/models/prepayment_test.rb +4 -4
  109. data/test/unit/models/repeating_invoice_test.rb +3 -3
  110. data/test/unit/models/tax_rate_test.rb +2 -2
  111. data/test/unit/oauth2_test.rb +171 -0
  112. data/test/unit/oauth_config_test.rb +1 -1
  113. data/test/unit/record/base_model_test.rb +13 -13
  114. data/test/unit/record/base_test.rb +15 -4
  115. data/test/unit/record/block_validator_test.rb +1 -1
  116. data/test/unit/record/connection_test.rb +60 -0
  117. data/test/unit/record/model_definition_test.rb +36 -36
  118. data/test/unit/record/parse_params_test.rb +2 -2
  119. data/test/unit/record/parse_where_hash_test.rb +13 -13
  120. data/test/unit/record/record_association_test.rb +14 -14
  121. data/test/unit/record/validators_test.rb +43 -43
  122. data/test/unit/record_definition_test.rb +7 -7
  123. data/test/unit/report_definition_test.rb +7 -7
  124. data/test/unit/report_test.rb +20 -20
  125. data/test/unit_test_helper.rb +16 -0
  126. metadata +100 -25
  127. data/lib/xeroizer/models/payroll/home_address.rb +0 -24
  128. data/lib/xeroizer/partner_application.rb +0 -51
  129. data/lib/xeroizer/private_application.rb +0 -25
  130. data/lib/xeroizer/public_application.rb +0 -21
  131. data/test/unit/http_tsl_12_upgrade_test.rb +0 -31
  132. data/test/unit/oauth_test.rb +0 -118
  133. data/test/unit/private_application_test.rb +0 -20
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xeroizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.1
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne Robinson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-07 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: '2.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -54,6 +54,20 @@ dependencies:
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: shoulda
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.6.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: test-unit
84
+ name: turn
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: rest-client
98
+ name: ansi
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: turn
112
+ name: redcarpet
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -109,7 +123,7 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: ansi
126
+ name: yard
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - ">="
@@ -123,7 +137,7 @@ dependencies:
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: redcarpet
140
+ name: webmock
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
@@ -137,7 +151,7 @@ dependencies:
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
- name: yard
154
+ name: pry
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
@@ -178,6 +192,20 @@ dependencies:
178
192
  - - ">="
179
193
  - !ruby/object:Gem::Version
180
194
  version: 0.4.5
195
+ - !ruby/object:Gem::Dependency
196
+ name: oauth2
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: 1.4.0
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 1.4.0
181
209
  - !ruby/object:Gem::Dependency
182
210
  name: activesupport
183
211
  requirement: !ruby/object:Gem::Requirement
@@ -250,10 +278,12 @@ files:
250
278
  - lib/xeroizer/application_http_proxy.rb
251
279
  - lib/xeroizer/ca-certificates.crt
252
280
  - lib/xeroizer/configuration.rb
281
+ - lib/xeroizer/connection.rb
253
282
  - lib/xeroizer/exceptions.rb
254
283
  - lib/xeroizer/generic_application.rb
255
284
  - lib/xeroizer/http.rb
256
285
  - lib/xeroizer/http_encoding_helper.rb
286
+ - lib/xeroizer/http_response.rb
257
287
  - lib/xeroizer/logging.rb
258
288
  - lib/xeroizer/models/account.rb
259
289
  - lib/xeroizer/models/accounts_payable.rb
@@ -265,6 +295,7 @@ files:
265
295
  - lib/xeroizer/models/bank_account.rb
266
296
  - lib/xeroizer/models/bank_transaction.rb
267
297
  - lib/xeroizer/models/bank_transfer.rb
298
+ - lib/xeroizer/models/batch_payment.rb
268
299
  - lib/xeroizer/models/batch_payments.rb
269
300
  - lib/xeroizer/models/bills.rb
270
301
  - lib/xeroizer/models/branding_theme.rb
@@ -279,6 +310,7 @@ files:
279
310
  - lib/xeroizer/models/expense_claim.rb
280
311
  - lib/xeroizer/models/external_link.rb
281
312
  - lib/xeroizer/models/from_bank_account.rb
313
+ - lib/xeroizer/models/history_record.rb
282
314
  - lib/xeroizer/models/invoice.rb
283
315
  - lib/xeroizer/models/invoice_reminder.rb
284
316
  - lib/xeroizer/models/item.rb
@@ -297,13 +329,38 @@ files:
297
329
  - lib/xeroizer/models/organisation.rb
298
330
  - lib/xeroizer/models/overpayment.rb
299
331
  - lib/xeroizer/models/payment.rb
332
+ - lib/xeroizer/models/payment_service.rb
300
333
  - lib/xeroizer/models/payment_terms.rb
334
+ - lib/xeroizer/models/payroll/address.rb
301
335
  - lib/xeroizer/models/payroll/bank_account.rb
336
+ - lib/xeroizer/models/payroll/benefit_line.rb
337
+ - lib/xeroizer/models/payroll/benefit_type.rb
338
+ - lib/xeroizer/models/payroll/deduction_line.rb
339
+ - lib/xeroizer/models/payroll/deduction_type.rb
340
+ - lib/xeroizer/models/payroll/earnings_line.rb
341
+ - lib/xeroizer/models/payroll/earnings_type.rb
302
342
  - lib/xeroizer/models/payroll/employee.rb
303
- - lib/xeroizer/models/payroll/home_address.rb
343
+ - lib/xeroizer/models/payroll/leave_application.rb
344
+ - lib/xeroizer/models/payroll/leave_line.rb
345
+ - lib/xeroizer/models/payroll/leave_period.rb
346
+ - lib/xeroizer/models/payroll/pay_items.rb
347
+ - lib/xeroizer/models/payroll/pay_run.rb
348
+ - lib/xeroizer/models/payroll/pay_schedule.rb
349
+ - lib/xeroizer/models/payroll/pay_template.rb
350
+ - lib/xeroizer/models/payroll/payment_method.rb
351
+ - lib/xeroizer/models/payroll/paystub.rb
352
+ - lib/xeroizer/models/payroll/reimbursement_line.rb
353
+ - lib/xeroizer/models/payroll/reimbursement_type.rb
354
+ - lib/xeroizer/models/payroll/salary_and_wage.rb
355
+ - lib/xeroizer/models/payroll/super_line.rb
356
+ - lib/xeroizer/models/payroll/tax_declaration.rb
357
+ - lib/xeroizer/models/payroll/time_off_line.rb
358
+ - lib/xeroizer/models/payroll/time_off_type.rb
359
+ - lib/xeroizer/models/payroll/work_location.rb
304
360
  - lib/xeroizer/models/phone.rb
305
361
  - lib/xeroizer/models/prepayment.rb
306
362
  - lib/xeroizer/models/purchase_order.rb
363
+ - lib/xeroizer/models/quote.rb
307
364
  - lib/xeroizer/models/receipt.rb
308
365
  - lib/xeroizer/models/repeating_invoice.rb
309
366
  - lib/xeroizer/models/sales.rb
@@ -315,10 +372,9 @@ files:
315
372
  - lib/xeroizer/models/tracking_category_child.rb
316
373
  - lib/xeroizer/models/user.rb
317
374
  - lib/xeroizer/oauth.rb
318
- - lib/xeroizer/partner_application.rb
375
+ - lib/xeroizer/oauth2.rb
376
+ - lib/xeroizer/oauth2_application.rb
319
377
  - lib/xeroizer/payroll_application.rb
320
- - lib/xeroizer/private_application.rb
321
- - lib/xeroizer/public_application.rb
322
378
  - lib/xeroizer/record/application_helper.rb
323
379
  - lib/xeroizer/record/base.rb
324
380
  - lib/xeroizer/record/base_model.rb
@@ -356,10 +412,13 @@ files:
356
412
  - test/acceptance/bank_transaction_reference_data.rb
357
413
  - test/acceptance/bank_transfer_test.rb
358
414
  - test/acceptance/bulk_operations_test.rb
415
+ - test/acceptance/connections_test.rb
359
416
  - test/stub_responses/accounts.xml
360
417
  - test/stub_responses/api_exception.xml
418
+ - test/stub_responses/bad_request.json
361
419
  - test/stub_responses/bogus_oauth_error
362
420
  - test/stub_responses/branding_themes.xml
421
+ - test/stub_responses/connections.json
363
422
  - test/stub_responses/contact.xml
364
423
  - test/stub_responses/contact_with_details.xml
365
424
  - test/stub_responses/contacts.xml
@@ -370,9 +429,13 @@ files:
370
429
  - test/stub_responses/credit_notes.xml
371
430
  - test/stub_responses/currencies.xml
372
431
  - test/stub_responses/employees.xml
432
+ - test/stub_responses/expired_oauth2_token.json
433
+ - test/stub_responses/generic_response_error.json
373
434
  - test/stub_responses/invalid_api_key_error.xml
374
435
  - test/stub_responses/invalid_consumer_key
436
+ - test/stub_responses/invalid_oauth2_request_token.json
375
437
  - test/stub_responses/invalid_request_token
438
+ - test/stub_responses/invalid_tenant_header.json
376
439
  - test/stub_responses/invoice.xml
377
440
  - test/stub_responses/invoice_not_found_error.xml
378
441
  - test/stub_responses/invoices.xml
@@ -380,8 +443,10 @@ files:
380
443
  - test/stub_responses/manual_journal.xml
381
444
  - test/stub_responses/manual_journals.xml
382
445
  - test/stub_responses/nonce_used
446
+ - test/stub_responses/object_not_found.json
383
447
  - test/stub_responses/organisation.xml
384
448
  - test/stub_responses/organisations.xml
449
+ - test/stub_responses/payment_service.xml
385
450
  - test/stub_responses/payments.xml
386
451
  - test/stub_responses/prepayments.xml
387
452
  - test/stub_responses/rate_limit_exceeded
@@ -596,7 +661,6 @@ files:
596
661
  - test/test_helper.rb
597
662
  - test/unit/generic_application_test.rb
598
663
  - test/unit/http_test.rb
599
- - test/unit/http_tsl_12_upgrade_test.rb
600
664
  - test/unit/models/address_test.rb
601
665
  - test/unit/models/bank_transaction_model_parsing_test.rb
602
666
  - test/unit/models/bank_transaction_test.rb
@@ -611,16 +675,17 @@ files:
611
675
  - test/unit/models/line_item_test.rb
612
676
  - test/unit/models/manual_journal_test.rb
613
677
  - test/unit/models/organisation_test.rb
678
+ - test/unit/models/payment_service_test.rb
614
679
  - test/unit/models/phone_test.rb
615
680
  - test/unit/models/prepayment_test.rb
616
681
  - test/unit/models/repeating_invoice_test.rb
617
682
  - test/unit/models/tax_rate_test.rb
683
+ - test/unit/oauth2_test.rb
618
684
  - test/unit/oauth_config_test.rb
619
- - test/unit/oauth_test.rb
620
- - test/unit/private_application_test.rb
621
685
  - test/unit/record/base_model_test.rb
622
686
  - test/unit/record/base_test.rb
623
687
  - test/unit/record/block_validator_test.rb
688
+ - test/unit/record/connection_test.rb
624
689
  - test/unit/record/model_definition_test.rb
625
690
  - test/unit/record/parse_params_test.rb
626
691
  - test/unit/record/parse_where_hash_test.rb
@@ -629,6 +694,7 @@ files:
629
694
  - test/unit/record_definition_test.rb
630
695
  - test/unit/report_definition_test.rb
631
696
  - test/unit/report_test.rb
697
+ - test/unit_test_helper.rb
632
698
  homepage: http://github.com/waynerobinson/xeroizer
633
699
  licenses:
634
700
  - MIT
@@ -638,7 +704,7 @@ metadata:
638
704
  source_code_uri: https://github.com/waynerobinson/xeroizer
639
705
  documentation_uri: https://developer.xero.com/documentation/
640
706
  mailing_list_uri: https://developer.xero.com/subscribe-to-the-xero-api-developer-mailing-list
641
- post_install_message:
707
+ post_install_message:
642
708
  rdoc_options: []
643
709
  require_paths:
644
710
  - lib
@@ -653,9 +719,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
653
719
  - !ruby/object:Gem::Version
654
720
  version: '0'
655
721
  requirements: []
656
- rubyforge_project:
657
- rubygems_version: 2.6.14
658
- signing_key:
722
+ rubygems_version: 3.2.3
723
+ signing_key:
659
724
  specification_version: 4
660
725
  summary: Ruby Library for Xero accounting API
661
726
  test_files:
@@ -667,10 +732,13 @@ test_files:
667
732
  - test/acceptance/bank_transaction_reference_data.rb
668
733
  - test/acceptance/bank_transfer_test.rb
669
734
  - test/acceptance/bulk_operations_test.rb
735
+ - test/acceptance/connections_test.rb
670
736
  - test/stub_responses/accounts.xml
671
737
  - test/stub_responses/api_exception.xml
738
+ - test/stub_responses/bad_request.json
672
739
  - test/stub_responses/bogus_oauth_error
673
740
  - test/stub_responses/branding_themes.xml
741
+ - test/stub_responses/connections.json
674
742
  - test/stub_responses/contact.xml
675
743
  - test/stub_responses/contact_with_details.xml
676
744
  - test/stub_responses/contacts.xml
@@ -681,9 +749,13 @@ test_files:
681
749
  - test/stub_responses/credit_notes.xml
682
750
  - test/stub_responses/currencies.xml
683
751
  - test/stub_responses/employees.xml
752
+ - test/stub_responses/expired_oauth2_token.json
753
+ - test/stub_responses/generic_response_error.json
684
754
  - test/stub_responses/invalid_api_key_error.xml
685
755
  - test/stub_responses/invalid_consumer_key
756
+ - test/stub_responses/invalid_oauth2_request_token.json
686
757
  - test/stub_responses/invalid_request_token
758
+ - test/stub_responses/invalid_tenant_header.json
687
759
  - test/stub_responses/invoice.xml
688
760
  - test/stub_responses/invoice_not_found_error.xml
689
761
  - test/stub_responses/invoices.xml
@@ -691,8 +763,10 @@ test_files:
691
763
  - test/stub_responses/manual_journal.xml
692
764
  - test/stub_responses/manual_journals.xml
693
765
  - test/stub_responses/nonce_used
766
+ - test/stub_responses/object_not_found.json
694
767
  - test/stub_responses/organisation.xml
695
768
  - test/stub_responses/organisations.xml
769
+ - test/stub_responses/payment_service.xml
696
770
  - test/stub_responses/payments.xml
697
771
  - test/stub_responses/prepayments.xml
698
772
  - test/stub_responses/rate_limit_exceeded
@@ -907,7 +981,6 @@ test_files:
907
981
  - test/test_helper.rb
908
982
  - test/unit/generic_application_test.rb
909
983
  - test/unit/http_test.rb
910
- - test/unit/http_tsl_12_upgrade_test.rb
911
984
  - test/unit/models/address_test.rb
912
985
  - test/unit/models/bank_transaction_model_parsing_test.rb
913
986
  - test/unit/models/bank_transaction_test.rb
@@ -922,16 +995,17 @@ test_files:
922
995
  - test/unit/models/line_item_test.rb
923
996
  - test/unit/models/manual_journal_test.rb
924
997
  - test/unit/models/organisation_test.rb
998
+ - test/unit/models/payment_service_test.rb
925
999
  - test/unit/models/phone_test.rb
926
1000
  - test/unit/models/prepayment_test.rb
927
1001
  - test/unit/models/repeating_invoice_test.rb
928
1002
  - test/unit/models/tax_rate_test.rb
1003
+ - test/unit/oauth2_test.rb
929
1004
  - test/unit/oauth_config_test.rb
930
- - test/unit/oauth_test.rb
931
- - test/unit/private_application_test.rb
932
1005
  - test/unit/record/base_model_test.rb
933
1006
  - test/unit/record/base_test.rb
934
1007
  - test/unit/record/block_validator_test.rb
1008
+ - test/unit/record/connection_test.rb
935
1009
  - test/unit/record/model_definition_test.rb
936
1010
  - test/unit/record/parse_params_test.rb
937
1011
  - test/unit/record/parse_where_hash_test.rb
@@ -940,3 +1014,4 @@ test_files:
940
1014
  - test/unit/record_definition_test.rb
941
1015
  - test/unit/report_definition_test.rb
942
1016
  - test/unit/report_test.rb
1017
+ - test/unit_test_helper.rb
@@ -1,24 +0,0 @@
1
- module Xeroizer
2
- module Record
3
- module Payroll
4
-
5
- class HomeAddressModel < PayrollBaseModel
6
-
7
- end
8
-
9
- class HomeAddress < PayrollBase
10
-
11
- string :address_line_1
12
- string :address_line_2
13
- string :address_line_3
14
- string :address_line_4
15
- string :city
16
- string :region
17
- string :postal_code
18
- string :country
19
-
20
- end
21
-
22
- end
23
- end
24
- end
@@ -1,51 +0,0 @@
1
- module Xeroizer
2
- class PartnerApplication < GenericApplication
3
-
4
- extend Forwardable
5
- def_delegators :client, :request_token, :authorize_from_request, :renew_access_token, :expires_at, :authorization_expires_at, :session_handle, :authorize_from_access
6
-
7
- public
8
-
9
- # Partner applications allow for public AccessToken's received via the stanard OAuth
10
- # authentication process to be renewed up until the session's expiry. The default session
11
- # expiry for Xero is 365 days and the default AccessToken expiry is 30 minutes.
12
- #
13
- # @param [String] consumer_key consumer key/token from application developer (found at http://api.xero.com for your application).
14
- # @param [String] consumer_secret consumer secret from application developer (found at http://api.xero.com for your application).
15
- # @param [String] path_to_private_key application's private key for message signing (uploaded to http://api.xero.com)
16
- # @param [Hash] options other options to pass to the GenericApplication constructor
17
- # @return [PartnerApplication] instance of PrivateApplication
18
- def initialize(consumer_key, consumer_secret, path_to_private_key, options = {})
19
- default_options = {
20
- :xero_url => 'https://api.xero.com/api.xro/2.0',
21
- :site => 'https://api.xero.com',
22
- :authorize_url => 'https://api.xero.com/oauth/Authorize',
23
- :signature_method => 'RSA-SHA1'
24
- }
25
- options = default_options.merge(options).merge(
26
- :private_key_file => path_to_private_key
27
- )
28
- super(consumer_key, consumer_secret, options)
29
-
30
- # Load up an existing token if passed the token/key.
31
- if options[:access_token] && options[:access_key]
32
- authorize_from_access(options[:access_token], options[:access_key])
33
- end
34
-
35
- # Save the session_handle if passed in so we can renew the token.
36
- if options[:session_handle]
37
- client.session_handle = options[:session_handle]
38
- end
39
- end
40
-
41
- private
42
-
43
- def read_certificate(cert)
44
- if File.exists?(cert)
45
- File.read(cert)
46
- else
47
- cert
48
- end
49
- end
50
- end
51
- end
@@ -1,25 +0,0 @@
1
- module Xeroizer
2
- class PrivateApplication < GenericApplication
3
-
4
- extend Forwardable
5
- def_delegators :client, :authorize_from_access
6
-
7
- public
8
-
9
- # Private applications are defined in the Xero API website and can be accessed in the
10
- # background without ever requiring a redirect to the Xero website for authorisation.
11
- #
12
- # @param [String] consumer_key consumer key/token from application developer (found at http://api.xero.com for your application).
13
- # @param [String] consumer_secret consumer secret from application developer (found at http://api.xero.com for your application).
14
- # @param [String] path_to_private_key application's private key for message signing (uploaded to http://api.xero.com)
15
- # @param [Hash] options other options to pass to the GenericApplication constructor
16
- # @return [PrivateApplication] instance of PrivateApplication
17
- def initialize(consumer_key, consumer_secret, path_to_private_key, options = {})
18
- options[:signature_method] = 'RSA-SHA1'
19
- options[:private_key_file] = path_to_private_key
20
- super(consumer_key, consumer_secret, options)
21
- @client.authorize_from_access(consumer_key, consumer_secret)
22
- end
23
-
24
- end
25
- end
@@ -1,21 +0,0 @@
1
- module Xeroizer
2
- class PublicApplication < GenericApplication
3
-
4
- extend Forwardable
5
- def_delegators :client, :request_token, :authorize_from_request, :authorize_from_access
6
-
7
- public
8
-
9
- # Public appliations are authenticated via the Xero website via OAuth. AccessTokens are valid for 30 minutes
10
- # after authentication. To extend this time you must redirect the user to Xero's OAuth server again.
11
- #
12
- # @param [String] consumer_key consumer key/token from application developer (found at http://api.xero.com for your application)
13
- # @param [String] consumer_secret consumer secret from application developer (found at http://api.xero.com for your application)
14
- # @param [Hash] options other options to pass to the GenericApplication constructor
15
- # @return [PublicApplication] instance of PrivateApplication
16
- def initialize(consumer_key, consumer_secret, options = {})
17
- super(consumer_key, consumer_secret, options)
18
- end
19
-
20
- end
21
- end
@@ -1,31 +0,0 @@
1
- require 'test_helper'
2
- require 'json'
3
-
4
- class HttpTest < Test::Unit::TestCase
5
- include TestHelper
6
-
7
- def setup
8
- @application = Xeroizer::PrivateApplication.new(CONSUMER_KEY, CONSUMER_SECRET, PRIVATE_KEY_PATH, {:xero_url => 'https://api-tls.xero.com/', :site => 'https://api-tls.xero.com/'})
9
- @applicationExternal = Xeroizer::PrivateApplication.new(CONSUMER_KEY, CONSUMER_SECRET, PRIVATE_KEY_PATH, {:xero_url => 'https://www.howsmyssl.com', :site => 'https://www.howsmyssl.com'})
10
- end
11
-
12
- context "Connect to Xero TLS 1.2 Test endpoint" do
13
- should "receive a 301 response (endpoint redirects on success)" do
14
- begin
15
- @application.http_get(@application.client, "https://api-tls.xero.com/")
16
- rescue Xeroizer::Http::BadResponse => e
17
- assert_equal "Unknown response code: 301", e.message, "Unexpected Response Code (Xero): Check TLS 1.2 is set"
18
- end
19
-
20
- end
21
- end
22
-
23
- context "Connect to external TLS 1.2 Test endpoint" do
24
- should "respond with tls version 1.2" do
25
- response = @applicationExternal.http_get(@applicationExternal.client, "https://www.howsmyssl.com/a/check")
26
- jsonResponse = JSON.parse(response)
27
- assert_equal "TLS 1.2", jsonResponse['tls_version'], "Unexpected Response (External): Check TLS 1.2 is set"
28
- end
29
- end
30
- end
31
-
@@ -1,118 +0,0 @@
1
- require 'test_helper'
2
-
3
- class OAuthTest < Test::Unit::TestCase
4
- include TestHelper
5
-
6
- def setup
7
- @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
8
- end
9
-
10
- context "with oauth error handling" do
11
-
12
- should "handle token expired" do
13
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("token_expired"), :code => "401"))
14
-
15
- assert_raises Xeroizer::OAuth::TokenExpired do
16
- @client.Organisation.first
17
- end
18
- end
19
-
20
- should "handle invalid request tokens" do
21
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("invalid_request_token"), :code => "401"))
22
-
23
- assert_raises Xeroizer::OAuth::TokenInvalid do
24
- @client.Organisation.first
25
- end
26
- end
27
-
28
- should "handle invalid consumer key" do
29
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("invalid_consumer_key"), :code => "401"))
30
-
31
- assert_raises Xeroizer::OAuth::TokenInvalid do
32
- @client.Organisation.first
33
- end
34
- end
35
-
36
- should "handle nonce used" do
37
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("nonce_used"), :code => "401"))
38
-
39
- assert_raises Xeroizer::OAuth::NonceUsed do
40
- @client.Organisation.first
41
- end
42
- end
43
-
44
- should "raise rate limit exceeded" do
45
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("rate_limit_exceeded"), :code => "401"))
46
-
47
- assert_raises Xeroizer::OAuth::RateLimitExceeded do
48
- @client.Organisation.first
49
- end
50
- end
51
-
52
- should "automatically handle rate limit exceeded" do
53
- auto_rate_limit_client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET, :rate_limit_sleep => 1)
54
-
55
- # Return rate limit exceeded on first call, OK on the second
56
- Xeroizer::OAuth.any_instance.stubs(:get).returns(
57
- stub(:plain_body => get_file_as_string("rate_limit_exceeded"), :code => "401"),
58
- stub(:plain_body => get_record_xml(:organisation), :code => '200')
59
- )
60
-
61
- auto_rate_limit_client.expects(:sleep_for).with(1).returns(1)
62
-
63
- auto_rate_limit_client.Organisation.first
64
- end
65
-
66
- should "only retry rate limited request a configurable number of times" do
67
- auto_rate_limit_client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET, :rate_limit_sleep => 1, :rate_limit_max_attempts => 4)
68
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("rate_limit_exceeded"), :code => "401"))
69
-
70
- auto_rate_limit_client.expects(:sleep_for).with(1).times(4).returns(1)
71
-
72
- assert_raises Xeroizer::OAuth::RateLimitExceeded do
73
- auto_rate_limit_client.Organisation.first
74
- end
75
- end
76
-
77
- should "retry nonce_used failures a configurable number of times" do
78
- nonce_used_client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET, :nonce_used_max_attempts => 4)
79
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("nonce_used"), :code => "401"))
80
-
81
- nonce_used_client.expects(:sleep_for).with(1).times(4).returns(1)
82
-
83
- assert_raises Xeroizer::OAuth::NonceUsed do
84
- nonce_used_client.Organisation.first
85
- end
86
- end
87
-
88
- should "handle unknown errors" do
89
- Xeroizer::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("bogus_oauth_error"), :code => "401"))
90
-
91
- assert_raises Xeroizer::OAuth::UnknownError do
92
- @client.Organisation.first
93
- end
94
- end
95
-
96
- should "handle ApiExceptions" do
97
- Xeroizer::OAuth.any_instance.stubs(:put).returns(stub(:plain_body => get_file_as_string("api_exception.xml"),
98
- :code => "400"))
99
-
100
- assert_raises Xeroizer::ApiException do
101
- contact = @client.Contact.build(:name => 'Test Contact')
102
- contact.save!
103
- end
104
- end
105
-
106
- should "handle random root elements" do
107
- Xeroizer::OAuth.any_instance.stubs(:put).returns(stub(:plain_body => "<RandomRootElement></RandomRootElement>",
108
- :code => "200"))
109
-
110
- assert_raises Xeroizer::UnparseableResponse do
111
- contact = @client.Contact.build(:name => 'Test Contact')
112
- contact.save!
113
- end
114
- end
115
-
116
- end
117
-
118
- end
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PrivateApplicationTest < Test::Unit::TestCase
4
- include TestHelper
5
-
6
- def setup
7
- @client = Xeroizer::PrivateApplication.new(CONSUMER_KEY, CONSUMER_SECRET, PRIVATE_KEY_PATH)
8
- end
9
-
10
- context "initialization" do
11
-
12
- should "have a valid client" do
13
- assert_kind_of(Xeroizer::OAuth, @client.client)
14
- assert_equal(CONSUMER_KEY, @client.client.ctoken)
15
- assert_equal(CONSUMER_SECRET, @client.client.csecret)
16
- end
17
-
18
- end
19
-
20
- end