xero-ruby 0.1.1

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 (349) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +454 -0
  5. data/Rakefile +10 -0
  6. data/docs/Account.md +53 -0
  7. data/docs/AccountType.md +16 -0
  8. data/docs/AccountingApi.md +11269 -0
  9. data/docs/Accounts.md +17 -0
  10. data/docs/AccountsPayable.md +19 -0
  11. data/docs/AccountsReceivable.md +19 -0
  12. data/docs/Address.md +35 -0
  13. data/docs/Allocation.md +21 -0
  14. data/docs/Allocations.md +17 -0
  15. data/docs/Attachment.md +27 -0
  16. data/docs/Attachments.md +17 -0
  17. data/docs/Balances.md +19 -0
  18. data/docs/BankTransaction.md +59 -0
  19. data/docs/BankTransactions.md +17 -0
  20. data/docs/BankTransfer.md +37 -0
  21. data/docs/BankTransfers.md +17 -0
  22. data/docs/BatchPayment.md +47 -0
  23. data/docs/BatchPaymentDetails.md +25 -0
  24. data/docs/BatchPayments.md +17 -0
  25. data/docs/Bill.md +19 -0
  26. data/docs/BrandingTheme.md +23 -0
  27. data/docs/BrandingThemes.md +17 -0
  28. data/docs/CISOrgSetting.md +21 -0
  29. data/docs/CISSetting.md +19 -0
  30. data/docs/CISSettings.md +17 -0
  31. data/docs/Contact.md +91 -0
  32. data/docs/ContactGroup.md +23 -0
  33. data/docs/ContactGroups.md +17 -0
  34. data/docs/ContactPerson.md +23 -0
  35. data/docs/Contacts.md +17 -0
  36. data/docs/CountryCode.md +16 -0
  37. data/docs/CreditNote.md +61 -0
  38. data/docs/CreditNotes.md +17 -0
  39. data/docs/Currencies.md +17 -0
  40. data/docs/Currency.md +19 -0
  41. data/docs/CurrencyCode.md +16 -0
  42. data/docs/Element.md +17 -0
  43. data/docs/Employee.md +27 -0
  44. data/docs/Employees.md +17 -0
  45. data/docs/Error.md +23 -0
  46. data/docs/ExpenseClaim.md +39 -0
  47. data/docs/ExpenseClaims.md +17 -0
  48. data/docs/ExternalLink.md +21 -0
  49. data/docs/HistoryRecord.md +23 -0
  50. data/docs/HistoryRecords.md +17 -0
  51. data/docs/Invoice.md +89 -0
  52. data/docs/InvoiceReminder.md +17 -0
  53. data/docs/InvoiceReminders.md +17 -0
  54. data/docs/Invoices.md +17 -0
  55. data/docs/Item.md +45 -0
  56. data/docs/Items.md +17 -0
  57. data/docs/Journal.md +31 -0
  58. data/docs/JournalLine.md +39 -0
  59. data/docs/Journals.md +17 -0
  60. data/docs/LineAmountTypes.md +16 -0
  61. data/docs/LineItem.md +41 -0
  62. data/docs/LineItemTracking.md +21 -0
  63. data/docs/LinkedTransaction.md +37 -0
  64. data/docs/LinkedTransactions.md +17 -0
  65. data/docs/ManualJournal.md +41 -0
  66. data/docs/ManualJournalLine.md +29 -0
  67. data/docs/ManualJournals.md +17 -0
  68. data/docs/OnlineInvoice.md +17 -0
  69. data/docs/OnlineInvoices.md +17 -0
  70. data/docs/Organisation.md +79 -0
  71. data/docs/Organisations.md +17 -0
  72. data/docs/Overpayment.md +51 -0
  73. data/docs/Overpayments.md +17 -0
  74. data/docs/Payment.md +61 -0
  75. data/docs/PaymentService.md +27 -0
  76. data/docs/PaymentServices.md +17 -0
  77. data/docs/PaymentTerm.md +19 -0
  78. data/docs/PaymentTermType.md +16 -0
  79. data/docs/Payments.md +17 -0
  80. data/docs/Phone.md +23 -0
  81. data/docs/Prepayment.md +49 -0
  82. data/docs/Prepayments.md +17 -0
  83. data/docs/Purchase.md +23 -0
  84. data/docs/PurchaseOrder.md +71 -0
  85. data/docs/PurchaseOrders.md +17 -0
  86. data/docs/Receipt.md +49 -0
  87. data/docs/Receipts.md +17 -0
  88. data/docs/RepeatingInvoice.md +47 -0
  89. data/docs/RepeatingInvoices.md +17 -0
  90. data/docs/Report.md +29 -0
  91. data/docs/ReportAttribute.md +19 -0
  92. data/docs/ReportCell.md +19 -0
  93. data/docs/ReportFields.md +21 -0
  94. data/docs/ReportRow.md +21 -0
  95. data/docs/ReportRows.md +23 -0
  96. data/docs/ReportWithRow.md +33 -0
  97. data/docs/ReportWithRows.md +17 -0
  98. data/docs/Reports.md +17 -0
  99. data/docs/RequestEmpty.md +17 -0
  100. data/docs/RowType.md +16 -0
  101. data/docs/SalesTrackingCategory.md +19 -0
  102. data/docs/Schedule.md +29 -0
  103. data/docs/TaxComponent.md +23 -0
  104. data/docs/TaxRate.md +39 -0
  105. data/docs/TaxRates.md +17 -0
  106. data/docs/TaxType.md +16 -0
  107. data/docs/TenNinteyNineContact.md +59 -0
  108. data/docs/TimeZone.md +16 -0
  109. data/docs/TrackingCategories.md +17 -0
  110. data/docs/TrackingCategory.md +27 -0
  111. data/docs/TrackingOption.md +23 -0
  112. data/docs/TrackingOptions.md +17 -0
  113. data/docs/User.md +29 -0
  114. data/docs/Users.md +17 -0
  115. data/docs/ValidationError.md +17 -0
  116. data/git_push.sh +55 -0
  117. data/lib/.DS_Store +0 -0
  118. data/lib/xero-ruby.rb +149 -0
  119. data/lib/xero-ruby/api/accounting_api.rb +14686 -0
  120. data/lib/xero-ruby/api_client.rb +386 -0
  121. data/lib/xero-ruby/api_error.rb +57 -0
  122. data/lib/xero-ruby/configuration.rb +252 -0
  123. data/lib/xero-ruby/models/account.rb +484 -0
  124. data/lib/xero-ruby/models/account_type.rb +57 -0
  125. data/lib/xero-ruby/models/accounts.rb +205 -0
  126. data/lib/xero-ruby/models/accounts_payable.rb +212 -0
  127. data/lib/xero-ruby/models/accounts_receivable.rb +212 -0
  128. data/lib/xero-ruby/models/address.rb +463 -0
  129. data/lib/xero-ruby/models/allocation.rb +238 -0
  130. data/lib/xero-ruby/models/allocations.rb +205 -0
  131. data/lib/xero-ruby/models/attachment.rb +254 -0
  132. data/lib/xero-ruby/models/attachments.rb +205 -0
  133. data/lib/xero-ruby/models/balances.rb +213 -0
  134. data/lib/xero-ruby/models/bank_transaction.rb +480 -0
  135. data/lib/xero-ruby/models/bank_transactions.rb +205 -0
  136. data/lib/xero-ruby/models/bank_transfer.rb +319 -0
  137. data/lib/xero-ruby/models/bank_transfers.rb +205 -0
  138. data/lib/xero-ruby/models/batch_payment.rb +429 -0
  139. data/lib/xero-ruby/models/batch_payment_details.rb +290 -0
  140. data/lib/xero-ruby/models/batch_payments.rb +205 -0
  141. data/lib/xero-ruby/models/bill.rb +213 -0
  142. data/lib/xero-ruby/models/branding_theme.rb +234 -0
  143. data/lib/xero-ruby/models/branding_themes.rb +205 -0
  144. data/lib/xero-ruby/models/cis_org_setting.rb +224 -0
  145. data/lib/xero-ruby/models/cis_setting.rb +214 -0
  146. data/lib/xero-ruby/models/cis_settings.rb +205 -0
  147. data/lib/xero-ruby/models/contact.rb +724 -0
  148. data/lib/xero-ruby/models/contact_group.rb +270 -0
  149. data/lib/xero-ruby/models/contact_groups.rb +205 -0
  150. data/lib/xero-ruby/models/contact_person.rb +234 -0
  151. data/lib/xero-ruby/models/contacts.rb +205 -0
  152. data/lib/xero-ruby/models/country_code.rb +275 -0
  153. data/lib/xero-ruby/models/credit_note.rb +475 -0
  154. data/lib/xero-ruby/models/credit_notes.rb +205 -0
  155. data/lib/xero-ruby/models/currencies.rb +205 -0
  156. data/lib/xero-ruby/models/currency.rb +213 -0
  157. data/lib/xero-ruby/models/currency_code.rb +197 -0
  158. data/lib/xero-ruby/models/element.rb +206 -0
  159. data/lib/xero-ruby/models/employee.rb +316 -0
  160. data/lib/xero-ruby/models/employees.rb +205 -0
  161. data/lib/xero-ruby/models/error.rb +236 -0
  162. data/lib/xero-ruby/models/expense_claim.rb +350 -0
  163. data/lib/xero-ruby/models/expense_claims.rb +205 -0
  164. data/lib/xero-ruby/models/external_link.rb +257 -0
  165. data/lib/xero-ruby/models/history_record.rb +234 -0
  166. data/lib/xero-ruby/models/history_records.rb +205 -0
  167. data/lib/xero-ruby/models/invoice.rb +666 -0
  168. data/lib/xero-ruby/models/invoice_reminder.rb +204 -0
  169. data/lib/xero-ruby/models/invoice_reminders.rb +205 -0
  170. data/lib/xero-ruby/models/invoices.rb +205 -0
  171. data/lib/xero-ruby/models/item.rb +418 -0
  172. data/lib/xero-ruby/models/items.rb +205 -0
  173. data/lib/xero-ruby/models/journal.rb +310 -0
  174. data/lib/xero-ruby/models/journal_line.rb +315 -0
  175. data/lib/xero-ruby/models/journals.rb +205 -0
  176. data/lib/xero-ruby/models/line_amount_types.rb +38 -0
  177. data/lib/xero-ruby/models/line_item.rb +326 -0
  178. data/lib/xero-ruby/models/line_item_tracking.rb +239 -0
  179. data/lib/xero-ruby/models/linked_transaction.rb +369 -0
  180. data/lib/xero-ruby/models/linked_transactions.rb +205 -0
  181. data/lib/xero-ruby/models/manual_journal.rb +375 -0
  182. data/lib/xero-ruby/models/manual_journal_line.rb +266 -0
  183. data/lib/xero-ruby/models/manual_journals.rb +205 -0
  184. data/lib/xero-ruby/models/online_invoice.rb +204 -0
  185. data/lib/xero-ruby/models/online_invoices.rb +205 -0
  186. data/lib/xero-ruby/models/organisation.rb +622 -0
  187. data/lib/xero-ruby/models/organisations.rb +205 -0
  188. data/lib/xero-ruby/models/overpayment.rb +425 -0
  189. data/lib/xero-ruby/models/overpayments.rb +205 -0
  190. data/lib/xero-ruby/models/payment.rb +467 -0
  191. data/lib/xero-ruby/models/payment_service.rb +256 -0
  192. data/lib/xero-ruby/models/payment_services.rb +205 -0
  193. data/lib/xero-ruby/models/payment_term.rb +212 -0
  194. data/lib/xero-ruby/models/payment_term_type.rb +39 -0
  195. data/lib/xero-ruby/models/payments.rb +205 -0
  196. data/lib/xero-ruby/models/phone.rb +312 -0
  197. data/lib/xero-ruby/models/prepayment.rb +413 -0
  198. data/lib/xero-ruby/models/prepayments.rb +205 -0
  199. data/lib/xero-ruby/models/purchase.rb +234 -0
  200. data/lib/xero-ruby/models/purchase_order.rb +523 -0
  201. data/lib/xero-ruby/models/purchase_orders.rb +205 -0
  202. data/lib/xero-ruby/models/receipt.rb +420 -0
  203. data/lib/xero-ruby/models/receipts.rb +205 -0
  204. data/lib/xero-ruby/models/repeating_invoice.rb +400 -0
  205. data/lib/xero-ruby/models/repeating_invoices.rb +205 -0
  206. data/lib/xero-ruby/models/report.rb +299 -0
  207. data/lib/xero-ruby/models/report_attribute.rb +212 -0
  208. data/lib/xero-ruby/models/report_cell.rb +214 -0
  209. data/lib/xero-ruby/models/report_fields.rb +221 -0
  210. data/lib/xero-ruby/models/report_row.rb +223 -0
  211. data/lib/xero-ruby/models/report_rows.rb +234 -0
  212. data/lib/xero-ruby/models/report_with_row.rb +288 -0
  213. data/lib/xero-ruby/models/report_with_rows.rb +205 -0
  214. data/lib/xero-ruby/models/reports.rb +205 -0
  215. data/lib/xero-ruby/models/request_empty.rb +204 -0
  216. data/lib/xero-ruby/models/row_type.rb +39 -0
  217. data/lib/xero-ruby/models/sales_tracking_category.rb +214 -0
  218. data/lib/xero-ruby/models/schedule.rb +310 -0
  219. data/lib/xero-ruby/models/tax_component.rb +234 -0
  220. data/lib/xero-ruby/models/tax_rate.rb +367 -0
  221. data/lib/xero-ruby/models/tax_rates.rb +205 -0
  222. data/lib/xero-ruby/models/tax_type.rb +87 -0
  223. data/lib/xero-ruby/models/ten_nintey_nine_contact.rb +414 -0
  224. data/lib/xero-ruby/models/time_zone.rb +142 -0
  225. data/lib/xero-ruby/models/tracking_categories.rb +205 -0
  226. data/lib/xero-ruby/models/tracking_category.rb +320 -0
  227. data/lib/xero-ruby/models/tracking_option.rb +283 -0
  228. data/lib/xero-ruby/models/tracking_options.rb +205 -0
  229. data/lib/xero-ruby/models/user.rb +298 -0
  230. data/lib/xero-ruby/models/users.rb +205 -0
  231. data/lib/xero-ruby/models/validation_error.rb +204 -0
  232. data/lib/xero-ruby/version.rb +15 -0
  233. data/pkg/xero-ruby-0.1.0.gem +0 -0
  234. data/pkg/xero-ruby-1.0.0.gem +0 -0
  235. data/spec/api/accounting_api_spec.rb +2322 -0
  236. data/spec/api_client_spec.rb +226 -0
  237. data/spec/configuration_spec.rb +42 -0
  238. data/spec/models/account_spec.rb +165 -0
  239. data/spec/models/account_type_spec.rb +35 -0
  240. data/spec/models/accounts_payable_spec.rb +47 -0
  241. data/spec/models/accounts_receivable_spec.rb +47 -0
  242. data/spec/models/accounts_spec.rb +41 -0
  243. data/spec/models/address_spec.rb +99 -0
  244. data/spec/models/allocation_spec.rb +53 -0
  245. data/spec/models/allocations_spec.rb +41 -0
  246. data/spec/models/attachment_spec.rb +71 -0
  247. data/spec/models/attachments_spec.rb +41 -0
  248. data/spec/models/balances_spec.rb +47 -0
  249. data/spec/models/bank_transaction_spec.rb +175 -0
  250. data/spec/models/bank_transactions_spec.rb +41 -0
  251. data/spec/models/bank_transfer_spec.rb +101 -0
  252. data/spec/models/bank_transfers_spec.rb +41 -0
  253. data/spec/models/batch_payment_details_spec.rb +65 -0
  254. data/spec/models/batch_payment_spec.rb +131 -0
  255. data/spec/models/batch_payments_spec.rb +41 -0
  256. data/spec/models/bill_spec.rb +47 -0
  257. data/spec/models/branding_theme_spec.rb +59 -0
  258. data/spec/models/branding_themes_spec.rb +41 -0
  259. data/spec/models/cis_org_setting_spec.rb +53 -0
  260. data/spec/models/cis_setting_spec.rb +47 -0
  261. data/spec/models/cis_settings_spec.rb +41 -0
  262. data/spec/models/contact_group_spec.rb +63 -0
  263. data/spec/models/contact_groups_spec.rb +41 -0
  264. data/spec/models/contact_person_spec.rb +59 -0
  265. data/spec/models/contact_spec.rb +267 -0
  266. data/spec/models/contacts_spec.rb +41 -0
  267. data/spec/models/country_code_spec.rb +35 -0
  268. data/spec/models/credit_note_spec.rb +181 -0
  269. data/spec/models/credit_notes_spec.rb +41 -0
  270. data/spec/models/currencies_spec.rb +41 -0
  271. data/spec/models/currency_code_spec.rb +35 -0
  272. data/spec/models/currency_spec.rb +47 -0
  273. data/spec/models/element_spec.rb +41 -0
  274. data/spec/models/employee_spec.rb +75 -0
  275. data/spec/models/employees_spec.rb +41 -0
  276. data/spec/models/error_spec.rb +59 -0
  277. data/spec/models/expense_claim_spec.rb +111 -0
  278. data/spec/models/expense_claims_spec.rb +41 -0
  279. data/spec/models/external_link_spec.rb +57 -0
  280. data/spec/models/history_record_spec.rb +59 -0
  281. data/spec/models/history_records_spec.rb +41 -0
  282. data/spec/models/invoice_reminder_spec.rb +41 -0
  283. data/spec/models/invoice_reminders_spec.rb +41 -0
  284. data/spec/models/invoice_spec.rb +259 -0
  285. data/spec/models/invoices_spec.rb +41 -0
  286. data/spec/models/item_spec.rb +125 -0
  287. data/spec/models/items_spec.rb +41 -0
  288. data/spec/models/journal_line_spec.rb +107 -0
  289. data/spec/models/journal_spec.rb +87 -0
  290. data/spec/models/journals_spec.rb +41 -0
  291. data/spec/models/line_amount_types_spec.rb +35 -0
  292. data/spec/models/line_item_spec.rb +107 -0
  293. data/spec/models/line_item_tracking_spec.rb +53 -0
  294. data/spec/models/linked_transaction_spec.rb +113 -0
  295. data/spec/models/linked_transactions_spec.rb +41 -0
  296. data/spec/models/manual_journal_line_spec.rb +77 -0
  297. data/spec/models/manual_journal_spec.rb +117 -0
  298. data/spec/models/manual_journals_spec.rb +41 -0
  299. data/spec/models/online_invoice_spec.rb +41 -0
  300. data/spec/models/online_invoices_spec.rb +41 -0
  301. data/spec/models/organisation_spec.rb +255 -0
  302. data/spec/models/organisations_spec.rb +41 -0
  303. data/spec/models/overpayment_spec.rb +151 -0
  304. data/spec/models/overpayments_spec.rb +41 -0
  305. data/spec/models/payment_service_spec.rb +71 -0
  306. data/spec/models/payment_services_spec.rb +41 -0
  307. data/spec/models/payment_spec.rb +181 -0
  308. data/spec/models/payment_term_spec.rb +47 -0
  309. data/spec/models/payment_term_type_spec.rb +35 -0
  310. data/spec/models/payments_spec.rb +41 -0
  311. data/spec/models/phone_spec.rb +63 -0
  312. data/spec/models/prepayment_spec.rb +145 -0
  313. data/spec/models/prepayments_spec.rb +41 -0
  314. data/spec/models/purchase_order_spec.rb +207 -0
  315. data/spec/models/purchase_orders_spec.rb +41 -0
  316. data/spec/models/purchase_spec.rb +59 -0
  317. data/spec/models/receipt_spec.rb +141 -0
  318. data/spec/models/receipts_spec.rb +41 -0
  319. data/spec/models/repeating_invoice_spec.rb +139 -0
  320. data/spec/models/repeating_invoices_spec.rb +41 -0
  321. data/spec/models/report_attribute_spec.rb +47 -0
  322. data/spec/models/report_cell_spec.rb +47 -0
  323. data/spec/models/report_fields_spec.rb +53 -0
  324. data/spec/models/report_row_spec.rb +53 -0
  325. data/spec/models/report_rows_spec.rb +59 -0
  326. data/spec/models/report_spec.rb +81 -0
  327. data/spec/models/report_with_row_spec.rb +89 -0
  328. data/spec/models/report_with_rows_spec.rb +41 -0
  329. data/spec/models/reports_spec.rb +41 -0
  330. data/spec/models/request_empty_spec.rb +41 -0
  331. data/spec/models/row_type_spec.rb +35 -0
  332. data/spec/models/sales_tracking_category_spec.rb +47 -0
  333. data/spec/models/schedule_spec.rb +85 -0
  334. data/spec/models/tax_component_spec.rb +59 -0
  335. data/spec/models/tax_rate_spec.rb +115 -0
  336. data/spec/models/tax_rates_spec.rb +41 -0
  337. data/spec/models/tax_type_spec.rb +35 -0
  338. data/spec/models/ten_nintey_nine_contact_spec.rb +167 -0
  339. data/spec/models/time_zone_spec.rb +35 -0
  340. data/spec/models/tracking_categories_spec.rb +41 -0
  341. data/spec/models/tracking_category_spec.rb +75 -0
  342. data/spec/models/tracking_option_spec.rb +63 -0
  343. data/spec/models/tracking_options_spec.rb +41 -0
  344. data/spec/models/user_spec.rb +81 -0
  345. data/spec/models/users_spec.rb +41 -0
  346. data/spec/models/validation_error_spec.rb +41 -0
  347. data/spec/spec_helper.rb +111 -0
  348. data/xero-ruby.gemspec +39 -0
  349. metadata +563 -0
