xero-ruby 2.9.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +133 -97
  3. data/lib/xero-ruby.rb +3 -0
  4. data/lib/xero-ruby/api/accounting_api.rb +306 -147
  5. data/lib/xero-ruby/api_client.rb +57 -8
  6. data/lib/xero-ruby/models/accounting/account.rb +11 -7
  7. data/lib/xero-ruby/models/accounting/accounts.rb +11 -7
  8. data/lib/xero-ruby/models/accounting/accounts_payable.rb +11 -7
  9. data/lib/xero-ruby/models/accounting/accounts_receivable.rb +11 -7
  10. data/lib/xero-ruby/models/accounting/action.rb +11 -7
  11. data/lib/xero-ruby/models/accounting/actions.rb +11 -7
  12. data/lib/xero-ruby/models/accounting/address.rb +11 -7
  13. data/lib/xero-ruby/models/accounting/address_for_organisation.rb +11 -7
  14. data/lib/xero-ruby/models/accounting/allocation.rb +11 -7
  15. data/lib/xero-ruby/models/accounting/allocations.rb +11 -7
  16. data/lib/xero-ruby/models/accounting/attachment.rb +11 -7
  17. data/lib/xero-ruby/models/accounting/attachments.rb +11 -7
  18. data/lib/xero-ruby/models/accounting/balance_details.rb +11 -7
  19. data/lib/xero-ruby/models/accounting/balances.rb +11 -7
  20. data/lib/xero-ruby/models/accounting/bank_transaction.rb +11 -7
  21. data/lib/xero-ruby/models/accounting/bank_transactions.rb +11 -7
  22. data/lib/xero-ruby/models/accounting/bank_transfer.rb +11 -7
  23. data/lib/xero-ruby/models/accounting/bank_transfers.rb +11 -7
  24. data/lib/xero-ruby/models/accounting/batch_payment.rb +11 -7
  25. data/lib/xero-ruby/models/accounting/batch_payment_details.rb +11 -7
  26. data/lib/xero-ruby/models/accounting/batch_payments.rb +11 -7
  27. data/lib/xero-ruby/models/accounting/bill.rb +11 -7
  28. data/lib/xero-ruby/models/accounting/branding_theme.rb +11 -7
  29. data/lib/xero-ruby/models/accounting/branding_themes.rb +11 -7
  30. data/lib/xero-ruby/models/accounting/budget.rb +321 -0
  31. data/lib/xero-ruby/models/accounting/budget_lines.rb +265 -0
  32. data/lib/xero-ruby/models/accounting/budgets.rb +222 -0
  33. data/lib/xero-ruby/models/accounting/cis_org_setting.rb +11 -7
  34. data/lib/xero-ruby/models/accounting/cis_org_settings.rb +11 -7
  35. data/lib/xero-ruby/models/accounting/cis_setting.rb +11 -7
  36. data/lib/xero-ruby/models/accounting/cis_settings.rb +11 -7
  37. data/lib/xero-ruby/models/accounting/contact.rb +11 -7
  38. data/lib/xero-ruby/models/accounting/contact_group.rb +11 -7
  39. data/lib/xero-ruby/models/accounting/contact_groups.rb +11 -7
  40. data/lib/xero-ruby/models/accounting/contact_person.rb +11 -7
  41. data/lib/xero-ruby/models/accounting/contacts.rb +11 -7
  42. data/lib/xero-ruby/models/accounting/conversion_balances.rb +11 -7
  43. data/lib/xero-ruby/models/accounting/conversion_date.rb +11 -7
  44. data/lib/xero-ruby/models/accounting/credit_note.rb +11 -7
  45. data/lib/xero-ruby/models/accounting/credit_notes.rb +11 -7
  46. data/lib/xero-ruby/models/accounting/currencies.rb +11 -7
  47. data/lib/xero-ruby/models/accounting/currency.rb +11 -7
  48. data/lib/xero-ruby/models/accounting/element.rb +11 -7
  49. data/lib/xero-ruby/models/accounting/employee.rb +11 -7
  50. data/lib/xero-ruby/models/accounting/employees.rb +11 -7
  51. data/lib/xero-ruby/models/accounting/error.rb +11 -7
  52. data/lib/xero-ruby/models/accounting/expense_claim.rb +11 -7
  53. data/lib/xero-ruby/models/accounting/expense_claims.rb +11 -7
  54. data/lib/xero-ruby/models/accounting/external_link.rb +11 -7
  55. data/lib/xero-ruby/models/accounting/history_record.rb +11 -7
  56. data/lib/xero-ruby/models/accounting/history_records.rb +11 -7
  57. data/lib/xero-ruby/models/accounting/import_summary.rb +11 -7
  58. data/lib/xero-ruby/models/accounting/import_summary_accounts.rb +11 -7
  59. data/lib/xero-ruby/models/accounting/import_summary_object.rb +11 -7
  60. data/lib/xero-ruby/models/accounting/import_summary_organisation.rb +11 -7
  61. data/lib/xero-ruby/models/accounting/invoice.rb +11 -7
  62. data/lib/xero-ruby/models/accounting/invoice_reminder.rb +11 -7
  63. data/lib/xero-ruby/models/accounting/invoice_reminders.rb +11 -7
  64. data/lib/xero-ruby/models/accounting/invoices.rb +11 -7
  65. data/lib/xero-ruby/models/accounting/item.rb +11 -7
  66. data/lib/xero-ruby/models/accounting/items.rb +11 -7
  67. data/lib/xero-ruby/models/accounting/journal.rb +11 -7
  68. data/lib/xero-ruby/models/accounting/journal_line.rb +11 -7
  69. data/lib/xero-ruby/models/accounting/journals.rb +11 -7
  70. data/lib/xero-ruby/models/accounting/line_item.rb +22 -8
  71. data/lib/xero-ruby/models/accounting/line_item_tracking.rb +11 -7
  72. data/lib/xero-ruby/models/accounting/linked_transaction.rb +11 -7
  73. data/lib/xero-ruby/models/accounting/linked_transactions.rb +11 -7
  74. data/lib/xero-ruby/models/accounting/manual_journal.rb +11 -7
  75. data/lib/xero-ruby/models/accounting/manual_journal_line.rb +11 -7
  76. data/lib/xero-ruby/models/accounting/manual_journals.rb +11 -7
  77. data/lib/xero-ruby/models/accounting/online_invoice.rb +11 -7
  78. data/lib/xero-ruby/models/accounting/online_invoices.rb +11 -7
  79. data/lib/xero-ruby/models/accounting/organisation.rb +11 -7
  80. data/lib/xero-ruby/models/accounting/organisations.rb +11 -7
  81. data/lib/xero-ruby/models/accounting/overpayment.rb +11 -7
  82. data/lib/xero-ruby/models/accounting/overpayments.rb +11 -7
  83. data/lib/xero-ruby/models/accounting/payment.rb +11 -7
  84. data/lib/xero-ruby/models/accounting/payment_delete.rb +11 -7
  85. data/lib/xero-ruby/models/accounting/payment_service.rb +11 -7
  86. data/lib/xero-ruby/models/accounting/payment_services.rb +11 -7
  87. data/lib/xero-ruby/models/accounting/payment_term.rb +11 -7
  88. data/lib/xero-ruby/models/accounting/payments.rb +11 -7
  89. data/lib/xero-ruby/models/accounting/phone.rb +11 -7
  90. data/lib/xero-ruby/models/accounting/prepayment.rb +24 -8
  91. data/lib/xero-ruby/models/accounting/prepayments.rb +11 -7
  92. data/lib/xero-ruby/models/accounting/purchase.rb +11 -7
  93. data/lib/xero-ruby/models/accounting/purchase_order.rb +11 -7
  94. data/lib/xero-ruby/models/accounting/purchase_orders.rb +11 -7
  95. data/lib/xero-ruby/models/accounting/quote.rb +11 -7
  96. data/lib/xero-ruby/models/accounting/quotes.rb +11 -7
  97. data/lib/xero-ruby/models/accounting/receipt.rb +11 -7
  98. data/lib/xero-ruby/models/accounting/receipts.rb +11 -7
  99. data/lib/xero-ruby/models/accounting/repeating_invoice.rb +11 -7
  100. data/lib/xero-ruby/models/accounting/repeating_invoices.rb +11 -7
  101. data/lib/xero-ruby/models/accounting/report.rb +12 -18
  102. data/lib/xero-ruby/models/accounting/report_attribute.rb +11 -7
  103. data/lib/xero-ruby/models/accounting/report_cell.rb +11 -7
  104. data/lib/xero-ruby/models/accounting/report_fields.rb +11 -7
  105. data/lib/xero-ruby/models/accounting/report_row.rb +11 -7
  106. data/lib/xero-ruby/models/accounting/report_rows.rb +11 -7
  107. data/lib/xero-ruby/models/accounting/report_with_row.rb +12 -8
  108. data/lib/xero-ruby/models/accounting/report_with_rows.rb +11 -7
  109. data/lib/xero-ruby/models/accounting/reports.rb +11 -7
  110. data/lib/xero-ruby/models/accounting/request_empty.rb +11 -7
  111. data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +11 -7
  112. data/lib/xero-ruby/models/accounting/schedule.rb +11 -7
  113. data/lib/xero-ruby/models/accounting/setup.rb +11 -7
  114. data/lib/xero-ruby/models/accounting/tax_component.rb +11 -7
  115. data/lib/xero-ruby/models/accounting/tax_rate.rb +11 -7
  116. data/lib/xero-ruby/models/accounting/tax_rates.rb +11 -7
  117. data/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +11 -7
  118. data/lib/xero-ruby/models/accounting/tracking_categories.rb +11 -7
  119. data/lib/xero-ruby/models/accounting/tracking_category.rb +11 -7
  120. data/lib/xero-ruby/models/accounting/tracking_option.rb +11 -7
  121. data/lib/xero-ruby/models/accounting/tracking_options.rb +11 -7
  122. data/lib/xero-ruby/models/accounting/user.rb +11 -7
  123. data/lib/xero-ruby/models/accounting/users.rb +11 -7
  124. data/lib/xero-ruby/models/accounting/validation_error.rb +11 -7
  125. data/lib/xero-ruby/models/assets/asset.rb +11 -7
  126. data/lib/xero-ruby/models/assets/asset_type.rb +11 -7
  127. data/lib/xero-ruby/models/assets/assets.rb +11 -7
  128. data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +11 -7
  129. data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +11 -7
  130. data/lib/xero-ruby/models/assets/error.rb +11 -7
  131. data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +11 -7
  132. data/lib/xero-ruby/models/assets/pagination.rb +11 -7
  133. data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +11 -7
  134. data/lib/xero-ruby/models/assets/setting.rb +11 -7
  135. data/lib/xero-ruby/models/files/association.rb +11 -7
  136. data/lib/xero-ruby/models/files/file_object.rb +11 -7
  137. data/lib/xero-ruby/models/files/files.rb +11 -7
  138. data/lib/xero-ruby/models/files/folder.rb +11 -7
  139. data/lib/xero-ruby/models/files/folders.rb +11 -7
  140. data/lib/xero-ruby/models/files/upload_object.rb +11 -7
  141. data/lib/xero-ruby/models/files/user.rb +11 -7
  142. data/lib/xero-ruby/models/payroll_au/account.rb +11 -7
  143. data/lib/xero-ruby/models/payroll_au/api_exception.rb +11 -7
  144. data/lib/xero-ruby/models/payroll_au/bank_account.rb +11 -7
  145. data/lib/xero-ruby/models/payroll_au/deduction_line.rb +11 -7
  146. data/lib/xero-ruby/models/payroll_au/deduction_type.rb +11 -7
  147. data/lib/xero-ruby/models/payroll_au/earnings_line.rb +11 -7
  148. data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +11 -7
  149. data/lib/xero-ruby/models/payroll_au/employee.rb +11 -7
  150. data/lib/xero-ruby/models/payroll_au/employees.rb +11 -7
  151. data/lib/xero-ruby/models/payroll_au/home_address.rb +11 -7
  152. data/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb +11 -7
  153. data/lib/xero-ruby/models/payroll_au/leave_application.rb +11 -7
  154. data/lib/xero-ruby/models/payroll_au/leave_applications.rb +11 -7
  155. data/lib/xero-ruby/models/payroll_au/leave_balance.rb +11 -7
  156. data/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +11 -7
  157. data/lib/xero-ruby/models/payroll_au/leave_line.rb +11 -7
  158. data/lib/xero-ruby/models/payroll_au/leave_lines.rb +11 -7
  159. data/lib/xero-ruby/models/payroll_au/leave_period.rb +11 -7
  160. data/lib/xero-ruby/models/payroll_au/leave_type.rb +11 -7
  161. data/lib/xero-ruby/models/payroll_au/opening_balances.rb +11 -7
  162. data/lib/xero-ruby/models/payroll_au/pay_item.rb +11 -7
  163. data/lib/xero-ruby/models/payroll_au/pay_items.rb +11 -7
  164. data/lib/xero-ruby/models/payroll_au/pay_run.rb +11 -7
  165. data/lib/xero-ruby/models/payroll_au/pay_runs.rb +11 -7
  166. data/lib/xero-ruby/models/payroll_au/pay_template.rb +11 -7
  167. data/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +11 -7
  168. data/lib/xero-ruby/models/payroll_au/payroll_calendars.rb +11 -7
  169. data/lib/xero-ruby/models/payroll_au/payslip.rb +11 -7
  170. data/lib/xero-ruby/models/payroll_au/payslip_lines.rb +11 -7
  171. data/lib/xero-ruby/models/payroll_au/payslip_object.rb +11 -7
  172. data/lib/xero-ruby/models/payroll_au/payslip_summary.rb +11 -7
  173. data/lib/xero-ruby/models/payroll_au/payslips.rb +11 -7
  174. data/lib/xero-ruby/models/payroll_au/reimbursement_line.rb +11 -7
  175. data/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb +11 -7
  176. data/lib/xero-ruby/models/payroll_au/reimbursement_type.rb +11 -7
  177. data/lib/xero-ruby/models/payroll_au/settings.rb +11 -7
  178. data/lib/xero-ruby/models/payroll_au/settings_object.rb +11 -7
  179. data/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb +11 -7
  180. data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb +11 -7
  181. data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb +11 -7
  182. data/lib/xero-ruby/models/payroll_au/super_fund.rb +11 -7
  183. data/lib/xero-ruby/models/payroll_au/super_fund_product.rb +11 -7
  184. data/lib/xero-ruby/models/payroll_au/super_fund_products.rb +11 -7
  185. data/lib/xero-ruby/models/payroll_au/super_funds.rb +11 -7
  186. data/lib/xero-ruby/models/payroll_au/super_line.rb +11 -7
  187. data/lib/xero-ruby/models/payroll_au/super_membership.rb +11 -7
  188. data/lib/xero-ruby/models/payroll_au/superannuation_line.rb +11 -7
  189. data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +11 -7
  190. data/lib/xero-ruby/models/payroll_au/tax_line.rb +11 -7
  191. data/lib/xero-ruby/models/payroll_au/timesheet.rb +11 -7
  192. data/lib/xero-ruby/models/payroll_au/timesheet_line.rb +11 -7
  193. data/lib/xero-ruby/models/payroll_au/timesheet_object.rb +11 -7
  194. data/lib/xero-ruby/models/payroll_au/timesheets.rb +11 -7
  195. data/lib/xero-ruby/models/payroll_au/validation_error.rb +11 -7
  196. data/lib/xero-ruby/models/payroll_nz/account.rb +11 -7
  197. data/lib/xero-ruby/models/payroll_nz/accounts.rb +11 -7
  198. data/lib/xero-ruby/models/payroll_nz/address.rb +11 -7
  199. data/lib/xero-ruby/models/payroll_nz/bank_account.rb +11 -7
  200. data/lib/xero-ruby/models/payroll_nz/benefit.rb +11 -7
  201. data/lib/xero-ruby/models/payroll_nz/deduction.rb +11 -7
  202. data/lib/xero-ruby/models/payroll_nz/deduction_line.rb +11 -7
  203. data/lib/xero-ruby/models/payroll_nz/deduction_object.rb +11 -7
  204. data/lib/xero-ruby/models/payroll_nz/deductions.rb +11 -7
  205. data/lib/xero-ruby/models/payroll_nz/earnings_line.rb +11 -7
  206. data/lib/xero-ruby/models/payroll_nz/earnings_order.rb +11 -7
  207. data/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb +11 -7
  208. data/lib/xero-ruby/models/payroll_nz/earnings_orders.rb +11 -7
  209. data/lib/xero-ruby/models/payroll_nz/earnings_rate.rb +11 -7
  210. data/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb +11 -7
  211. data/lib/xero-ruby/models/payroll_nz/earnings_rates.rb +11 -7
  212. data/lib/xero-ruby/models/payroll_nz/earnings_template.rb +11 -7
  213. data/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb +11 -7
  214. data/lib/xero-ruby/models/payroll_nz/employee.rb +11 -7
  215. data/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb +11 -7
  216. data/lib/xero-ruby/models/payroll_nz/employee_leave.rb +11 -7
  217. data/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb +11 -7
  218. data/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb +11 -7
  219. data/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb +11 -7
  220. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +11 -7
  221. data/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb +11 -7
  222. data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +11 -7
  223. data/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb +11 -7
  224. data/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb +11 -7
  225. data/lib/xero-ruby/models/payroll_nz/employee_leaves.rb +11 -7
  226. data/lib/xero-ruby/models/payroll_nz/employee_object.rb +11 -7
  227. data/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb +11 -7
  228. data/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb +11 -7
  229. data/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +11 -7
  230. data/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb +11 -7
  231. data/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb +11 -7
  232. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb +11 -7
  233. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb +11 -7
  234. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb +11 -7
  235. data/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb +11 -7
  236. data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb +11 -7
  237. data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb +11 -7
  238. data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb +11 -7
  239. data/lib/xero-ruby/models/payroll_nz/employee_tax.rb +11 -7
  240. data/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb +11 -7
  241. data/lib/xero-ruby/models/payroll_nz/employees.rb +11 -7
  242. data/lib/xero-ruby/models/payroll_nz/employment.rb +11 -7
  243. data/lib/xero-ruby/models/payroll_nz/employment_object.rb +11 -7
  244. data/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb +11 -7
  245. data/lib/xero-ruby/models/payroll_nz/invalid_field.rb +11 -7
  246. data/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb +11 -7
  247. data/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb +11 -7
  248. data/lib/xero-ruby/models/payroll_nz/leave_period.rb +11 -7
  249. data/lib/xero-ruby/models/payroll_nz/leave_periods.rb +11 -7
  250. data/lib/xero-ruby/models/payroll_nz/leave_type.rb +11 -7
  251. data/lib/xero-ruby/models/payroll_nz/leave_type_object.rb +11 -7
  252. data/lib/xero-ruby/models/payroll_nz/leave_types.rb +11 -7
  253. data/lib/xero-ruby/models/payroll_nz/pagination.rb +11 -7
  254. data/lib/xero-ruby/models/payroll_nz/pay_run.rb +11 -7
  255. data/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb +11 -7
  256. data/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb +11 -7
  257. data/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb +11 -7
  258. data/lib/xero-ruby/models/payroll_nz/pay_run_object.rb +11 -7
  259. data/lib/xero-ruby/models/payroll_nz/pay_runs.rb +11 -7
  260. data/lib/xero-ruby/models/payroll_nz/pay_slip.rb +11 -7
  261. data/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb +11 -7
  262. data/lib/xero-ruby/models/payroll_nz/pay_slips.rb +11 -7
  263. data/lib/xero-ruby/models/payroll_nz/payment_line.rb +11 -7
  264. data/lib/xero-ruby/models/payroll_nz/payment_method.rb +11 -7
  265. data/lib/xero-ruby/models/payroll_nz/payment_method_object.rb +11 -7
  266. data/lib/xero-ruby/models/payroll_nz/problem.rb +11 -7
  267. data/lib/xero-ruby/models/payroll_nz/reimbursement.rb +11 -7
  268. data/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb +11 -7
  269. data/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb +11 -7
  270. data/lib/xero-ruby/models/payroll_nz/reimbursements.rb +11 -7
  271. data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +11 -7
  272. data/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb +11 -7
  273. data/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb +11 -7
  274. data/lib/xero-ruby/models/payroll_nz/settings.rb +11 -7
  275. data/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb +11 -7
  276. data/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb +11 -7
  277. data/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb +11 -7
  278. data/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb +11 -7
  279. data/lib/xero-ruby/models/payroll_nz/superannuation_line.rb +11 -7
  280. data/lib/xero-ruby/models/payroll_nz/superannuation_object.rb +11 -7
  281. data/lib/xero-ruby/models/payroll_nz/superannuations.rb +11 -7
  282. data/lib/xero-ruby/models/payroll_nz/tax_line.rb +11 -7
  283. data/lib/xero-ruby/models/payroll_nz/tax_settings.rb +11 -7
  284. data/lib/xero-ruby/models/payroll_nz/timesheet.rb +11 -7
  285. data/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb +11 -7
  286. data/lib/xero-ruby/models/payroll_nz/timesheet_line.rb +11 -7
  287. data/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb +11 -7
  288. data/lib/xero-ruby/models/payroll_nz/timesheet_object.rb +11 -7
  289. data/lib/xero-ruby/models/payroll_nz/timesheets.rb +11 -7
  290. data/lib/xero-ruby/models/payroll_nz/tracking_categories.rb +11 -7
  291. data/lib/xero-ruby/models/payroll_nz/tracking_category.rb +11 -7
  292. data/lib/xero-ruby/models/payroll_uk/account.rb +11 -7
  293. data/lib/xero-ruby/models/payroll_uk/accounts.rb +11 -7
  294. data/lib/xero-ruby/models/payroll_uk/address.rb +11 -7
  295. data/lib/xero-ruby/models/payroll_uk/bank_account.rb +11 -7
  296. data/lib/xero-ruby/models/payroll_uk/benefit.rb +11 -7
  297. data/lib/xero-ruby/models/payroll_uk/benefit_line.rb +11 -7
  298. data/lib/xero-ruby/models/payroll_uk/benefit_object.rb +11 -7
  299. data/lib/xero-ruby/models/payroll_uk/benefits.rb +11 -7
  300. data/lib/xero-ruby/models/payroll_uk/court_order_line.rb +11 -7
  301. data/lib/xero-ruby/models/payroll_uk/deduction.rb +11 -7
  302. data/lib/xero-ruby/models/payroll_uk/deduction_line.rb +11 -7
  303. data/lib/xero-ruby/models/payroll_uk/deduction_object.rb +11 -7
  304. data/lib/xero-ruby/models/payroll_uk/deductions.rb +11 -7
  305. data/lib/xero-ruby/models/payroll_uk/earnings_line.rb +11 -7
  306. data/lib/xero-ruby/models/payroll_uk/earnings_order.rb +11 -7
  307. data/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb +11 -7
  308. data/lib/xero-ruby/models/payroll_uk/earnings_orders.rb +11 -7
  309. data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +11 -7
  310. data/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb +11 -7
  311. data/lib/xero-ruby/models/payroll_uk/earnings_rates.rb +11 -7
  312. data/lib/xero-ruby/models/payroll_uk/earnings_template.rb +11 -7
  313. data/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb +11 -7
  314. data/lib/xero-ruby/models/payroll_uk/employee.rb +11 -7
  315. data/lib/xero-ruby/models/payroll_uk/employee_leave.rb +11 -7
  316. data/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb +11 -7
  317. data/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb +11 -7
  318. data/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb +11 -7
  319. data/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +11 -7
  320. data/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb +11 -7
  321. data/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb +11 -7
  322. data/lib/xero-ruby/models/payroll_uk/employee_leaves.rb +11 -7
  323. data/lib/xero-ruby/models/payroll_uk/employee_object.rb +11 -7
  324. data/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb +11 -7
  325. data/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb +11 -7
  326. data/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +11 -7
  327. data/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb +11 -7
  328. data/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb +11 -7
  329. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +11 -7
  330. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb +11 -7
  331. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +11 -7
  332. data/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb +11 -7
  333. data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb +11 -7
  334. data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb +11 -7
  335. data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb +11 -7
  336. data/lib/xero-ruby/models/payroll_uk/employee_tax.rb +11 -7
  337. data/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb +11 -7
  338. data/lib/xero-ruby/models/payroll_uk/employees.rb +11 -7
  339. data/lib/xero-ruby/models/payroll_uk/employment.rb +11 -7
  340. data/lib/xero-ruby/models/payroll_uk/employment_object.rb +11 -7
  341. data/lib/xero-ruby/models/payroll_uk/invalid_field.rb +11 -7
  342. data/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb +11 -7
  343. data/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb +11 -7
  344. data/lib/xero-ruby/models/payroll_uk/leave_period.rb +11 -7
  345. data/lib/xero-ruby/models/payroll_uk/leave_periods.rb +11 -7
  346. data/lib/xero-ruby/models/payroll_uk/leave_type.rb +11 -7
  347. data/lib/xero-ruby/models/payroll_uk/leave_type_object.rb +11 -7
  348. data/lib/xero-ruby/models/payroll_uk/leave_types.rb +11 -7
  349. data/lib/xero-ruby/models/payroll_uk/pagination.rb +11 -7
  350. data/lib/xero-ruby/models/payroll_uk/pay_run.rb +11 -7
  351. data/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb +11 -7
  352. data/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb +11 -7
  353. data/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb +11 -7
  354. data/lib/xero-ruby/models/payroll_uk/pay_run_object.rb +11 -7
  355. data/lib/xero-ruby/models/payroll_uk/pay_runs.rb +11 -7
  356. data/lib/xero-ruby/models/payroll_uk/payment_line.rb +11 -7
  357. data/lib/xero-ruby/models/payroll_uk/payment_method.rb +11 -7
  358. data/lib/xero-ruby/models/payroll_uk/payment_method_object.rb +11 -7
  359. data/lib/xero-ruby/models/payroll_uk/payslip.rb +11 -7
  360. data/lib/xero-ruby/models/payroll_uk/payslip_object.rb +11 -7
  361. data/lib/xero-ruby/models/payroll_uk/payslips.rb +11 -7
  362. data/lib/xero-ruby/models/payroll_uk/problem.rb +11 -7
  363. data/lib/xero-ruby/models/payroll_uk/reimbursement.rb +11 -7
  364. data/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb +11 -7
  365. data/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb +11 -7
  366. data/lib/xero-ruby/models/payroll_uk/reimbursements.rb +11 -7
  367. data/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +11 -7
  368. data/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb +11 -7
  369. data/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb +11 -7
  370. data/lib/xero-ruby/models/payroll_uk/settings.rb +11 -7
  371. data/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb +11 -7
  372. data/lib/xero-ruby/models/payroll_uk/tax_line.rb +11 -7
  373. data/lib/xero-ruby/models/payroll_uk/timesheet.rb +11 -7
  374. data/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb +11 -7
  375. data/lib/xero-ruby/models/payroll_uk/timesheet_line.rb +11 -7
  376. data/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb +11 -7
  377. data/lib/xero-ruby/models/payroll_uk/timesheet_object.rb +11 -7
  378. data/lib/xero-ruby/models/payroll_uk/timesheets.rb +11 -7
  379. data/lib/xero-ruby/models/payroll_uk/tracking_categories.rb +11 -7
  380. data/lib/xero-ruby/models/payroll_uk/tracking_category.rb +11 -7
  381. data/lib/xero-ruby/models/projects/amount.rb +11 -7
  382. data/lib/xero-ruby/models/projects/error.rb +11 -7
  383. data/lib/xero-ruby/models/projects/pagination.rb +11 -7
  384. data/lib/xero-ruby/models/projects/project.rb +11 -7
  385. data/lib/xero-ruby/models/projects/project_create_or_update.rb +11 -7
  386. data/lib/xero-ruby/models/projects/project_patch.rb +11 -7
  387. data/lib/xero-ruby/models/projects/project_user.rb +11 -7
  388. data/lib/xero-ruby/models/projects/project_users.rb +11 -7
  389. data/lib/xero-ruby/models/projects/projects.rb +11 -7
  390. data/lib/xero-ruby/models/projects/task.rb +11 -7
  391. data/lib/xero-ruby/models/projects/task_create_or_update.rb +11 -7
  392. data/lib/xero-ruby/models/projects/tasks.rb +11 -7
  393. data/lib/xero-ruby/models/projects/time_entries.rb +11 -7
  394. data/lib/xero-ruby/models/projects/time_entry.rb +14 -9
  395. data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +11 -7
  396. data/lib/xero-ruby/version.rb +2 -2
  397. data/spec/api_client_spec.rb +84 -9
  398. data/spec/helper_methods_spec.rb +28 -0
  399. metadata +29 -6
