xero-ruby 2.4.1 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (460) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +240 -189
  3. data/lib/xero-ruby.rb +10 -4
  4. data/lib/xero-ruby/api/accounting_api.rb +1308 -920
  5. data/lib/xero-ruby/api/asset_api.rb +15 -14
  6. data/lib/xero-ruby/api/files_api.rb +204 -85
  7. data/lib/xero-ruby/api/payroll_au_api.rb +121 -93
  8. data/lib/xero-ruby/api/payroll_nz_api.rb +307 -240
  9. data/lib/xero-ruby/api/payroll_uk_api.rb +317 -254
  10. data/lib/xero-ruby/api/project_api.rb +71 -59
  11. data/lib/xero-ruby/api_client.rb +182 -128
  12. data/lib/xero-ruby/api_error.rb +4 -4
  13. data/lib/xero-ruby/configuration.rb +17 -5
  14. data/lib/xero-ruby/models/accounting/account.rb +25 -12
  15. data/lib/xero-ruby/models/accounting/account_type.rb +1 -2
  16. data/lib/xero-ruby/models/accounting/accounts.rb +25 -11
  17. data/lib/xero-ruby/models/accounting/accounts_payable.rb +25 -11
  18. data/lib/xero-ruby/models/accounting/accounts_receivable.rb +25 -11
  19. data/lib/xero-ruby/models/accounting/action.rb +25 -11
  20. data/lib/xero-ruby/models/accounting/actions.rb +25 -11
  21. data/lib/xero-ruby/models/accounting/address.rb +27 -14
  22. data/lib/xero-ruby/models/accounting/address_for_organisation.rb +484 -0
  23. data/lib/xero-ruby/models/accounting/allocation.rb +25 -11
  24. data/lib/xero-ruby/models/accounting/allocations.rb +25 -11
  25. data/lib/xero-ruby/models/accounting/attachment.rb +25 -11
  26. data/lib/xero-ruby/models/accounting/attachments.rb +25 -11
  27. data/lib/xero-ruby/models/accounting/balance_details.rb +25 -11
  28. data/lib/xero-ruby/models/accounting/balances.rb +25 -11
  29. data/lib/xero-ruby/models/accounting/bank_transaction.rb +25 -11
  30. data/lib/xero-ruby/models/accounting/bank_transactions.rb +25 -11
  31. data/lib/xero-ruby/models/accounting/bank_transfer.rb +25 -11
  32. data/lib/xero-ruby/models/accounting/bank_transfers.rb +25 -11
  33. data/lib/xero-ruby/models/accounting/batch_payment.rb +41 -15
  34. data/lib/xero-ruby/models/accounting/batch_payment_details.rb +25 -11
  35. data/lib/xero-ruby/models/accounting/batch_payments.rb +25 -11
  36. data/lib/xero-ruby/models/accounting/bill.rb +25 -11
  37. data/lib/xero-ruby/models/accounting/branding_theme.rb +25 -11
  38. data/lib/xero-ruby/models/accounting/branding_themes.rb +25 -11
  39. data/lib/xero-ruby/models/accounting/budget.rb +327 -0
  40. data/lib/xero-ruby/models/accounting/budget_balance.rb +267 -0
  41. data/lib/xero-ruby/models/accounting/budget_line.rb +244 -0
  42. data/lib/xero-ruby/models/{files/file_response204.rb → accounting/budgets.rb} +40 -24
  43. data/lib/xero-ruby/models/accounting/cis_org_setting.rb +26 -12
  44. data/lib/xero-ruby/models/accounting/cis_org_settings.rb +224 -0
  45. data/lib/xero-ruby/models/accounting/cis_setting.rb +26 -12
  46. data/lib/xero-ruby/models/accounting/cis_settings.rb +25 -11
  47. data/lib/xero-ruby/models/accounting/contact.rb +25 -11
  48. data/lib/xero-ruby/models/accounting/contact_group.rb +25 -11
  49. data/lib/xero-ruby/models/accounting/contact_groups.rb +25 -11
  50. data/lib/xero-ruby/models/accounting/contact_person.rb +25 -11
  51. data/lib/xero-ruby/models/accounting/contacts.rb +25 -11
  52. data/lib/xero-ruby/models/accounting/conversion_balances.rb +25 -11
  53. data/lib/xero-ruby/models/accounting/conversion_date.rb +25 -11
  54. data/lib/xero-ruby/models/accounting/country_code.rb +1 -2
  55. data/lib/xero-ruby/models/accounting/credit_note.rb +62 -16
  56. data/lib/xero-ruby/models/accounting/credit_notes.rb +25 -11
  57. data/lib/xero-ruby/models/accounting/currencies.rb +25 -11
  58. data/lib/xero-ruby/models/accounting/currency.rb +25 -11
  59. data/lib/xero-ruby/models/accounting/currency_code.rb +1 -2
  60. data/lib/xero-ruby/models/accounting/element.rb +25 -11
  61. data/lib/xero-ruby/models/accounting/employee.rb +25 -11
  62. data/lib/xero-ruby/models/accounting/employees.rb +25 -11
  63. data/lib/xero-ruby/models/accounting/error.rb +25 -11
  64. data/lib/xero-ruby/models/accounting/expense_claim.rb +25 -11
  65. data/lib/xero-ruby/models/accounting/expense_claims.rb +25 -11
  66. data/lib/xero-ruby/models/accounting/external_link.rb +25 -11
  67. data/lib/xero-ruby/models/accounting/history_record.rb +25 -11
  68. data/lib/xero-ruby/models/accounting/history_records.rb +25 -11
  69. data/lib/xero-ruby/models/accounting/import_summary.rb +25 -11
  70. data/lib/xero-ruby/models/accounting/import_summary_accounts.rb +33 -19
  71. data/lib/xero-ruby/models/accounting/import_summary_object.rb +25 -11
  72. data/lib/xero-ruby/models/accounting/import_summary_organisation.rb +25 -11
  73. data/lib/xero-ruby/models/accounting/invoice.rb +37 -28
  74. data/lib/xero-ruby/models/accounting/invoice_reminder.rb +25 -11
  75. data/lib/xero-ruby/models/accounting/invoice_reminders.rb +25 -11
  76. data/lib/xero-ruby/models/accounting/invoices.rb +25 -11
  77. data/lib/xero-ruby/models/accounting/item.rb +25 -11
  78. data/lib/xero-ruby/models/accounting/items.rb +25 -11
  79. data/lib/xero-ruby/models/accounting/journal.rb +25 -11
  80. data/lib/xero-ruby/models/accounting/journal_line.rb +25 -11
  81. data/lib/xero-ruby/models/accounting/journals.rb +25 -11
  82. data/lib/xero-ruby/models/accounting/line_amount_types.rb +1 -2
  83. data/lib/xero-ruby/models/accounting/line_item.rb +36 -12
  84. data/lib/xero-ruby/models/accounting/line_item_tracking.rb +25 -11
  85. data/lib/xero-ruby/models/accounting/linked_transaction.rb +25 -11
  86. data/lib/xero-ruby/models/accounting/linked_transactions.rb +25 -11
  87. data/lib/xero-ruby/models/accounting/manual_journal.rb +25 -11
  88. data/lib/xero-ruby/models/accounting/manual_journal_line.rb +25 -11
  89. data/lib/xero-ruby/models/accounting/manual_journals.rb +25 -11
  90. data/lib/xero-ruby/models/accounting/online_invoice.rb +25 -11
  91. data/lib/xero-ruby/models/accounting/online_invoices.rb +25 -11
  92. data/lib/xero-ruby/models/accounting/organisation.rb +26 -14
  93. data/lib/xero-ruby/models/accounting/organisations.rb +25 -11
  94. data/lib/xero-ruby/models/accounting/overpayment.rb +25 -11
  95. data/lib/xero-ruby/models/accounting/overpayments.rb +25 -11
  96. data/lib/xero-ruby/models/accounting/payment.rb +36 -12
  97. data/lib/xero-ruby/models/accounting/payment_delete.rb +25 -11
  98. data/lib/xero-ruby/models/accounting/payment_service.rb +25 -11
  99. data/lib/xero-ruby/models/accounting/payment_services.rb +25 -11
  100. data/lib/xero-ruby/models/accounting/payment_term.rb +25 -11
  101. data/lib/xero-ruby/models/accounting/payment_term_type.rb +1 -2
  102. data/lib/xero-ruby/models/accounting/payments.rb +25 -11
  103. data/lib/xero-ruby/models/accounting/phone.rb +25 -11
  104. data/lib/xero-ruby/models/accounting/prepayment.rb +38 -12
  105. data/lib/xero-ruby/models/accounting/prepayments.rb +25 -11
  106. data/lib/xero-ruby/models/accounting/purchase.rb +25 -11
  107. data/lib/xero-ruby/models/accounting/purchase_order.rb +25 -11
  108. data/lib/xero-ruby/models/accounting/purchase_orders.rb +25 -11
  109. data/lib/xero-ruby/models/accounting/quote.rb +25 -11
  110. data/lib/xero-ruby/models/accounting/quote_line_amount_types.rb +1 -2
  111. data/lib/xero-ruby/models/accounting/quote_status_codes.rb +1 -2
  112. data/lib/xero-ruby/models/accounting/quotes.rb +25 -11
  113. data/lib/xero-ruby/models/accounting/receipt.rb +25 -11
  114. data/lib/xero-ruby/models/accounting/receipts.rb +25 -11
  115. data/lib/xero-ruby/models/accounting/repeating_invoice.rb +25 -11
  116. data/lib/xero-ruby/models/accounting/repeating_invoices.rb +25 -11
  117. data/lib/xero-ruby/models/accounting/report.rb +26 -22
  118. data/lib/xero-ruby/models/accounting/report_attribute.rb +25 -11
  119. data/lib/xero-ruby/models/accounting/report_cell.rb +25 -11
  120. data/lib/xero-ruby/models/accounting/report_fields.rb +25 -11
  121. data/lib/xero-ruby/models/accounting/report_row.rb +25 -11
  122. data/lib/xero-ruby/models/accounting/report_rows.rb +25 -11
  123. data/lib/xero-ruby/models/accounting/report_with_row.rb +26 -12
  124. data/lib/xero-ruby/models/accounting/report_with_rows.rb +25 -11
  125. data/lib/xero-ruby/models/accounting/reports.rb +25 -11
  126. data/lib/xero-ruby/models/accounting/request_empty.rb +25 -11
  127. data/lib/xero-ruby/models/accounting/row_type.rb +1 -2
  128. data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +25 -11
  129. data/lib/xero-ruby/models/accounting/schedule.rb +25 -11
  130. data/lib/xero-ruby/models/accounting/setup.rb +25 -11
  131. data/lib/xero-ruby/models/accounting/tax_component.rb +25 -11
  132. data/lib/xero-ruby/models/accounting/tax_rate.rb +25 -11
  133. data/lib/xero-ruby/models/accounting/tax_rates.rb +25 -11
  134. data/lib/xero-ruby/models/accounting/tax_type.rb +1 -2
  135. data/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +25 -11
  136. data/lib/xero-ruby/models/accounting/time_zone.rb +1 -2
  137. data/lib/xero-ruby/models/accounting/tracking_categories.rb +25 -11
  138. data/lib/xero-ruby/models/accounting/tracking_category.rb +25 -11
  139. data/lib/xero-ruby/models/accounting/tracking_option.rb +25 -11
  140. data/lib/xero-ruby/models/accounting/tracking_options.rb +25 -11
  141. data/lib/xero-ruby/models/accounting/user.rb +25 -11
  142. data/lib/xero-ruby/models/accounting/users.rb +25 -11
  143. data/lib/xero-ruby/models/accounting/validation_error.rb +25 -11
  144. data/lib/xero-ruby/models/assets/asset.rb +25 -11
  145. data/lib/xero-ruby/models/assets/asset_status.rb +1 -2
  146. data/lib/xero-ruby/models/assets/asset_status_query_param.rb +1 -2
  147. data/lib/xero-ruby/models/assets/asset_type.rb +25 -11
  148. data/lib/xero-ruby/models/assets/assets.rb +25 -11
  149. data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +25 -11
  150. data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +25 -11
  151. data/lib/xero-ruby/models/assets/error.rb +25 -11
  152. data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +26 -12
  153. data/lib/xero-ruby/models/assets/pagination.rb +25 -11
  154. data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +26 -12
  155. data/lib/xero-ruby/models/assets/setting.rb +25 -11
  156. data/lib/xero-ruby/models/files/association.rb +25 -11
  157. data/lib/xero-ruby/models/files/file_object.rb +25 -11
  158. data/lib/xero-ruby/models/files/files.rb +25 -11
  159. data/lib/xero-ruby/models/files/folder.rb +25 -11
  160. data/lib/xero-ruby/models/files/folders.rb +25 -11
  161. data/lib/xero-ruby/models/files/object_group.rb +1 -2
  162. data/lib/xero-ruby/models/files/object_type.rb +1 -2
  163. data/lib/xero-ruby/models/files/{inline_object.rb → upload_object.rb} +43 -14
  164. data/lib/xero-ruby/models/files/user.rb +25 -11
  165. data/lib/xero-ruby/models/payroll_au/account.rb +25 -11
  166. data/lib/xero-ruby/models/payroll_au/account_type.rb +1 -2
  167. data/lib/xero-ruby/models/payroll_au/allowance_type.rb +1 -2
  168. data/lib/xero-ruby/models/payroll_au/api_exception.rb +25 -11
  169. data/lib/xero-ruby/models/payroll_au/bank_account.rb +25 -11
  170. data/lib/xero-ruby/models/payroll_au/calendar_type.rb +1 -2
  171. data/lib/xero-ruby/models/payroll_au/deduction_line.rb +25 -16
  172. data/lib/xero-ruby/models/payroll_au/deduction_type.rb +25 -11
  173. data/lib/xero-ruby/models/payroll_au/deduction_type_calculation_type.rb +1 -2
  174. data/lib/xero-ruby/models/payroll_au/earnings_line.rb +25 -11
  175. data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +25 -11
  176. data/lib/xero-ruby/models/payroll_au/earnings_rate_calculation_type.rb +1 -2
  177. data/lib/xero-ruby/models/payroll_au/earnings_type.rb +2 -2
  178. data/lib/xero-ruby/models/payroll_au/employee.rb +25 -11
  179. data/lib/xero-ruby/models/payroll_au/employee_status.rb +1 -2
  180. data/lib/xero-ruby/models/payroll_au/employees.rb +25 -11
  181. data/lib/xero-ruby/models/payroll_au/employment_basis.rb +1 -2
  182. data/lib/xero-ruby/models/payroll_au/employment_termination_payment_type.rb +1 -2
  183. data/lib/xero-ruby/models/payroll_au/entitlement_final_pay_payout_type.rb +1 -2
  184. data/lib/xero-ruby/models/payroll_au/home_address.rb +25 -11
  185. data/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb +25 -11
  186. data/lib/xero-ruby/models/payroll_au/leave_application.rb +25 -11
  187. data/lib/xero-ruby/models/payroll_au/leave_applications.rb +25 -11
  188. data/lib/xero-ruby/models/payroll_au/leave_balance.rb +25 -11
  189. data/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +25 -11
  190. data/lib/xero-ruby/models/payroll_au/leave_line.rb +25 -11
  191. data/lib/xero-ruby/models/payroll_au/leave_line_calculation_type.rb +1 -2
  192. data/lib/xero-ruby/models/payroll_au/leave_lines.rb +25 -11
  193. data/lib/xero-ruby/models/payroll_au/leave_period.rb +25 -11
  194. data/lib/xero-ruby/models/payroll_au/leave_period_status.rb +1 -2
  195. data/lib/xero-ruby/models/payroll_au/leave_type.rb +25 -11
  196. data/lib/xero-ruby/models/payroll_au/leave_type_contribution_type.rb +1 -2
  197. data/lib/xero-ruby/models/payroll_au/manual_tax_type.rb +1 -2
  198. data/lib/xero-ruby/models/payroll_au/opening_balances.rb +25 -11
  199. data/lib/xero-ruby/models/payroll_au/pay_item.rb +25 -11
  200. data/lib/xero-ruby/models/payroll_au/pay_items.rb +25 -11
  201. data/lib/xero-ruby/models/payroll_au/pay_run.rb +25 -11
  202. data/lib/xero-ruby/models/payroll_au/pay_run_status.rb +1 -2
  203. data/lib/xero-ruby/models/payroll_au/pay_runs.rb +25 -11
  204. data/lib/xero-ruby/models/payroll_au/pay_template.rb +25 -11
  205. data/lib/xero-ruby/models/payroll_au/payment_frequency_type.rb +1 -2
  206. data/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +25 -11
  207. data/lib/xero-ruby/models/payroll_au/payroll_calendars.rb +25 -11
  208. data/lib/xero-ruby/models/payroll_au/payslip.rb +25 -11
  209. data/lib/xero-ruby/models/payroll_au/payslip_lines.rb +25 -11
  210. data/lib/xero-ruby/models/payroll_au/payslip_object.rb +25 -11
  211. data/lib/xero-ruby/models/payroll_au/payslip_summary.rb +25 -11
  212. data/lib/xero-ruby/models/payroll_au/payslips.rb +25 -11
  213. data/lib/xero-ruby/models/payroll_au/rate_type.rb +1 -2
  214. data/lib/xero-ruby/models/payroll_au/reimbursement_line.rb +25 -11
  215. data/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb +25 -11
  216. data/lib/xero-ruby/models/payroll_au/reimbursement_type.rb +25 -11
  217. data/lib/xero-ruby/models/payroll_au/residency_status.rb +1 -2
  218. data/lib/xero-ruby/models/payroll_au/settings.rb +25 -11
  219. data/lib/xero-ruby/models/payroll_au/settings_object.rb +25 -11
  220. data/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb +25 -11
  221. data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb +25 -11
  222. data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb +25 -11
  223. data/lib/xero-ruby/models/payroll_au/state.rb +1 -2
  224. data/lib/xero-ruby/models/payroll_au/super_fund.rb +25 -11
  225. data/lib/xero-ruby/models/payroll_au/super_fund_product.rb +25 -11
  226. data/lib/xero-ruby/models/payroll_au/super_fund_products.rb +25 -11
  227. data/lib/xero-ruby/models/payroll_au/super_fund_type.rb +1 -2
  228. data/lib/xero-ruby/models/payroll_au/super_funds.rb +25 -11
  229. data/lib/xero-ruby/models/payroll_au/super_line.rb +26 -12
  230. data/lib/xero-ruby/models/payroll_au/super_membership.rb +26 -12
  231. data/lib/xero-ruby/models/payroll_au/superannuation_calculation_type.rb +1 -2
  232. data/lib/xero-ruby/models/payroll_au/superannuation_contribution_type.rb +1 -2
  233. data/lib/xero-ruby/models/payroll_au/superannuation_line.rb +25 -11
  234. data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +25 -11
  235. data/lib/xero-ruby/models/payroll_au/tax_line.rb +25 -11
  236. data/lib/xero-ruby/models/payroll_au/tfn_exemption_type.rb +1 -2
  237. data/lib/xero-ruby/models/payroll_au/timesheet.rb +25 -11
  238. data/lib/xero-ruby/models/payroll_au/timesheet_line.rb +25 -11
  239. data/lib/xero-ruby/models/payroll_au/timesheet_object.rb +25 -11
  240. data/lib/xero-ruby/models/payroll_au/timesheet_status.rb +1 -2
  241. data/lib/xero-ruby/models/payroll_au/timesheets.rb +25 -11
  242. data/lib/xero-ruby/models/payroll_au/validation_error.rb +25 -11
  243. data/lib/xero-ruby/models/payroll_nz/account.rb +24 -10
  244. data/lib/xero-ruby/models/payroll_nz/accounts.rb +24 -10
  245. data/lib/xero-ruby/models/payroll_nz/address.rb +24 -10
  246. data/lib/xero-ruby/models/payroll_nz/bank_account.rb +24 -10
  247. data/lib/xero-ruby/models/payroll_nz/benefit.rb +24 -10
  248. data/lib/xero-ruby/models/payroll_nz/calendar_type.rb +0 -1
  249. data/lib/xero-ruby/models/payroll_nz/deduction.rb +24 -10
  250. data/lib/xero-ruby/models/payroll_nz/deduction_line.rb +24 -10
  251. data/lib/xero-ruby/models/payroll_nz/deduction_object.rb +24 -10
  252. data/lib/xero-ruby/models/payroll_nz/deductions.rb +24 -10
  253. data/lib/xero-ruby/models/payroll_nz/earnings_line.rb +25 -11
  254. data/lib/xero-ruby/models/payroll_nz/earnings_order.rb +24 -10
  255. data/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb +24 -10
  256. data/lib/xero-ruby/models/payroll_nz/earnings_orders.rb +24 -10
  257. data/lib/xero-ruby/models/payroll_nz/earnings_rate.rb +24 -10
  258. data/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb +24 -10
  259. data/lib/xero-ruby/models/payroll_nz/earnings_rates.rb +24 -10
  260. data/lib/xero-ruby/models/payroll_nz/earnings_template.rb +24 -10
  261. data/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb +24 -10
  262. data/lib/xero-ruby/models/payroll_nz/employee.rb +24 -10
  263. data/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb +24 -10
  264. data/lib/xero-ruby/models/payroll_nz/employee_leave.rb +24 -10
  265. data/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb +24 -10
  266. data/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb +24 -10
  267. data/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb +24 -10
  268. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +24 -10
  269. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb +24 -10
  270. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +24 -10
  271. data/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb +24 -10
  272. data/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb +24 -10
  273. data/lib/xero-ruby/models/payroll_nz/employee_leaves.rb +24 -10
  274. data/lib/xero-ruby/models/payroll_nz/employee_object.rb +24 -10
  275. data/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb +24 -10
  276. data/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb +24 -10
  277. data/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +24 -10
  278. data/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb +24 -10
  279. data/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb +24 -10
  280. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb +24 -10
  281. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb +24 -10
  282. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb +24 -10
  283. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb +24 -10
  284. data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb +25 -11
  285. data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb +24 -10
  286. data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb +24 -10
  287. data/lib/xero-ruby/models/payroll_nz/employee_tax.rb +24 -10
  288. data/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb +24 -10
  289. data/lib/xero-ruby/models/payroll_nz/employees.rb +24 -10
  290. data/lib/xero-ruby/models/payroll_nz/employment.rb +24 -10
  291. data/lib/xero-ruby/models/payroll_nz/employment_object.rb +24 -10
  292. data/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb +24 -10
  293. data/lib/xero-ruby/models/payroll_nz/invalid_field.rb +24 -10
  294. data/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb +24 -10
  295. data/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb +25 -11
  296. data/lib/xero-ruby/models/payroll_nz/leave_period.rb +24 -10
  297. data/lib/xero-ruby/models/payroll_nz/leave_periods.rb +24 -10
  298. data/lib/xero-ruby/models/payroll_nz/leave_type.rb +24 -10
  299. data/lib/xero-ruby/models/payroll_nz/leave_type_object.rb +24 -10
  300. data/lib/xero-ruby/models/payroll_nz/leave_types.rb +24 -10
  301. data/lib/xero-ruby/models/payroll_nz/pagination.rb +24 -10
  302. data/lib/xero-ruby/models/payroll_nz/pay_run.rb +24 -10
  303. data/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb +24 -10
  304. data/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb +24 -10
  305. data/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb +24 -10
  306. data/lib/xero-ruby/models/payroll_nz/pay_run_object.rb +24 -10
  307. data/lib/xero-ruby/models/payroll_nz/pay_runs.rb +24 -10
  308. data/lib/xero-ruby/models/payroll_nz/pay_slip.rb +24 -10
  309. data/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb +24 -10
  310. data/lib/xero-ruby/models/payroll_nz/pay_slips.rb +24 -10
  311. data/lib/xero-ruby/models/payroll_nz/payment_line.rb +24 -10
  312. data/lib/xero-ruby/models/payroll_nz/payment_method.rb +24 -10
  313. data/lib/xero-ruby/models/payroll_nz/payment_method_object.rb +24 -10
  314. data/lib/xero-ruby/models/payroll_nz/problem.rb +24 -10
  315. data/lib/xero-ruby/models/payroll_nz/reimbursement.rb +24 -10
  316. data/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb +24 -10
  317. data/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb +24 -10
  318. data/lib/xero-ruby/models/payroll_nz/reimbursements.rb +24 -10
  319. data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +28 -13
  320. data/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb +24 -10
  321. data/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb +24 -10
  322. data/lib/xero-ruby/models/payroll_nz/settings.rb +24 -10
  323. data/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb +24 -10
  324. data/lib/xero-ruby/models/payroll_nz/statutory_deduction_category.rb +0 -1
  325. data/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb +24 -10
  326. data/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb +24 -10
  327. data/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb +24 -10
  328. data/lib/xero-ruby/models/payroll_nz/superannuation_line.rb +25 -11
  329. data/lib/xero-ruby/models/payroll_nz/superannuation_object.rb +24 -10
  330. data/lib/xero-ruby/models/payroll_nz/superannuations.rb +24 -10
  331. data/lib/xero-ruby/models/payroll_nz/tax_code.rb +0 -1
  332. data/lib/xero-ruby/models/payroll_nz/tax_line.rb +24 -10
  333. data/lib/xero-ruby/models/payroll_nz/tax_settings.rb +24 -10
  334. data/lib/xero-ruby/models/payroll_nz/timesheet.rb +28 -13
  335. data/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb +25 -11
  336. data/lib/xero-ruby/models/payroll_nz/timesheet_line.rb +24 -10
  337. data/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb +24 -10
  338. data/lib/xero-ruby/models/payroll_nz/timesheet_object.rb +24 -10
  339. data/lib/xero-ruby/models/payroll_nz/timesheets.rb +24 -10
  340. data/lib/xero-ruby/models/payroll_nz/tracking_categories.rb +24 -10
  341. data/lib/xero-ruby/models/payroll_nz/tracking_category.rb +24 -10
  342. data/lib/xero-ruby/models/payroll_uk/account.rb +24 -10
  343. data/lib/xero-ruby/models/payroll_uk/accounts.rb +24 -10
  344. data/lib/xero-ruby/models/payroll_uk/address.rb +24 -10
  345. data/lib/xero-ruby/models/payroll_uk/bank_account.rb +24 -10
  346. data/lib/xero-ruby/models/payroll_uk/benefit.rb +24 -10
  347. data/lib/xero-ruby/models/payroll_uk/benefit_line.rb +24 -10
  348. data/lib/xero-ruby/models/payroll_uk/benefit_object.rb +24 -10
  349. data/lib/xero-ruby/models/payroll_uk/benefits.rb +24 -10
  350. data/lib/xero-ruby/models/payroll_uk/court_order_line.rb +24 -10
  351. data/lib/xero-ruby/models/payroll_uk/deduction.rb +24 -10
  352. data/lib/xero-ruby/models/payroll_uk/deduction_line.rb +24 -10
  353. data/lib/xero-ruby/models/payroll_uk/deduction_object.rb +24 -10
  354. data/lib/xero-ruby/models/payroll_uk/deductions.rb +24 -10
  355. data/lib/xero-ruby/models/payroll_uk/earnings_line.rb +24 -10
  356. data/lib/xero-ruby/models/payroll_uk/earnings_order.rb +24 -10
  357. data/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb +24 -10
  358. data/lib/xero-ruby/models/payroll_uk/earnings_orders.rb +24 -10
  359. data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +34 -12
  360. data/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb +24 -10
  361. data/lib/xero-ruby/models/payroll_uk/earnings_rates.rb +24 -10
  362. data/lib/xero-ruby/models/payroll_uk/earnings_template.rb +24 -10
  363. data/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb +24 -10
  364. data/lib/xero-ruby/models/payroll_uk/employee.rb +24 -10
  365. data/lib/xero-ruby/models/payroll_uk/employee_leave.rb +24 -10
  366. data/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb +24 -10
  367. data/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb +24 -10
  368. data/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb +24 -10
  369. data/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +24 -10
  370. data/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb +24 -10
  371. data/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb +24 -10
  372. data/lib/xero-ruby/models/payroll_uk/employee_leaves.rb +24 -10
  373. data/lib/xero-ruby/models/payroll_uk/employee_object.rb +24 -10
  374. data/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb +24 -10
  375. data/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb +24 -10
  376. data/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +24 -10
  377. data/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb +24 -10
  378. data/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb +24 -10
  379. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +24 -10
  380. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb +24 -10
  381. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +24 -10
  382. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb +24 -10
  383. data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb +25 -11
  384. data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb +24 -10
  385. data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb +24 -10
  386. data/lib/xero-ruby/models/payroll_uk/employee_tax.rb +24 -10
  387. data/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb +24 -10
  388. data/lib/xero-ruby/models/payroll_uk/employees.rb +24 -10
  389. data/lib/xero-ruby/models/payroll_uk/employment.rb +24 -10
  390. data/lib/xero-ruby/models/payroll_uk/employment_object.rb +24 -10
  391. data/lib/xero-ruby/models/payroll_uk/invalid_field.rb +24 -10
  392. data/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb +24 -10
  393. data/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb +24 -10
  394. data/lib/xero-ruby/models/payroll_uk/leave_period.rb +24 -10
  395. data/lib/xero-ruby/models/payroll_uk/leave_periods.rb +24 -10
  396. data/lib/xero-ruby/models/payroll_uk/leave_type.rb +24 -10
  397. data/lib/xero-ruby/models/payroll_uk/leave_type_object.rb +24 -10
  398. data/lib/xero-ruby/models/payroll_uk/leave_types.rb +24 -10
  399. data/lib/xero-ruby/models/payroll_uk/pagination.rb +24 -10
  400. data/lib/xero-ruby/models/payroll_uk/pay_run.rb +24 -10
  401. data/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb +24 -10
  402. data/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb +24 -10
  403. data/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb +24 -10
  404. data/lib/xero-ruby/models/payroll_uk/pay_run_object.rb +24 -10
  405. data/lib/xero-ruby/models/payroll_uk/pay_runs.rb +24 -10
  406. data/lib/xero-ruby/models/payroll_uk/payment_line.rb +24 -10
  407. data/lib/xero-ruby/models/payroll_uk/payment_method.rb +24 -10
  408. data/lib/xero-ruby/models/payroll_uk/payment_method_object.rb +24 -10
  409. data/lib/xero-ruby/models/payroll_uk/payslip.rb +24 -10
  410. data/lib/xero-ruby/models/payroll_uk/payslip_object.rb +24 -10
  411. data/lib/xero-ruby/models/payroll_uk/payslips.rb +24 -10
  412. data/lib/xero-ruby/models/payroll_uk/problem.rb +24 -10
  413. data/lib/xero-ruby/models/payroll_uk/reimbursement.rb +24 -10
  414. data/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb +24 -10
  415. data/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb +24 -10
  416. data/lib/xero-ruby/models/payroll_uk/reimbursements.rb +24 -10
  417. data/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +27 -12
  418. data/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb +24 -10
  419. data/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb +24 -10
  420. data/lib/xero-ruby/models/payroll_uk/settings.rb +24 -10
  421. data/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb +24 -10
  422. data/lib/xero-ruby/models/payroll_uk/statutory_deduction_category.rb +0 -1
  423. data/lib/xero-ruby/models/payroll_uk/tax_line.rb +24 -10
  424. data/lib/xero-ruby/models/payroll_uk/timesheet.rb +25 -11
  425. data/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb +24 -10
  426. data/lib/xero-ruby/models/payroll_uk/timesheet_line.rb +24 -10
  427. data/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb +24 -10
  428. data/lib/xero-ruby/models/payroll_uk/timesheet_object.rb +24 -10
  429. data/lib/xero-ruby/models/payroll_uk/timesheets.rb +24 -10
  430. data/lib/xero-ruby/models/payroll_uk/tracking_categories.rb +24 -10
  431. data/lib/xero-ruby/models/payroll_uk/tracking_category.rb +24 -10
  432. data/lib/xero-ruby/models/projects/amount.rb +24 -10
  433. data/lib/xero-ruby/models/projects/charge_type.rb +0 -1
  434. data/lib/xero-ruby/models/projects/currency_code.rb +0 -1
  435. data/lib/xero-ruby/models/projects/error.rb +24 -10
  436. data/lib/xero-ruby/models/projects/pagination.rb +24 -10
  437. data/lib/xero-ruby/models/projects/project.rb +24 -10
  438. data/lib/xero-ruby/models/projects/project_create_or_update.rb +24 -10
  439. data/lib/xero-ruby/models/projects/project_patch.rb +24 -10
  440. data/lib/xero-ruby/models/projects/project_status.rb +0 -1
  441. data/lib/xero-ruby/models/projects/project_user.rb +24 -10
  442. data/lib/xero-ruby/models/projects/project_users.rb +24 -10
  443. data/lib/xero-ruby/models/projects/projects.rb +24 -10
  444. data/lib/xero-ruby/models/projects/task.rb +24 -10
  445. data/lib/xero-ruby/models/projects/task_create_or_update.rb +24 -10
  446. data/lib/xero-ruby/models/projects/tasks.rb +24 -10
  447. data/lib/xero-ruby/models/projects/time_entries.rb +24 -10
  448. data/lib/xero-ruby/models/projects/time_entry.rb +27 -12
  449. data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +24 -10
  450. data/lib/xero-ruby/string_serialization.rb +52 -0
  451. data/lib/xero-ruby/version.rb +3 -3
  452. data/lib/xero-ruby/where.rb +65 -0
  453. data/spec/api_client_spec.rb +292 -14
  454. data/spec/api_error_spec.rb +45 -0
  455. data/spec/configuration_spec.rb +26 -16
  456. data/spec/files/models/inline_object_spec.rb +3 -3
  457. data/spec/helper_methods_spec.rb +110 -0
  458. data/spec/where_spec.rb +82 -0
  459. metadata +43 -12
  460. data/spec/files/models/file_response204_spec.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9971f81d76c9c1b3d6533ecb022cf10a28e43ef1e13ff80e3e4358e70d6b528c
