xero-ruby 3.0.0 → 3.3.0

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