@@ -0,0 +1,205 @@
1
+ =begin
2
+ #Accounting API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: api@xero.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.3
10
+
11
+ =end
12
+
13
+ require 'time'
14
+ require 'date'
15
+
16
+ module XeroRuby
17
+ class Prepayments
18
+ attr_accessor :prepayments
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'prepayments' => :'Prepayments'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'prepayments' => :'Array<Prepayment>'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ if (!attributes.is_a?(Hash))
38
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Prepayments` initialize method"
39
+ end
40
+
41
+ # check to see if the attribute exists and convert string to symbol for hash key
42
+ attributes = attributes.each_with_object({}) { |(k, v), h|
43
+ if (!self.class.attribute_map.key?(k.to_sym))
44
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Prepayments`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
45
+ end
46
+ h[k.to_sym] = v
47
+ }
48
+
49
+ if attributes.key?(:'prepayments')
50
+ if (value = attributes[:'prepayments']).is_a?(Array)
51
+ self.prepayments = value
52
+ end
53
+ end
54
+ end
55
+
56
+ # Show invalid properties with the reasons. Usually used together with valid?
57
+ # @return Array for valid properties with the reasons
58
+ def list_invalid_properties
59
+ invalid_properties = Array.new
60
+ invalid_properties
61
+ end
62
+
63
+ # Check to see if the all the properties in the model are valid
64
+ # @return true if the model is valid
65
+ def valid?
66
+ true
67
+ end
68
+
69
+ # Checks equality by comparing each attribute.
70
+ # @param [Object] Object to be compared
71
+ def ==(o)
72
+ return true if self.equal?(o)
73
+ self.class == o.class &&
74
+ prepayments == o.prepayments
75
+ end
76
+
77
+ # @see the `==` method
78
+ # @param [Object] Object to be compared
79
+ def eql?(o)
80
+ self == o
81
+ end
82
+
83
+ # Calculates hash code according to all attributes.
84
+ # @return [Integer] Hash code
85
+ def hash
86
+ [prepayments].hash
87
+ end
88
+
89
+ # Builds the object from hash
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ # @return [Object] Returns the model itself
92
+ def self.build_from_hash(attributes)
93
+ new.build_from_hash(attributes)
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def build_from_hash(attributes)
100
+ return nil unless attributes.is_a?(Hash)
101
+ self.class.openapi_types.each_pair do |key, type|
102
+ if type =~ /\AArray<(.*)>/i
103
+ # check to ensure the input is an array given that the attribute
104
+ # is documented as an array but the input is not
105
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
106
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
107
+ end
108
+ elsif !attributes[self.class.attribute_map[key]].nil?
109
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
110
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
111
+ end
112
+
113
+ self
114
+ end
115
+
116
+ # Deserializes the data based on type
117
+ # @param string type Data type
118
+ # @param string value Value to be deserialized
119
+ # @return [Object] Deserialized data
120
+ def _deserialize(type, value)
121
+ case type.to_sym
122
+ when :DateTime
123
+ DateTime.parse(parse_date(value))
124
+ when :Date
125
+ Date._iso8601(parse_date(value))
126
+ when :String
127
+ value.to_s
128
+ when :Integer
129
+ value.to_i
130
+ when :Float
131
+ value.to_f
132
+ when :Boolean
133
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
134
+ true
135
+ else
136
+ false
137
+ end
138
+ when :Object
139
+ # generic object (usually a Hash), return directly
140
+ value
141
+ when /\AArray<(?<inner_type>.+)>\z/
142
+ inner_type = Regexp.last_match[:inner_type]
143
+ value.map { |v| _deserialize(inner_type, v) }
144
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
145
+ k_type = Regexp.last_match[:k_type]
146
+ v_type = Regexp.last_match[:v_type]
147
+ {}.tap do |hash|
148
+ value.each do |k, v|
149
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
150
+ end
151
+ end
152
+ else # model
153
+ XeroRuby.const_get(type).build_from_hash(value)
154
+ end
155
+ end
156
+
157
+ # Returns the string representation of the object
158
+ # @return [String] String presentation of the object
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_hash (backward compatibility)
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_body
166
+ to_hash
167
+ end
168
+
169
+ # Returns the object in the form of hash
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_hash
172
+ hash = {}
173
+ self.class.attribute_map.each_pair do |attr, param|
174
+ value = self.send(attr)
175
+ next if value.nil?
176
+ hash[param] = _to_hash(value)
177
+ end
178
+ hash
179
+ end
180
+
181
+ # Outputs non-array value in the form of hash
182
+ # For object, use to_hash. Otherwise, just return the value
183
+ # @param [Object] value Any valid value
184
+ # @return [Hash] Returns the value in the form of hash
185
+ def _to_hash(value)
186
+ if value.is_a?(Array)
187
+ value.compact.map { |v| _to_hash(v) }
188
+ elsif value.is_a?(Hash)
189
+ {}.tap do |hash|
190
+ value.each { |k, v| hash[k] = _to_hash(v) }
191
+ end
192
+ elsif value.respond_to? :to_hash
193
+ value.to_hash
194
+ else
195
+ value
196
+ end
197
+ end
198
+
199
+ # customized data_parser
200
+ def parse_date(datestring)
201
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
202
+ return Time.at(seconds_since_epoch).to_s
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,234 @@
1
+ =begin
2
+ #Accounting API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: api@xero.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.3
10
+
11
+ =end
12
+
13
+ require 'time'
14
+ require 'date'
15
+
16
+ module XeroRuby
17
+ class Purchase
18
+ # Unit Price of the item. By default UnitPrice is rounded to two decimal places. You can use 4 decimal places by adding the unitdp=4 querystring parameter to your request.
19
+ attr_accessor :unit_price
20
+
21
+ # Default account code to be used for purchased/sale. Not applicable to the purchase details of tracked items
22
+ attr_accessor :account_code
23
+
24
+ # Cost of goods sold account. Only applicable to the purchase details of tracked items.
25
+ attr_accessor :cogs_account_code
26
+
27
+ # The tax type from TaxRates
28
+ attr_accessor :tax_type
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'unit_price' => :'UnitPrice',
34
+ :'account_code' => :'AccountCode',
35
+ :'cogs_account_code' => :'COGSAccountCode',
36
+ :'tax_type' => :'TaxType'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'unit_price' => :'Float',
44
+ :'account_code' => :'String',
45
+ :'cogs_account_code' => :'String',
46
+ :'tax_type' => :'String'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Purchase` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Purchase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'unit_price')
66
+ self.unit_price = attributes[:'unit_price']
67
+ end
68
+
69
+ if attributes.key?(:'account_code')
70
+ self.account_code = attributes[:'account_code']
71
+ end
72
+
73
+ if attributes.key?(:'cogs_account_code')
74
+ self.cogs_account_code = attributes[:'cogs_account_code']
75
+ end
76
+
77
+ if attributes.key?(:'tax_type')
78
+ self.tax_type = attributes[:'tax_type']
79
+ end
80
+ end
81
+
82
+ # Show invalid properties with the reasons. Usually used together with valid?
83
+ # @return Array for valid properties with the reasons
84
+ def list_invalid_properties
85
+ invalid_properties = Array.new
86
+ invalid_properties
87
+ end
88
+
89
+ # Check to see if the all the properties in the model are valid
90
+ # @return true if the model is valid
91
+ def valid?
92
+ true
93
+ end
94
+
95
+ # Checks equality by comparing each attribute.
96
+ # @param [Object] Object to be compared
97
+ def ==(o)
98
+ return true if self.equal?(o)
99
+ self.class == o.class &&
100
+ unit_price == o.unit_price &&
101
+ account_code == o.account_code &&
102
+ cogs_account_code == o.cogs_account_code &&
103
+ tax_type == o.tax_type
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Integer] Hash code
114
+ def hash
115
+ [unit_price, account_code, cogs_account_code, tax_type].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ new.build_from_hash(attributes)
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ self.class.openapi_types.each_pair do |key, type|
131
+ if type =~ /\AArray<(.*)>/i
132
+ # check to ensure the input is an array given that the attribute
133
+ # is documented as an array but the input is not
134
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
135
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
136
+ end
137
+ elsif !attributes[self.class.attribute_map[key]].nil?
138
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
139
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
140
+ end
141
+
142
+ self
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def _deserialize(type, value)
150
+ case type.to_sym
151
+ when :DateTime
152
+ DateTime.parse(parse_date(value))
153
+ when :Date
154
+ Date._iso8601(parse_date(value))
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ XeroRuby.const_get(type).build_from_hash(value)
183
+ end
184
+ end
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # to_body is an alias to to_hash (backward compatibility)
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_body
195
+ to_hash
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ self.class.attribute_map.each_pair do |attr, param|
203
+ value = self.send(attr)
204
+ next if value.nil?
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+
228
+ # customized data_parser
229
+ def parse_date(datestring)
230
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
231
+ return Time.at(seconds_since_epoch).to_s
232
+ end
233
+ end
234
+ end
@@ -0,0 +1,523 @@
1
+ =begin
2
+ #Accounting API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: api@xero.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.3
10
+
11
+ =end
12
+
13
+ require 'time'
14
+ require 'date'
15
+
16
+ module XeroRuby
17
+ class PurchaseOrder
18
+ attr_accessor :contact
19
+
20
+ # See LineItems
21
+ attr_accessor :line_items
22
+
23
+ # Date purchase order was issued – YYYY-MM-DD. If the Date element is not specified then it will default to the current date based on the timezone setting of the organisation
24
+ attr_accessor :date
25
+
26
+ # Date the goods are to be delivered – YYYY-MM-DD
27
+ attr_accessor :delivery_date
28
+
29
+ attr_accessor :line_amount_types
30
+
31
+ # Unique alpha numeric code identifying purchase order (when missing will auto-generate from your Organisation Invoice Settings)
32
+ attr_accessor :purchase_order_number
33
+
34
+ # Additional reference number
35
+ attr_accessor :reference
36
+
37
+ # See BrandingThemes
38
+ attr_accessor :branding_theme_id
39
+
40
+ attr_accessor :currency_code
41
+
42
+ # See Purchase Order Status Codes
43
+ attr_accessor :status
44
+
45
+ # Boolean to set whether the purchase order should be marked as “sent”. This can be set only on purchase orders that have been approved or billed
46
+ attr_accessor :sent_to_contact
47
+
48
+ # The address the goods are to be delivered to
49
+ attr_accessor :delivery_address
50
+
51
+ # The person that the delivery is going to
52
+ attr_accessor :attention_to
53
+
54
+ # The phone number for the person accepting the delivery
55
+ attr_accessor :telephone
56
+
57
+ # A free text feild for instructions (500 characters max)
58
+ attr_accessor :delivery_instructions
59
+
60
+ # The date the goods are expected to arrive.
61
+ attr_accessor :expected_arrival_date
62
+
63
+ # Xero generated unique identifier for purchase order
64
+ attr_accessor :purchase_order_id
65
+
66
+ # The currency rate for a multicurrency purchase order. As no rate can be specified, the XE.com day rate is used.
67
+ attr_accessor :currency_rate
68
+
69
+ # Total of purchase order excluding taxes
70
+ attr_accessor :sub_total
71
+
72
+ # Total tax on purchase order
73
+ attr_accessor :total_tax
74
+
75
+ # Total of Purchase Order tax inclusive (i.e. SubTotal + TotalTax)
76
+ attr_accessor :total
77
+
78
+ # Total of discounts applied on the purchase order line items
79
+ attr_accessor :total_discount
80
+
81
+ # boolean to indicate if a purchase order has an attachment
82
+ attr_accessor :has_attachments
83
+
84
+ # Last modified date UTC format
85
+ attr_accessor :updated_date_utc
86
+
87
+ # A string to indicate if a invoice status
88
+ attr_accessor :status_attribute_string
89
+
90
+ # Displays array of validation error messages from the API
91
+ attr_accessor :validation_errors
92
+
93
+ # Displays array of warning messages from the API
94
+ attr_accessor :warnings
95
+
96
+ # Displays array of attachments from the API
97
+ attr_accessor :attachments
98
+
99
+ class EnumAttributeValidator
100
+ attr_reader :datatype
101
+ attr_reader :allowable_values
102
+
103
+ def initialize(datatype, allowable_values)
104
+ @allowable_values = allowable_values.map do |value|
105
+ case datatype.to_s
106
+ when /Integer/i
107
+ value.to_i
108
+ when /Float/i
109
+ value.to_f
110
+ else
111
+ value
112
+ end
113
+ end
114
+ end
115
+
116
+ def valid?(value)
117
+ !value || allowable_values.include?(value)
118
+ end
119
+ end
120
+
121
+ # Attribute mapping from ruby-style variable name to JSON key.
122
+ def self.attribute_map
123
+ {
124
+ :'contact' => :'Contact',
125
+ :'line_items' => :'LineItems',
126
+ :'date' => :'Date',
127
+ :'delivery_date' => :'DeliveryDate',
128
+ :'line_amount_types' => :'LineAmountTypes',
129
+ :'purchase_order_number' => :'PurchaseOrderNumber',
130
+ :'reference' => :'Reference',
131
+ :'branding_theme_id' => :'BrandingThemeID',
132
+ :'currency_code' => :'CurrencyCode',
133
+ :'status' => :'Status',
134
+ :'sent_to_contact' => :'SentToContact',
135
+ :'delivery_address' => :'DeliveryAddress',
136
+ :'attention_to' => :'AttentionTo',
137
+ :'telephone' => :'Telephone',
138
+ :'delivery_instructions' => :'DeliveryInstructions',
139
+ :'expected_arrival_date' => :'ExpectedArrivalDate',
140
+ :'purchase_order_id' => :'PurchaseOrderID',
141
+ :'currency_rate' => :'CurrencyRate',
142
+ :'sub_total' => :'SubTotal',
143
+ :'total_tax' => :'TotalTax',
144
+ :'total' => :'Total',
145
+ :'total_discount' => :'TotalDiscount',
146
+ :'has_attachments' => :'HasAttachments',
147
+ :'updated_date_utc' => :'UpdatedDateUTC',
148
+ :'status_attribute_string' => :'StatusAttributeString',
149
+ :'validation_errors' => :'ValidationErrors',
150
+ :'warnings' => :'Warnings',
151
+ :'attachments' => :'Attachments'
152
+ }
153
+ end
154
+
155
+ # Attribute type mapping.
156
+ def self.openapi_types
157
+ {
158
+ :'contact' => :'Contact',
159
+ :'line_items' => :'Array<LineItem>',
160
+ :'date' => :'Date',
161
+ :'delivery_date' => :'Date',
162
+ :'line_amount_types' => :'LineAmountTypes',
163
+ :'purchase_order_number' => :'String',
164
+ :'reference' => :'String',
165
+ :'branding_theme_id' => :'String',
166
+ :'currency_code' => :'CurrencyCode',
167
+ :'status' => :'String',
168
+ :'sent_to_contact' => :'Boolean',
169
+ :'delivery_address' => :'String',
170
+ :'attention_to' => :'String',
171
+ :'telephone' => :'String',
172
+ :'delivery_instructions' => :'String',
173
+ :'expected_arrival_date' => :'Date',
174
+ :'purchase_order_id' => :'String',
175
+ :'currency_rate' => :'Float',
176
+ :'sub_total' => :'Float',
177
+ :'total_tax' => :'Float',
178
+ :'total' => :'Float',
179
+ :'total_discount' => :'Float',
180
+ :'has_attachments' => :'Boolean',
181
+ :'updated_date_utc' => :'DateTime',
182
+ :'status_attribute_string' => :'String',
183
+ :'validation_errors' => :'Array<ValidationError>',
184
+ :'warnings' => :'Array<ValidationError>',
185
+ :'attachments' => :'Array<Attachment>'
186
+ }
187
+ end
188
+
189
+ # Initializes the object
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ def initialize(attributes = {})
192
+ if (!attributes.is_a?(Hash))
193
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::PurchaseOrder` initialize method"
194
+ end
195
+
196
+ # check to see if the attribute exists and convert string to symbol for hash key
197
+ attributes = attributes.each_with_object({}) { |(k, v), h|
198
+ if (!self.class.attribute_map.key?(k.to_sym))
199
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::PurchaseOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
200
+ end
201
+ h[k.to_sym] = v
202
+ }
203
+
204
+ if attributes.key?(:'contact')
205
+ self.contact = attributes[:'contact']
206
+ end
207
+
208
+ if attributes.key?(:'line_items')
209
+ if (value = attributes[:'line_items']).is_a?(Array)
210
+ self.line_items = value
211
+ end
212
+ end
213
+
214
+ if attributes.key?(:'date')
215
+ self.date = attributes[:'date']
216
+ end
217
+
218
+ if attributes.key?(:'delivery_date')
219
+ self.delivery_date = attributes[:'delivery_date']
220
+ end
221
+
222
+ if attributes.key?(:'line_amount_types')
223
+ self.line_amount_types = attributes[:'line_amount_types']
224
+ end
225
+
226
+ if attributes.key?(:'purchase_order_number')
227
+ self.purchase_order_number = attributes[:'purchase_order_number']
228
+ end
229
+
230
+ if attributes.key?(:'reference')
231
+ self.reference = attributes[:'reference']
232
+ end
233
+
234
+ if attributes.key?(:'branding_theme_id')
235
+ self.branding_theme_id = attributes[:'branding_theme_id']
236
+ end
237
+
238
+ if attributes.key?(:'currency_code')
239
+ self.currency_code = attributes[:'currency_code']
240
+ end
241
+
242
+ if attributes.key?(:'status')
243
+ self.status = attributes[:'status']
244
+ end
245
+
246
+ if attributes.key?(:'sent_to_contact')
247
+ self.sent_to_contact = attributes[:'sent_to_contact']
248
+ end
249
+
250
+ if attributes.key?(:'delivery_address')
251
+ self.delivery_address = attributes[:'delivery_address']
252
+ end
253
+
254
+ if attributes.key?(:'attention_to')
255
+ self.attention_to = attributes[:'attention_to']
256
+ end
257
+
258
+ if attributes.key?(:'telephone')
259
+ self.telephone = attributes[:'telephone']
260
+ end
261
+
262
+ if attributes.key?(:'delivery_instructions')
263
+ self.delivery_instructions = attributes[:'delivery_instructions']
264
+ end
265
+
266
+ if attributes.key?(:'expected_arrival_date')
267
+ self.expected_arrival_date = attributes[:'expected_arrival_date']
268
+ end
269
+
270
+ if attributes.key?(:'purchase_order_id')
271
+ self.purchase_order_id = attributes[:'purchase_order_id']
272
+ end
273
+
274
+ if attributes.key?(:'currency_rate')
275
+ self.currency_rate = attributes[:'currency_rate']
276
+ end
277
+
278
+ if attributes.key?(:'sub_total')
279
+ self.sub_total = attributes[:'sub_total']
280
+ end
281
+
282
+ if attributes.key?(:'total_tax')
283
+ self.total_tax = attributes[:'total_tax']
284
+ end
285
+
286
+ if attributes.key?(:'total')
287
+ self.total = attributes[:'total']
288
+ end
289
+
290
+ if attributes.key?(:'total_discount')
291
+ self.total_discount = attributes[:'total_discount']
292
+ end
293
+
294
+ if attributes.key?(:'has_attachments')
295
+ self.has_attachments = attributes[:'has_attachments']
296
+ end
297
+
298
+ if attributes.key?(:'updated_date_utc')
299
+ self.updated_date_utc = attributes[:'updated_date_utc']
300
+ end
301
+
302
+ if attributes.key?(:'status_attribute_string')
303
+ self.status_attribute_string = attributes[:'status_attribute_string']
304
+ end
305
+
306
+ if attributes.key?(:'validation_errors')
307
+ if (value = attributes[:'validation_errors']).is_a?(Array)
308
+ self.validation_errors = value
309
+ end
310
+ end
311
+
312
+ if attributes.key?(:'warnings')
313
+ if (value = attributes[:'warnings']).is_a?(Array)
314
+ self.warnings = value
315
+ end
316
+ end
317
+
318
+ if attributes.key?(:'attachments')
319
+ if (value = attributes[:'attachments']).is_a?(Array)
320
+ self.attachments = value
321
+ end
322
+ end
323
+ end
324
+
325
+ # Show invalid properties with the reasons. Usually used together with valid?
326
+ # @return Array for valid properties with the reasons
327
+ def list_invalid_properties
328
+ invalid_properties = Array.new
329
+ if @contact.nil?
330
+ invalid_properties.push('invalid value for "contact", contact cannot be nil.')
331
+ end
332
+
333
+ if @line_items.nil?
334
+ invalid_properties.push('invalid value for "line_items", line_items cannot be nil.')
335
+ end
336
+
337
+ invalid_properties
338
+ end
339
+
340
+ # Check to see if the all the properties in the model are valid
341
+ # @return true if the model is valid
342
+ def valid?
343
+ return false if @contact.nil?
344
+ return false if @line_items.nil?
345
+ status_validator = EnumAttributeValidator.new('String', ["DRAFT", "SUBMITTED", "AUTHORISED", "BILLED", "DELETED"])
346
+ return false unless status_validator.valid?(@status)
347
+ true
348
+ end
349
+
350
+ # Custom attribute writer method checking allowed values (enum).
351
+ # @param [Object] status Object to be assigned
352
+ def status=(status)
353
+ validator = EnumAttributeValidator.new('String', ["DRAFT", "SUBMITTED", "AUTHORISED", "BILLED", "DELETED"])
354
+ unless validator.valid?(status)
355
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
356
+ end
357
+ @status = status
358
+ end
359
+
360
+ # Checks equality by comparing each attribute.
361
+ # @param [Object] Object to be compared
362
+ def ==(o)
363
+ return true if self.equal?(o)
364
+ self.class == o.class &&
365
+ contact == o.contact &&
366
+ line_items == o.line_items &&
367
+ date == o.date &&
368
+ delivery_date == o.delivery_date &&
369
+ line_amount_types == o.line_amount_types &&
370
+ purchase_order_number == o.purchase_order_number &&
371
+ reference == o.reference &&
372
+ branding_theme_id == o.branding_theme_id &&
373
+ currency_code == o.currency_code &&
374
+ status == o.status &&
375
+ sent_to_contact == o.sent_to_contact &&
376
+ delivery_address == o.delivery_address &&
377
+ attention_to == o.attention_to &&
378
+ telephone == o.telephone &&
379
+ delivery_instructions == o.delivery_instructions &&
380
+ expected_arrival_date == o.expected_arrival_date &&
381
+ purchase_order_id == o.purchase_order_id &&
382
+ currency_rate == o.currency_rate &&
383
+ sub_total == o.sub_total &&
384
+ total_tax == o.total_tax &&
385
+ total == o.total &&
386
+ total_discount == o.total_discount &&
387
+ has_attachments == o.has_attachments &&
388
+ updated_date_utc == o.updated_date_utc &&
389
+ status_attribute_string == o.status_attribute_string &&
390
+ validation_errors == o.validation_errors &&
391
+ warnings == o.warnings &&
392
+ attachments == o.attachments
393
+ end
394
+
395
+ # @see the `==` method
396
+ # @param [Object] Object to be compared
397
+ def eql?(o)
398
+ self == o
399
+ end
400
+
401
+ # Calculates hash code according to all attributes.
402
+ # @return [Integer] Hash code
403
+ def hash
404
+ [contact, line_items, date, delivery_date, line_amount_types, purchase_order_number, reference, branding_theme_id, currency_code, status, sent_to_contact, delivery_address, attention_to, telephone, delivery_instructions, expected_arrival_date, purchase_order_id, currency_rate, sub_total, total_tax, total, total_discount, has_attachments, updated_date_utc, status_attribute_string, validation_errors, warnings, attachments].hash
405
+ end
406
+
407
+ # Builds the object from hash
408
+ # @param [Hash] attributes Model attributes in the form of hash
409
+ # @return [Object] Returns the model itself
410
+ def self.build_from_hash(attributes)
411
+ new.build_from_hash(attributes)
412
+ end
413
+
414
+ # Builds the object from hash
415
+ # @param [Hash] attributes Model attributes in the form of hash
416
+ # @return [Object] Returns the model itself
417
+ def build_from_hash(attributes)
418
+ return nil unless attributes.is_a?(Hash)
419
+ self.class.openapi_types.each_pair do |key, type|
420
+ if type =~ /\AArray<(.*)>/i
421
+ # check to ensure the input is an array given that the attribute
422
+ # is documented as an array but the input is not
423
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
424
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
425
+ end
426
+ elsif !attributes[self.class.attribute_map[key]].nil?
427
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
428
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
429
+ end
430
+
431
+ self
432
+ end
433
+
434
+ # Deserializes the data based on type
435
+ # @param string type Data type
436
+ # @param string value Value to be deserialized
437
+ # @return [Object] Deserialized data
438
+ def _deserialize(type, value)
439
+ case type.to_sym
440
+ when :DateTime
441
+ DateTime.parse(parse_date(value))
442
+ when :Date
443
+ Date._iso8601(parse_date(value))
444
+ when :String
445
+ value.to_s
446
+ when :Integer
447
+ value.to_i
448
+ when :Float
449
+ value.to_f
450
+ when :Boolean
451
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
452
+ true
453
+ else
454
+ false
455
+ end
456
+ when :Object
457
+ # generic object (usually a Hash), return directly
458
+ value
459
+ when /\AArray<(?<inner_type>.+)>\z/
460
+ inner_type = Regexp.last_match[:inner_type]
461
+ value.map { |v| _deserialize(inner_type, v) }
462
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
463
+ k_type = Regexp.last_match[:k_type]
464
+ v_type = Regexp.last_match[:v_type]
465
+ {}.tap do |hash|
466
+ value.each do |k, v|
467
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
468
+ end
469
+ end
470
+ else # model
471
+ XeroRuby.const_get(type).build_from_hash(value)
472
+ end
473
+ end
474
+
475
+ # Returns the string representation of the object
476
+ # @return [String] String presentation of the object
477
+ def to_s
478
+ to_hash.to_s
479
+ end
480
+
481
+ # to_body is an alias to to_hash (backward compatibility)
482
+ # @return [Hash] Returns the object in the form of hash
483
+ def to_body
484
+ to_hash
485
+ end
486
+
487
+ # Returns the object in the form of hash
488
+ # @return [Hash] Returns the object in the form of hash
489
+ def to_hash
490
+ hash = {}
491
+ self.class.attribute_map.each_pair do |attr, param|
492
+ value = self.send(attr)
493
+ next if value.nil?
494
+ hash[param] = _to_hash(value)
495
+ end
496
+ hash
497
+ end
498
+
499
+ # Outputs non-array value in the form of hash
500
+ # For object, use to_hash. Otherwise, just return the value
501
+ # @param [Object] value Any valid value
502
+ # @return [Hash] Returns the value in the form of hash
503
+ def _to_hash(value)
504
+ if value.is_a?(Array)
505
+ value.compact.map { |v| _to_hash(v) }
506
+ elsif value.is_a?(Hash)
507
+ {}.tap do |hash|
508
+ value.each { |k, v| hash[k] = _to_hash(v) }
509
+ end
510
+ elsif value.respond_to? :to_hash
511
+ value.to_hash
512
+ else
513
+ value
514
+ end
515
+ end
516
+
517
+ # customized data_parser
518
+ def parse_date(datestring)
519
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
520
+ return Time.at(seconds_since_epoch).to_s
521
+ end
522
+ end
523
+ end