4
- data.tar.gz: ea190c78416aa8fd3a4bfdbec2be51e01c4be862b6fc9fb591d4103c24754bf0
3
+ metadata.gz: fcc8e88d077eb5b42f9a9c8a206ce6c7fb62589e7179932764a70cc28c3f821a
4
+ data.tar.gz: 8c25945749aaca49892462186f749701255022d05ea498645a3b1e59c10a5e52
5
5
  SHA512:
6
- metadata.gz: 6119180c2690484854f32fdef63d9b7e76ad7e78c5b5487174fc41cf7df827427d77dc901c9f10edf9a710898833a11c2aa7542c5ac3cc0abdf5319606f8c559
7
- data.tar.gz: 73585f179d4d148dfc47bef5dadf1ea7586c4872ab827aa11a0116e3379ae4a2f83aa01fd941a78eefddd37895711af52c06037344d424e91135b78b2bd3b6b6
6
+ metadata.gz: 4196ec14ceaa6179bbbedb856b447e7af947ba96e4af24ab8130835af5660a8e6787fbf3261c3f6c5c605d0f81436559bd37e1e0a7252bab42feb752f4634d31
7
+ data.tar.gz: c99e89b1f45563b72023ad5d5ceb3632fe5661068ad5ee89d672194fca72ddccbb1967d9f9796098d12ff9b649f03dfa5b26d3eb08b3daf756bef0e3a7f3fe5f
data/README.md CHANGED
@@ -1,176 +1,228 @@
1
1
  # xero-ruby