@@ -0,0 +1,265 @@
1
+ =begin
2
+ #Xero Accounting API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::Accounting
16
+ require 'bigdecimal'
17
+
18
+ class BudgetLines
19
+ # Period the amount applies to (e.g. “2019-08”)
20
+ attr_accessor :period
21
+
22
+ # LineItem Quantity
23
+ attr_accessor :amount
24
+
25
+ # Budgeted amount
26
+ attr_accessor :unit_amount
27
+
28
+ # Any footnotes associated with this balance
29
+ attr_accessor :notes
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'period' => :'Period',
35
+ :'amount' => :'Amount',
36
+ :'unit_amount' => :'UnitAmount',
37
+ :'notes' => :'Notes'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'period' => :'Date',
45
+ :'amount' => :'Integer',
46
+ :'unit_amount' => :'Integer',
47
+ :'notes' => :'String'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Accounting::BudgetLines` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Accounting::BudgetLines`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'period')
67
+ self.period = attributes[:'period']
68
+ end
69
+
70
+ if attributes.key?(:'amount')
71
+ self.amount = attributes[:'amount']
72
+ end
73
+
74
+ if attributes.key?(:'unit_amount')
75
+ self.unit_amount = attributes[:'unit_amount']
76
+ end
77
+
78
+ if attributes.key?(:'notes')
79
+ self.notes = attributes[:'notes']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ if !@notes.nil? && @notes.to_s.length > 255
88
+ invalid_properties.push('invalid value for "notes", the character length must be smaller than or equal to 255.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ return false if !@notes.nil? && @notes.to_s.length > 255
98
+ true
99
+ end
100
+
101
+ # Custom attribute writer method with validation
102
+ # @param [Object] notes Value to be assigned
103
+ def notes=(notes)
104
+ if !notes.nil? && notes.to_s.length > 255
105
+ fail ArgumentError, 'invalid value for "notes", the character length must be smaller than or equal to 255.'
106
+ end
107
+
108
+ @notes = notes
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ period == o.period &&
117
+ amount == o.amount &&
118
+ unit_amount == o.unit_amount &&
119
+ notes == o.notes
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [period, amount, unit_amount, notes].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ self.class.openapi_types.each_pair do |key, type|
147
+ if type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :DateTime
168
+ DateTime.parse(parse_date(value))
169
+ when :Date
170
+ Date.parse(parse_date(value))
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :BigDecimal
178
+ BigDecimal(value.to_s)
179
+ when :Boolean
180
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
+ true
182
+ else
183
+ false
184
+ end
185
+ when :Object
186
+ # generic object (usually a Hash), return directly
187
+ value
188
+ when /\AArray<(?<inner_type>.+)>\z/
189
+ inner_type = Regexp.last_match[:inner_type]
190
+ value.map { |v| _deserialize(inner_type, v) }
191
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
192
+ k_type = Regexp.last_match[:k_type]
193
+ v_type = Regexp.last_match[:v_type]
194
+ {}.tap do |hash|
195
+ value.each do |k, v|
196
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
197
+ end
198
+ end
199
+ else # model
200
+ XeroRuby::Accounting.const_get(type).build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ # Returns the string representation of the object
205
+ # @return [String] String presentation of the object
206
+ def to_s
207
+ to_hash.to_s
208
+ end
209
+
210
+ # to_body is an alias to to_hash (backward compatibility)
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_body
213
+ to_hash
214
+ end
215
+
216
+ # Returns the object in the form of hash
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_hash(downcase: false)
219
+ hash = {}
220
+ self.class.attribute_map.each_pair do |attr, param|
221
+ value = self.send(attr)
222
+ next if value.nil?
223
+ key = downcase ? attr : param
224
+ hash[key] = _to_hash(value, downcase: downcase)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Returns the object in the form of hash with snake_case
230
+ def to_attributes
231
+ to_hash(downcase: true)
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value, downcase: false)
239
+ if value.is_a?(Array)
240
+ value.map do |v|
241
+ v.to_hash(downcase: downcase)
242
+ end
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash(downcase: downcase)
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ def parse_date(datestring)
255
+ if datestring.include?('Date')
256
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
257
+ original, date, timezone = *date_pattern.match(datestring)
258
+ date = (date.to_i / 1000)
259
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
260
+ else # handle date 'types' for small subset of payroll API's
261
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
262
+ end
263
+ end
264
+ end
265
+ end
@@ -0,0 +1,222 @@
1
+ =begin
2
+ #Xero Accounting API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ Contact: api@xero.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 4.3.1
9
+
10
+ =end
11
+
12
+ require 'time'
13
+ require 'date'
14
+
15
+ module XeroRuby::Accounting
16
+ require 'bigdecimal'
17
+
18
+ class Budgets
19
+
20
+ attr_accessor :budgets
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'budgets' => :'Budgets'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.openapi_types
31
+ {
32
+ :'budgets' => :'Array<Budget>'
33
+ }
34
+ end
35
+
36
+ # Initializes the object
37
+ # @param [Hash] attributes Model attributes in the form of hash
38
+ def initialize(attributes = {})
39
+ if (!attributes.is_a?(Hash))
40
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Accounting::Budgets` initialize method"
41
+ end
42
+
43
+ # check to see if the attribute exists and convert string to symbol for hash key
44
+ attributes = attributes.each_with_object({}) { |(k, v), h|
45
+ if (!self.class.attribute_map.key?(k.to_sym))
46
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Accounting::Budgets`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
47
+ end
48
+ h[k.to_sym] = v
49
+ }
50
+
51
+ if attributes.key?(:'budgets')
52
+ if (value = attributes[:'budgets']).is_a?(Array)
53
+ self.budgets = value
54
+ end
55
+ end
56
+ end
57
+
58
+ # Show invalid properties with the reasons. Usually used together with valid?
59
+ # @return Array for valid properties with the reasons
60
+ def list_invalid_properties
61
+ invalid_properties = Array.new
62
+ invalid_properties
63
+ end
64
+
65
+ # Check to see if the all the properties in the model are valid
66
+ # @return true if the model is valid
67
+ def valid?
68
+ true
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(o)
74
+ return true if self.equal?(o)
75
+ self.class == o.class &&
76
+ budgets == o.budgets
77
+ end
78
+
79
+ # @see the `==` method
80
+ # @param [Object] Object to be compared
81
+ def eql?(o)
82
+ self == o
83
+ end
84
+
85
+ # Calculates hash code according to all attributes.
86
+ # @return [Integer] Hash code
87
+ def hash
88
+ [budgets].hash
89
+ end
90
+
91
+ # Builds the object from hash
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ # @return [Object] Returns the model itself
94
+ def self.build_from_hash(attributes)
95
+ new.build_from_hash(attributes)
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def build_from_hash(attributes)
102
+ return nil unless attributes.is_a?(Hash)
103
+ self.class.openapi_types.each_pair do |key, type|
104
+ if type =~ /\AArray<(.*)>/i
105
+ # check to ensure the input is an array given that the attribute
106
+ # is documented as an array but the input is not
107
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
108
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
109
+ end
110
+ elsif !attributes[self.class.attribute_map[key]].nil?
111
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
112
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
113
+ end
114
+
115
+ self
116
+ end
117
+
118
+ # Deserializes the data based on type
119
+ # @param string type Data type
120
+ # @param string value Value to be deserialized
121
+ # @return [Object] Deserialized data
122
+ def _deserialize(type, value)
123
+ case type.to_sym
124
+ when :DateTime
125
+ DateTime.parse(parse_date(value))
126
+ when :Date
127
+ Date.parse(parse_date(value))
128
+ when :String
129
+ value.to_s
130
+ when :Integer
131
+ value.to_i
132
+ when :Float
133
+ value.to_f
134
+ when :BigDecimal
135
+ BigDecimal(value.to_s)
136
+ when :Boolean
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ else # model
157
+ XeroRuby::Accounting.const_get(type).build_from_hash(value)
158
+ end
159
+ end
160
+
161
+ # Returns the string representation of the object
162
+ # @return [String] String presentation of the object
163
+ def to_s
164
+ to_hash.to_s
165
+ end
166
+
167
+ # to_body is an alias to to_hash (backward compatibility)
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_body
170
+ to_hash
171
+ end
172
+
173
+ # Returns the object in the form of hash
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_hash(downcase: false)
176
+ hash = {}
177
+ self.class.attribute_map.each_pair do |attr, param|
178
+ value = self.send(attr)
179
+ next if value.nil?
180
+ key = downcase ? attr : param
181
+ hash[key] = _to_hash(value, downcase: downcase)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Returns the object in the form of hash with snake_case
187
+ def to_attributes
188
+ to_hash(downcase: true)
189
+ end
190
+
191
+ # Outputs non-array value in the form of hash
192
+ # For object, use to_hash. Otherwise, just return the value
193
+ # @param [Object] value Any valid value
194
+ # @return [Hash] Returns the value in the form of hash
195
+ def _to_hash(value, downcase: false)
196
+ if value.is_a?(Array)
197
+ value.map do |v|
198
+ v.to_hash(downcase: downcase)
199
+ end
200
+ elsif value.is_a?(Hash)
201
+ {}.tap do |hash|
202
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
203
+ end
204
+ elsif value.respond_to? :to_hash
205
+ value.to_hash(downcase: downcase)
206
+ else
207
+ value
208
+ end
209
+ end
210
+
211
+ def parse_date(datestring)
212
+ if datestring.include?('Date')
213
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
214
+ original, date, timezone = *date_pattern.match(datestring)
215
+ date = (date.to_i / 1000)
216
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
217
+ else # handle date 'types' for small subset of payroll API's
218
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
219
+ end
220
+ end
221
+ end
222
+ end