2
- Xero Ruby SDK for OAuth 2.0 generated from [Xero API OpenAPI Spec](https://github.com/XeroAPI/Xero-OpenAPI).
3
-
4
- [![RubyGem](https://img.shields.io/badge/xero--ruby%20gem-v0.2.4-brightgreen)](https://rubygems.org/gems/xero-ruby)
5
-
6
- # Documentation
7
- Xero Ruby SDK supports Xero's OAuth2.0 authentication and supports the following Xero API sets.
8
-
9
- ## API Client Docs
10
- * [Accounting Api Docs](/docs/accounting/AccountingApi.md)
11
- * [Asset Api Docs](/docs/assets/AssetApi.md)
12
- * [Project Api Docs](docs/projects/ProjectApi.md)
13
- * [File Api Docs](docs/files/FileApi.md)
14
- * [Payroll Docs (AU)](docs/payroll_au/PayrollAuApi.md)
15
- * [Payroll Docs (NZ)](docs/payroll_nz/PayrollNzApi.md)
16
- * [Payroll Docs (UK)](docs/payroll_uk/PayrollUkApi.md)
17
-
18
- ## API Model Docs
19
- * [Accounting Models Docs](/docs/accounting/)
20
- * [Asset Models Docs](/docs/assets/)
21
- * [Project Models Docs](/docs/projects/)
22
- * [File Models Docs](/docs/files/)
23
- * [Payroll Models (AU)](docs/payroll_au/)
24
- * [Payroll Models (NZ)](docs/payroll_nz/)
25
- * [Payroll Models (UK)](docs/payroll_uk/)
26
-
27
- ## Sample Apps
28
- We have two apps showing SDK usage.
29
- * https://github.com/XeroAPI/xero-ruby-oauth2-starter (**Sinatra** - session based / getting started)
30
- * https://github.com/XeroAPI/xero-ruby-oauth2-app (**Rails** - token management / full examples)
31
-
32
- ![sample-app](https://i.imgur.com/OOEn55G.png)
33
-
34
- ## Looking for OAuth 1.0a support?
35
- Check out the [Xeroizer](https://github.com/waynerobinson/xeroizer) gem (maintained by community).
36
-
37
- ---
38
- ## Installation
39
- To install this gem to your current gemset.
2
+ [![Gem Version](https://badge.fury.io/rb/xero-ruby.svg)](https://badge.fury.io/rb/xero-ruby)
3
+ [![Github forks](https://img.shields.io/github/forks/XeroAPI/xero-ruby.svg)](https://github.com/XeroAPI/xero-ruby/network)
4
+ [![Github stars](https://img.shields.io/github/stars/XeroAPI/xero-ruby.svg)](https://github.com/XeroAPI/xero-ruby/stargazers)
5
+ ![total downloads](https://ruby-gem-downloads-badge.herokuapp.com/xero-ruby?type=total)
6
+
7
+ The xero-ruby SDK makes it easy for developers to access Xero's APIs in their Ruby code, and build robust applications and software using small business & general ledget accounting data.
8
+ # Table of Contents
9
+ - [API Client documentation](#api-client-documentation)
10
+ - [Sample Applications](#sample-applications)
11
+ - [Xero Account Requirements](#xero-account-requirements)
12
+ - [Installation](#installation)
13
+ - [Configuration](#configuration)
14
+ - [Authentication](#authentication)
15
+ - [Custom Connections](#custom-connections)
16
+ - [API Clients](#api-clients)
17
+ - [Helper Methods](#helper-methods)
18
+ - [Usage Examples](#usage-examples)
19
+ - [SDK conventions](#sdk-conventions)
20
+ - [Contributing](#contributing)
21
+
22
+ <hr>
23
+
24
+ ## API Client documentation
25
+ This SDK supports full method coverage for the following Xero API sets:
26
+
27
+ | API Set | Description |
28
+ | --- | --- |
29
+ | [`Accounting`](https://xeroapi.github.io/xero-ruby/accounting/index.html) | The Accounting API exposes accounting functions of the main Xero application *(most commonly used)*
30
+ | [Assets](https://xeroapi.github.io/xero-ruby/assets/index.html) | The Assets API exposes fixed asset related functions of the Xero Accounting application |
31
+ | [Files](https://xeroapi.github.io/xero-ruby/files/index.html) | The Files API provides access to the files, folders, and the association of files within a Xero organisation |
32
+ | [Projects](https://xeroapi.github.io/xero-ruby/projects/index.html) | Xero Projects allows businesses to track time and costs on projects/jobs and report on profitability |
33
+ | [Payroll (AU)](https://xeroapi.github.io/xero-ruby/payroll_au/index.html) | The (AU) Payroll API exposes payroll related functions of the payroll Xero application |
34
+ | [Payroll (UK)](https://xeroapi.github.io/xero-ruby/payroll_uk/index.html) | The (UK) Payroll API exposes payroll related functions of the payroll Xero application |
35
+ | [Payroll (NZ)](https://xeroapi.github.io/xero-ruby/payroll_nz/index.html) | The (NZ) Payroll API exposes payroll related functions of the payroll Xero application |
36
+ | [`Ruby Models`](/docs/) | Directory of markdown files, describing the object models for all supported API sets |
37
+
38
+ <img src="https://i.imgur.com/0MsvkGB.png" alt="drawing" width="350"/>
39
+
40
+ <hr>
41
+
42
+ ## Sample Applications
43
+ Sample apps can get you started quickly with simple auth flows to advanced usage.
44
+ | Sample App | Description | Screenshot |
45
+ | --- | --- | --- |
46
+ | [`xero-ruby-oauth2-starter`](https://github.com/XeroAPI/Xero-ruby-oauth2-starter) | A Sinatra application showing the basic getting started code to work with the sdk | <img src="https://i.imgur.com/9H4F98M.png" alt="drawing" width="300"/>
47
+ | [`xero-ruby-oauth2-app`](https://github.com/XeroAPI/Xero-ruby-oauth2-app) | Complete rails app with +95% of api set examples, complex filters, pagination, and user/token management in postgres | <img src="https://i.imgur.com/XsAp9Ww.png" alt="drawing" width="500"/>
48
+ | [`xero-ruby-custom-connections-starter`](https://github.com/XeroAPI/xero-ruby-custom-connections-starter) | A getting started Sinatra app showing Custom Connections - a Xero [premium option](https://developer.xero.com/documentation/oauth2/custom-connections) for building M2M integrations to a single org | <img src="https://i.imgur.com/YEkScui.png" alt="drawing" width="300"/>
49
+
50
+ <hr>
51
+
52
+ ## Xero Account Requirements
53
+ - Create a [free Xero user account](https://www.xero.com/us/signup/api/)
54
+ - Login to your Xero developer [dashboard](https://developer.xero.com/app/manage) and create an API application
55
+ - Copy the credentials from your API app and store them using a secure ENV variable strategy
56
+ - Decide the [neccesary scopes](https://developer.xero.com/documentation/oauth2/scopes) for your app's functionality
57
+
58
+ # Installation
59
+ To install this gem to your project
40
60
  ```
41
61
  gem install 'xero-ruby'
42
62
  ```
43
- Or add to your gemfile and run `bundle install`.
63
+ Or add to your gemfile and run `bundle install`
44
64
  ```
45
65
  gem 'xero-ruby'
46
66
  ```
47
67
 
48
- ## Getting Started
49
- * Create a [free Xero user account](https://www.xero.com/us/signup/api/)
50
- * Login to your Xero developer [/myapps](https://developer.xero.com/myapps) dashboard & create an API application and note your API app's credentials.
51
-
52
- ### Creating a Client
53
- * Get the credential values from an API application at https://developer.xero.com/myapps/.
54
- * Include [neccesary scopes](https://developer.xero.com/documentation/oauth2/scopes) as comma seperated list
55
- * example => "`openid profile email accounting.transactions accounting.settings`"
56
- ```
57
- require 'xero-ruby'
58
- ```
68
+ ---
69
+ ## Configuration
59
70
  ```ruby
71
+ require 'xero-ruby'
72
+
60
73
  creds = {
61
74
  client_id: ENV['CLIENT_ID'],
62
75
  client_secret: ENV['CLIENT_SECRET'],
63
76
  redirect_uri: ENV['REDIRECT_URI'],
64
- scopes: ENV['SCOPES']
77
+ scopes: ENV['SCOPES'],
78
+ state: "Optional value to pass through auth flow"
65
79
  }
66
80
  xero_client ||= XeroRuby::ApiClient.new(credentials: creds)
67
81
  ```
68
82
 
69
- ## User Authorization & Callback
70
- All API requests require a valid access token to be set on the client.
83
+ For additional [config](/lib/xero-ruby/configuration.rb) options you can pass an optional named parameter `config: {}`
84
+ ```ruby
85
+ config = { timeout: 30, debugging: true }
86
+ @xero_client ||= XeroRuby::ApiClient.new(credentials: creds, config: config)
87
+ ```
88
+ ---
89
+ ## Authentication
90
+ All API requests go through Xero's OAuth2.0 gateway and require a valid `access_token` to be set on the `xero_client`, which autmoatically appends the `access_token` [JWT](https://jwt.io/) to the header of each request.
91
+
92
+ If you are making an API call for the first time:
71
93
 
72
- To generate a valid `token_set` send a user to the `authorization_url`:
94
+ 1. Send the user to the Xero authorization URL
73
95
  ```ruby
74
96
  @authorization_url = xero_client.authorization_url
75
-
76
97
  redirect_to @authorization_url
77
98
  ```
78
-
79
- Xero will then redirect back to the URI defined in your ENV['REDIRECT_URI'] variable.
80
- *This must match **exactly** with the variable in your /myapps dashboard.*
81
-
82
- In your callback route catch, calling `get_token_set_from_callback` will exchange the temp code in your params, with a valid `token_set` that you can use to make API calls.
99
+ 2. The user will authorize your API application and be sent to your `redirect_uri`
83
100
  ```ruby
84
- # => http://localhost:3000/oauth/callback
85
-
86
- token_set = xero_client.get_token_set_from_callback(params)
87
-
88
- # save token_set JSON in a datastore in relation to the user authentication
101
+ ENV['REDIRECT_URI']
102
+ => /xero-callback?code=xyz123
89
103
  ```
90
-
91
- ## Making API calls once you have a token_set
92
- For use outside of the initial auth flow, setup the client by passing the whole token_set to `refresh_token_set` or `set_token_set`.
104
+ 3. You exchange a temporary `authorization_code` for a valid `token_set`
93
105
  ```ruby
94
- xero_client.refresh_token_set(user.token_set)
95
-
96
- xero_client.set_token_set(user.token_set)
106
+ @token_set = @xero_client.get_token_set_from_callback(params)
107
+ # save the @token_set
97
108
  ```
98
- A `token_set` contains data about your API connection most importantly :
99
- * `access_token`
100
- * `refresh_token`
101
- * `expiry`
102
109
 
103
- **An `access_token` is valid 30 minutes and a `refresh_token` is valid for 60 days**
110
+ It is reccomended that you store this token set JSON in a datastore in relation to the user who has authenticated the Xero API connection. Each time you want to call the Xero API, you will need to access the previously generated token set, initialize it on the SDK `xero_client`, and refresh the `access_token` prior to making API calls.
111
+
112
+ ### Token Set
113
+ | key | value | description |
114
+ | --- | --- | --- |
115
+ | id_token: | "xxx.yyy.zzz" | [OpenID Connect](https://openid.net/connect/) token returned if `openid profile email` scopes accepted |
116
+ | access_token: | "xxx.yyy.zzz" | [Bearer token](https://oauth.net/2/jwt/) with a 30 minute expiration required for all API calls |
117
+ | expires_in: | 1800 | Time in seconds till the token expires - 1800s is 30m |
118
+ | refresh_token: | "XXXXXXX" | Alphanumeric string used to obtain a new Token Set w/ a fresh access_token - 60 day expiry |
119
+ | scope: | "email profile openid accounting.transactions offline_access" | The Xero permissions that are embedded in the `access_token` |
104
120
 
105
- Example Token set:
106
- > You can decode the `id_token` & `access_token` for additional metadata by using a [decoding library](https://github.com/jwt/ruby-jwt):
107
- ```json
121
+ Example Token Set JSON:
122
+ ```
108
123
  {
109
124
  "id_token": "xxx.yyy.zz",
110
125
  "access_token": "xxx.yyy.zzz",
111
126
  "expires_in": 1800,
112
127
  "token_type": "Bearer",
113
- "refresh_token": "xxxxxx",
128
+ "refresh_token": "xxxxxxxxx",
114
129
  "scope": "email profile openid accounting.transactions offline_access"
115
130
  }
116
131
  ```
132
+ ---
133
+ ## Custom Connections
134
+
135
+ Custom Connections are a Xero [premium option](https://developer.xero.com/documentation/oauth2/custom-connections) used for building M2M integrations to a single organisation. A custom connection uses OAuth2.0's [`client_credentials`](https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/) grant which eliminates the step of exchanging the temporary code for a token set.
117
136
 
118
- ## Token & SDK Helpers
119
- Refresh/connection helpers
137
+ To use this SDK with a Custom Connections:
120
138
  ```ruby
121
- @token_set = xero_client.refresh_token_set(user.token_set)
122
-
123
- # Xero's tokens can potentially facilitate (n) org connections in a single token.
124
- # It is important to store the `tenantId` of the Organisation your user wants to read/write data.
125
-
126
- # The `updatedDateUtc` will show you the most recently authorized Tenant (AKA Organisation)
127
- connections = xero_client.connections
128
- [{
129
- "id" => "xxx-yyy-zzz",
130
- "tenantId" => "xxx-yyy-zzz",
131
- "tenantType" => "ORGANISATION",
132
- "tenantName" => "Demo Company (US)",
133
- "createdDateUtc" => "2019-11-01T20:08:03.0766400",
134
- "updatedDateUtc" => "2020-04-15T22:37:10.4943410"
135
- }]
136
-
137
- # disconnect an org from a user's connections. Pass the connection ['id'] not ['tenantId'].
138
- # Useful if you want to enforce only a single org connection per token.
139
- remaining_connections = xero_client.disconnect(connections[0]['id'])
140
-
141
- # set a refreshed token_set
142
- token_set = xero_client.set_token_set(user.token_set)
143
-
144
- # access token_set once it is set on the client
145
- token_set = xero_client.token_set
139
+ CREDENTIALS = {
140
+ client_id: ENV['CLIENT_ID'],
141
+ client_secret: ENV['CLIENT_SECRET'],
142
+ grant_type: 'client_credentials'
143
+ }
144
+
145
+ xero_client = XeroRuby::ApiClient.new(credentials: CREDENTIALS)
146
+
147
+ @token_set = xero_client.get_client_credentials_token
148
+ # save @token_set
149
+
150
+ @invoices = xero_client.accounting_api.get_invoices('').invoices
146
151
  ```
147
152
 
148
- Example token expiry helper
153
+ Because Custom Connections are only valid for a single organisation you don't need to pass the `xero-tenant-id` as the first parameter to every method.
154
+
155
+ However - due to the nature of how our SDK's are generated from our OpenAPI spec, the parameter remains which requires you to pass an empty string for now to use the SDK with a Custom Connection.
156
+
157
+ ---
158
+ ## API Clients
159
+ You can access the different API sets and their available methods through the following:
160
+
149
161
  ```ruby
150
- require 'jwt'
162
+ xero_client = XeroRuby::ApiClient.new(credentials: creds)
163
+
164
+ xero_client.accounting_api
165
+ xero_client.asset_api
166
+ xero_client.project_api
167
+ xero_client.files_api
168
+ xero_client.payroll_au_api
169
+ xero_client.payroll_nz_api
170
+ xero_client.payroll_uk_api
171
+ ```
172
+ ---
173
+ ## Helper Methods
151
174
 
152
- def token_expired?
153
- token_expiry = Time.at(decoded_access_token['exp'])
154
- token_expiry < Time.now
155
- end
175
+ Once you have a valid Token Set in your datastore, the next time you want to call the Xero API simply initialize a new `xero_client` and refresh the token set.
156
176
 
157
- def decoded_access_token
158
- JWT.decode(token_set['access_token'], nil, false)[0]
177
+ ```ruby
178
+ xero_client = XeroRuby::ApiClient.new(credentials: creds)
179
+
180
+ if xero_client.token_expired?
181
+ @token_set = xero_client.refresh_token_set(user.token_set)
182
+ else
183
+ @token_set = xero_client.set_token_set(user.token_set)
159
184
  end
160
- ```
161
185
 
162
- ## API Usage
186
+ # example strategy
187
+ user.token_set = @token_set if !@token_set["error"]
188
+ user.xero_connections = xero_client.connections
189
+ user.active_tenant_id = xero_client.last_connection
190
+ user.save!
191
+
192
+ xero_client.accounting_api.get_invoices(xero_client.last_connection['tenantId']).invoices
193
+ ```
163
194
 
195
+ This will set the access_token on the client and return the refreshed `token_set` that you need to save in your datastore to keep the connection alive until you or the user disconnect.
196
+
197
+ A full list of the SDK client's methods:
198
+
199
+ | method | description |
200
+ | --- | --- |
201
+ | xero_client.`authorization_url` | returns the authorize URL string to send a new user to for API authorization |
202
+ | xero_client.`get_token_set_from_callback`(params) | returns and generates a `token_set` from a temporary code for an `authorization_code` configured client only. Params are the url params. |
203
+ | xero_client.`get_client_credentials_token` | returns and generates a `token_set` for a `client_credentials` configured client only |
204
+ | xero_client.`refresh_token_set`(token_set) | returns a refreshed token_set |
205
+ | xero_client.`revoke_token`(token_set) | removes all a user's org connections and revokes the refresh_token |
206
+ | xero_client.`disconnect`(connection_id) | disconnects an org connection from a user's token permissions |
207
+ | xero_client.`connections` | returns an array of the user's currently connected Xero orgs |
208
+ | xero_client.`last_connection` | returns the `xero-tenant-id` of the most recently connected Xero org |
209
+ | xero_client.`set_token_set`(token_set) | returns a boolean and sets a token on the client - `token_set` containing an access_token & refresh_token |
210
+ | xero_client.`set_access_token`(access_token) | How you can set an `access_token` by itself |
211
+ | xero_client.`set_id_token`(id_token) | How you can set an `id_token` by itself |
212
+ | xero_client.`token_expired?` | returns a boolean if token_set['access_token'] is expired |
213
+ | xero_client.`token_set` | returns the token set if one is set on the client |
214
+ | xero_client.`access_token` | returns the `access_token` if one is set on the client |
215
+ | xero_client.`id_token` | returns the `id_token` if one is set on the client |
216
+ | xero_client.`decoded_access_token` | Decoded JWT exposing OAuth2.`0` meta details about the token |
217
+ | xero_client.`decoded_id_token` | Decoded JWT containing the user meta details that can be used to implement SSO or SSU to Lead |
218
+ ---
219
+ ## Usage Examples
164
220
  ### Accounting API
165
221
  ```ruby
166
222
  require 'xero-ruby'
167
223
 
168
- xero_client.refresh_token_set(user.token_set)
169
-
170
- tenant_id = user.active_tenant_id
171
- # example of how to store the `tenantId` of the specific tenant (aka organisation)
172
-
173
- # https://github.com/XeroAPI/xero-ruby/blob/master/accounting/lib/xero-ruby/api/accounting_api.rb
224
+ xero_client.refresh_token_set(user_token_set)
225
+ tenant_id = xero_client.last_connection
174
226
 
175
227
  # Get Accounts
176
228
  accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts
@@ -179,6 +231,13 @@ accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts
179
231
  invoices = { invoices: [{ type: XeroRuby::Accounting::Invoice::ACCREC, contact: { contact_id: contacts[0].contact_id }, line_items: [{ description: "Big Agency", quantity: BigDecimal("2.0"), unit_amount: BigDecimal("50.99"), account_code: "600", tax_type: XeroRuby::Accounting::TaxType::NONE }], date: "2019-03-11", due_date: "2018-12-10", reference: "Website Design", status: XeroRuby::Accounting::Invoice::DRAFT }]}
180
232
  invoice = xero_client.accounting_api.create_invoices(tenant_id, invoices).invoices.first
181
233
 
234
+ # return data as a snake_case hash
235
+ puts invoices.to_attributes
236
+ => {type: 'ACCREC', line_items: [...]}
237
+
238
+ puts invoices.to_hash(downcase: false)
239
+ => {'Type': 'ACCREC', 'LineItems': [...]}
240
+
182
241
  # Create History
183
242
  payment = xero_client.accounting_api.get_payments(tenant_id).payments.first
184
243
  history_records = { history_records: [{ details: "This payment now has some History!" }]}
@@ -194,59 +253,9 @@ file = File.read(Rails.root.join('app/assets/images/xero-api.png'))
194
253
  attachment = xero_client.accounting_api.create_account_attachment_by_file_name(tenant_id, @account.account_id, file_name, file, opts)
195
254
  ```
196
255
 
197
- ### Assets API
198
- ```ruby
199
- # https://github.com/XeroAPI/xero-ruby/blob/master/accounting/lib/xero-ruby/api/asset_api.rb
200
-
201
- # Create Asset
202
- asset = {
203
- "assetName": "AssetName: #{rand(10000)}",
204
- "assetNumber": "Asset: #{rand(10000)}",
205
- "assetStatus": "DRAFT"
206
- }
207
- asset = xero_client.asset_api.create_asset(tenant_id, asset)
208
- ```
209
-
210
- ### Project API
211
- ```ruby
212
- # https://github.com/XeroAPI/xero-ruby/blob/master/docs/projects/ProjectApi.md
213
-
214
- # Get Projects
215
- projects = xero_client.project_api.get_projects(tenant_id).items
216
- ```
217
-
218
- ### Files API
219
- ```ruby
220
- # https://github.com/XeroAPI/xero-ruby/blob/master/docs/files/FileApi.md
221
-
222
- # Get Files
223
- opts = {
224
- pagesize: 50, # Integer | pass an optional page size value
225
- page: 2, # Integer | number of records to skip for pagination
226
- sort: 'CreatedDateUTC DESC' # String | values to sort by
227
- }
228
-
229
- files = xero_client.files_api.get_files(tenant_id, opts).files
230
- ```
231
-
232
- ### Payroll API(s)
233
- ```ruby
234
- # https://github.com/XeroAPI/xero-ruby/blob/master/docs/payroll_au/PayrollAuApi.md
235
- employee_id = 'employee_uuid'
236
- employee = xero_client.payroll_au_api.get_employee(tenant_id, employee_id).employee
237
-
238
-
239
- # https://github.com/XeroAPI/xero-ruby/blob/master/docs/payroll_nz/PayrollNzApi.md
240
- timesheet_id = 'timesheeet_uuid'
241
- timesheet = xero_client.payroll_nz_api.approve_timesheet(tenant_id, timesheet_id).timesheets
242
-
243
-
244
- # https://github.com/XeroAPI/xero-ruby/blob/master/docs/payroll_uk/PayrollUkApi.md
245
- employee_id = 'employee_uuid'
246
- wages = xero_client.payroll_uk_api.get_employee_salary_and_wages(tenant_id, employee_id, opts).salary_and_wages
247
- ```
248
-
249
- ## BigDecimal
256
+ ---
257
+ ## SDK conventions
258
+ ### BigDecimal
250
259
  All monetary and fields and a couple quantity fields utilize BigDecimal
251
260
  ```ruby
252
261
  puts invoice.unit_amount
@@ -262,8 +271,8 @@ All monetary and fields and a couple quantity fields utilize BigDecimal
262
271
  number_to_currency(invoice.unit_amount, :unit => "$")
263
272
  ```
264
273
 
265
- ## Querying & Filtering
266
- Examples for the `opts` (_options_) parameters most endpoints support. This is an area of focus and improvement. If you have a complex filering/sorting/where usage that is not supported please [open an issue](https://github.com/XeroAPI/xero-ruby/issues).
274
+ ### Querying & Filtering
275
+ Examples for `opts` (aka _options_) parameters that most endpoints support. If you have a complex filering/sorting/where usage that is not supported please [open an issue](https://github.com/XeroAPI/xero-ruby/issues).
267
276
  ```ruby
268
277
  # Invoices
269
278
  opts = {
@@ -276,7 +285,7 @@ Examples for the `opts` (_options_) parameters most endpoints support. This is a
276
285
  invoice_number: ['=', "INV-0001"],
277
286
  contact_id: ['=', 'contact-uuid-xxxx-xxx-xxxxxxx'],
278
287
  contact_number: ['=', "the-contact-number"],
279
- # date: (DateTime.now - 2.year)..DateTime.now
288
+ date: (DateTime.now - 2.year)..DateTime.now
280
289
  # ▲ you can pass a range ▼ or a date & operator
281
290
  date: ['>=', DateTime.now - 2.year],
282
291
  status: ['=', XeroRuby::Accounting::Invoice::PAID]
@@ -291,11 +300,20 @@ opts = {
291
300
  order: 'UpdatedDateUtc DESC',
292
301
  where: {
293
302
  is_customer: ['==', true],
294
- is_supplier: ['==', true]
303
+ is_supplier: ['==', true],
304
+ name: ['StartsWith', 'Rick']
295
305
  }
296
306
  }
297
307
  xero_client.accounting_api.get_contacts(tenant_id, opts).contacts
298
308
 
309
+ # for more complex chained filtering that requires a null check pass those in as a string
310
+ # see https://developer.xero.com/documentation/api/requests-and-responses for more
311
+ opts = {
312
+ where: {
313
+ email_address: '!=null&&EmailAddress.StartsWith("chris.knight@")'
314
+ }
315
+ }
316
+
299
317
  # Bank Transactions
300
318
  opts = {
301
319
  if_modified_since: (DateTime.now - 1.year).to_s,
@@ -316,15 +334,48 @@ opts = {
316
334
  }
317
335
  xero_client.accounting_api.get_bank_transfers(tenant_id, opts).bank_transfers
318
336
  ```
319
- ### NOTE
320
- 1) Not all `opts` parameter combinations are available for all endpoints, and there are likely some undiscovered edge cases. If you encounter a filter / sort / where clause that seems buggy open an issue and we will dig.
321
337
 
322
- 2) Some opts string values may need PascalCasing to match casing defined in our [core API docs](https://developer.xero.com/documentation/api/api-overview).
323
- * `opts = { order: 'UpdatedDateUtc DESC'}`
338
+ - Not all `opts` parameter combinations are available for all endpoints
339
+
340
+ - Some opts string values may need PascalCasing to match casing defined in our [core API docs](https://developer.xero.com/documentation/api/api-overview) like `opts = { order: 'UpdatedDateUtc DESC'}`
341
+
342
+ ---
343
+ ## Contributing
344
+ PRs, issues, and discussion are highly appreciated and encouraged. Note that the majority of this project is generated code based on [Xero's OpenAPI specs](https://github.com/XeroAPI/Xero-OpenAPI) - PR's will be evaluated and pre-merge will be incorporated into the root generation templates.
345
+
346
+ Please add tests for net new functionality and make existing test suite succeeds.
347
+
348
+ `$ rspec spec/`
349
+ ### Versioning
350
+ We do our best to keep OS industry `semver` standards, but we can make mistakes! If something is not accurately reflected in a version's release notes please let the team know.
351
+ ### Developing locally
352
+ To develop or test this gem locally against your project we find the following development pattern easiest
353
+
354
+ ```bash
355
+ cd xero-ruby
356
+ gem build
357
+ mv xero-ruby-<vsn>.gem xero-ruby.gem
358
+ pwd
359
+ => /Users/your.user/code/sdks/xero-ruby/
360
+
361
+ cd ..
362
+ cd xero-ruby-oauth2-app/
363
+
364
+ # xero-ruby-oauth2-app/Gemfile
365
+ gem 'xero-ruby', path: '/Users/your.user/code/sdks/xero-ruby/'
366
+ bundle install
367
+ ```
368
+
369
+ ## Participating in Xero’s developer community
370
+
371
+ This SDK is one of a number of SDK’s that the Xero Developer team builds and maintains. We are grateful for all the contributions that the community makes.
324
372
 
325
- 3) If you have use cases outside of these examples let us know.
373
+ Here are a few things you should be aware of as a contributor:
374
+ * Xero has adopted the Contributor Covenant [Code of Conduct](https://github.com/XeroAPI/xero-ruby/blob/master/CODE_OF_CONDUCT.md), we expect all contributors in our community to adhere to it
375
+ * If you raise an issue then please make sure to fill out the github issue template, doing so helps us help you
376
+ * You’re welcome to raise PRs. As our SDKs are generated we may use your code in the core SDK build instead of merging your code
377
+ * We have a [contribution guide](https://github.com/XeroAPI/xero-ruby/blob/master/CONTRIBUTING.md) for you to follow when contributing to this SDK
378
+ * Curious about how we generate our SDK’s? Have a [read of our process](https://devblog.xero.com/building-sdks-for-the-future-b79ff726dfd6) and have a look at our [OpenAPISpec](https://github.com/XeroAPI/Xero-OpenAPI)
379
+ * This software is published under the [MIT License](https://github.com/XeroAPI/xero-ruby/blob/master/LICENSE)
326
380
 
327
- ## Sample App
328
- The best resource to understanding how to best leverage this SDK is the sample applications showing all the features of the gem.
329
- > https://github.com/XeroAPI/xero-ruby-oauth2-starter (Sinatra - simple getting started)
330
- > https://github.com/XeroAPI/xero-ruby-oauth2-app (Rails - full featured examples)
381
+ For questions that aren’t related to SDKs please refer to our [developer support page](https://developer.xero.com/support/).