xero-ruby 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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,204 @@
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 OnlineInvoice
18
+ # the URL to an online invoice
19
+ attr_accessor :online_invoice_url
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'online_invoice_url' => :'OnlineInvoiceUrl'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'online_invoice_url' => :'String'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ if (!attributes.is_a?(Hash))
39
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::OnlineInvoice` initialize method"
40
+ end
41
+
42
+ # check to see if the attribute exists and convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h|
44
+ if (!self.class.attribute_map.key?(k.to_sym))
45
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::OnlineInvoice`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
46
+ end
47
+ h[k.to_sym] = v
48
+ }
49
+
50
+ if attributes.key?(:'online_invoice_url')
51
+ self.online_invoice_url = attributes[:'online_invoice_url']
52
+ end
53
+ end
54
+
55
+ # Show invalid properties with the reasons. Usually used together with valid?
56
+ # @return Array for valid properties with the reasons
57
+ def list_invalid_properties
58
+ invalid_properties = Array.new
59
+ invalid_properties
60
+ end
61
+
62
+ # Check to see if the all the properties in the model are valid
63
+ # @return true if the model is valid
64
+ def valid?
65
+ true
66
+ end
67
+
68
+ # Checks equality by comparing each attribute.
69
+ # @param [Object] Object to be compared
70
+ def ==(o)
71
+ return true if self.equal?(o)
72
+ self.class == o.class &&
73
+ online_invoice_url == o.online_invoice_url
74
+ end
75
+
76
+ # @see the `==` method
77
+ # @param [Object] Object to be compared
78
+ def eql?(o)
79
+ self == o
80
+ end
81
+
82
+ # Calculates hash code according to all attributes.
83
+ # @return [Integer] Hash code
84
+ def hash
85
+ [online_invoice_url].hash
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def self.build_from_hash(attributes)
92
+ new.build_from_hash(attributes)
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def build_from_hash(attributes)
99
+ return nil unless attributes.is_a?(Hash)
100
+ self.class.openapi_types.each_pair do |key, type|
101
+ if type =~ /\AArray<(.*)>/i
102
+ # check to ensure the input is an array given that the attribute
103
+ # is documented as an array but the input is not
104
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
105
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
106
+ end
107
+ elsif !attributes[self.class.attribute_map[key]].nil?
108
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
109
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
110
+ end
111
+
112
+ self
113
+ end
114
+
115
+ # Deserializes the data based on type
116
+ # @param string type Data type
117
+ # @param string value Value to be deserialized
118
+ # @return [Object] Deserialized data
119
+ def _deserialize(type, value)
120
+ case type.to_sym
121
+ when :DateTime
122
+ DateTime.parse(parse_date(value))
123
+ when :Date
124
+ Date._iso8601(parse_date(value))
125
+ when :String
126
+ value.to_s
127
+ when :Integer
128
+ value.to_i
129
+ when :Float
130
+ value.to_f
131
+ when :Boolean
132
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
133
+ true
134
+ else
135
+ false
136
+ end
137
+ when :Object
138
+ # generic object (usually a Hash), return directly
139
+ value
140
+ when /\AArray<(?<inner_type>.+)>\z/
141
+ inner_type = Regexp.last_match[:inner_type]
142
+ value.map { |v| _deserialize(inner_type, v) }
143
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
144
+ k_type = Regexp.last_match[:k_type]
145
+ v_type = Regexp.last_match[:v_type]
146
+ {}.tap do |hash|
147
+ value.each do |k, v|
148
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
149
+ end
150
+ end
151
+ else # model
152
+ XeroRuby.const_get(type).build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # Returns the object in the form of hash
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_hash
171
+ hash = {}
172
+ self.class.attribute_map.each_pair do |attr, param|
173
+ value = self.send(attr)
174
+ next if value.nil?
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map { |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ # customized data_parser
199
+ def parse_date(datestring)
200
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
201
+ return Time.at(seconds_since_epoch).to_s
202
+ end
203
+ end
204
+ end
@@ -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 OnlineInvoices
18
+ attr_accessor :online_invoices
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'online_invoices' => :'OnlineInvoices'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'online_invoices' => :'Array<OnlineInvoice>'
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::OnlineInvoices` 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::OnlineInvoices`. 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?(:'online_invoices')
50
+ if (value = attributes[:'online_invoices']).is_a?(Array)
51
+ self.online_invoices = 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
+ online_invoices == o.online_invoices
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
+ [online_invoices].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,622 @@
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 Organisation
18
+ # Unique Xero identifier
19
+ attr_accessor :organisation_id
20
+
21
+ # Display a unique key used for Xero-to-Xero transactions
22
+ attr_accessor :api_key
23
+
24
+ # Display name of organisation shown in Xero
25
+ attr_accessor :name
26
+
27
+ # Organisation name shown on Reports
28
+ attr_accessor :legal_name
29
+
30
+ # Boolean to describe if organisation is registered with a local tax authority i.e. true, false
31
+ attr_accessor :pays_tax
32
+
33
+ # See Version Types
34
+ attr_accessor :version
35
+
36
+ # Organisation Type
37
+ attr_accessor :organisation_type
38
+
39
+ attr_accessor :base_currency
40
+
41
+ attr_accessor :country_code
42
+
43
+ # Boolean to describe if organisation is a demo company.
44
+ attr_accessor :is_demo_company
45
+
46
+ # Will be set to ACTIVE if you can connect to organisation via the Xero API
47
+ attr_accessor :organisation_status
48
+
49
+ # Shows for New Zealand, Australian and UK organisations
50
+ attr_accessor :registration_number
51
+
52
+ # Shown if set. Displays in the Xero UI as Tax File Number (AU), GST Number (NZ), VAT Number (UK) and Tax ID Number (US & Global).
53
+ attr_accessor :tax_number
54
+
55
+ # Calendar day e.g. 0-31
56
+ attr_accessor :financial_year_end_day
57
+
58
+ # Calendar Month e.g. 1-12
59
+ attr_accessor :financial_year_end_month
60
+
61
+ # The accounting basis used for tax returns. See Sales Tax Basis
62
+ attr_accessor :sales_tax_basis
63
+
64
+ # The frequency with which tax returns are processed. See Sales Tax Period
65
+ attr_accessor :sales_tax_period
66
+
67
+ # The default for LineAmountTypes on sales transactions
68
+ attr_accessor :default_sales_tax
69
+
70
+ # The default for LineAmountTypes on purchase transactions
71
+ attr_accessor :default_purchases_tax
72
+
73
+ # Shown if set. See lock dates
74
+ attr_accessor :period_lock_date
75
+
76
+ # Shown if set. See lock dates
77
+ attr_accessor :end_of_year_lock_date
78
+
79
+ # Timestamp when the organisation was created in Xero
80
+ attr_accessor :created_date_utc
81
+
82
+ attr_accessor :timezone
83
+
84
+ # Organisation Type
85
+ attr_accessor :organisation_entity_type
86
+
87
+ # A unique identifier for the organisation. Potential uses.
88
+ attr_accessor :short_code
89
+
90
+ # Organisation Classes describe which plan the Xero organisation is on (e.g. DEMO, TRIAL, PREMIUM)
91
+ attr_accessor :_class
92
+
93
+ # BUSINESS or PARTNER. Partner edition organisations are sold exclusively through accounting partners and have restricted functionality (e.g. no access to invoicing)
94
+ attr_accessor :edition
95
+
96
+ # Description of business type as defined in Organisation settings
97
+ attr_accessor :line_of_business
98
+
99
+ # Address details for organisation – see Addresses
100
+ attr_accessor :addresses
101
+
102
+ # Phones details for organisation – see Phones
103
+ attr_accessor :phones
104
+
105
+ # Organisation profile links for popular services such as Facebook,Twitter, GooglePlus and LinkedIn. You can also add link to your website here. Shown if Organisation settings is updated in Xero. See ExternalLinks below
106
+ attr_accessor :external_links
107
+
108
+ attr_accessor :payment_terms
109
+
110
+ class EnumAttributeValidator
111
+ attr_reader :datatype
112
+ attr_reader :allowable_values
113
+
114
+ def initialize(datatype, allowable_values)
115
+ @allowable_values = allowable_values.map do |value|
116
+ case datatype.to_s
117
+ when /Integer/i
118
+ value.to_i
119
+ when /Float/i
120
+ value.to_f
121
+ else
122
+ value
123
+ end
124
+ end
125
+ end
126
+
127
+ def valid?(value)
128
+ !value || allowable_values.include?(value)
129
+ end
130
+ end
131
+
132
+ # Attribute mapping from ruby-style variable name to JSON key.
133
+ def self.attribute_map
134
+ {
135
+ :'organisation_id' => :'OrganisationID',
136
+ :'api_key' => :'APIKey',
137
+ :'name' => :'Name',
138
+ :'legal_name' => :'LegalName',
139
+ :'pays_tax' => :'PaysTax',
140
+ :'version' => :'Version',
141
+ :'organisation_type' => :'OrganisationType',
142
+ :'base_currency' => :'BaseCurrency',
143
+ :'country_code' => :'CountryCode',
144
+ :'is_demo_company' => :'IsDemoCompany',
145
+ :'organisation_status' => :'OrganisationStatus',
146
+ :'registration_number' => :'RegistrationNumber',
147
+ :'tax_number' => :'TaxNumber',
148
+ :'financial_year_end_day' => :'FinancialYearEndDay',
149
+ :'financial_year_end_month' => :'FinancialYearEndMonth',
150
+ :'sales_tax_basis' => :'SalesTaxBasis',
151
+ :'sales_tax_period' => :'SalesTaxPeriod',
152
+ :'default_sales_tax' => :'DefaultSalesTax',
153
+ :'default_purchases_tax' => :'DefaultPurchasesTax',
154
+ :'period_lock_date' => :'PeriodLockDate',
155
+ :'end_of_year_lock_date' => :'EndOfYearLockDate',
156
+ :'created_date_utc' => :'CreatedDateUTC',
157
+ :'timezone' => :'Timezone',
158
+ :'organisation_entity_type' => :'OrganisationEntityType',
159
+ :'short_code' => :'ShortCode',
160
+ :'_class' => :'Class',
161
+ :'edition' => :'Edition',
162
+ :'line_of_business' => :'LineOfBusiness',
163
+ :'addresses' => :'Addresses',
164
+ :'phones' => :'Phones',
165
+ :'external_links' => :'ExternalLinks',
166
+ :'payment_terms' => :'PaymentTerms'
167
+ }
168
+ end
169
+
170
+ # Attribute type mapping.
171
+ def self.openapi_types
172
+ {
173
+ :'organisation_id' => :'String',
174
+ :'api_key' => :'String',
175
+ :'name' => :'String',
176
+ :'legal_name' => :'String',
177
+ :'pays_tax' => :'Boolean',
178
+ :'version' => :'String',
179
+ :'organisation_type' => :'String',
180
+ :'base_currency' => :'CurrencyCode',
181
+ :'country_code' => :'CountryCode',
182
+ :'is_demo_company' => :'Boolean',
183
+ :'organisation_status' => :'String',
184
+ :'registration_number' => :'String',
185
+ :'tax_number' => :'String',
186
+ :'financial_year_end_day' => :'Integer',
187
+ :'financial_year_end_month' => :'Integer',
188
+ :'sales_tax_basis' => :'String',
189
+ :'sales_tax_period' => :'String',
190
+ :'default_sales_tax' => :'String',
191
+ :'default_purchases_tax' => :'String',
192
+ :'period_lock_date' => :'Date',
193
+ :'end_of_year_lock_date' => :'Date',
194
+ :'created_date_utc' => :'DateTime',
195
+ :'timezone' => :'TimeZone',
196
+ :'organisation_entity_type' => :'String',
197
+ :'short_code' => :'String',
198
+ :'_class' => :'String',
199
+ :'edition' => :'String',
200
+ :'line_of_business' => :'String',
201
+ :'addresses' => :'Array<Address>',
202
+ :'phones' => :'Array<Phone>',
203
+ :'external_links' => :'Array<ExternalLink>',
204
+ :'payment_terms' => :'PaymentTerm'
205
+ }
206
+ end
207
+
208
+ # Initializes the object
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ def initialize(attributes = {})
211
+ if (!attributes.is_a?(Hash))
212
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Organisation` initialize method"
213
+ end
214
+
215
+ # check to see if the attribute exists and convert string to symbol for hash key
216
+ attributes = attributes.each_with_object({}) { |(k, v), h|
217
+ if (!self.class.attribute_map.key?(k.to_sym))
218
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Organisation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
219
+ end
220
+ h[k.to_sym] = v
221
+ }
222
+
223
+ if attributes.key?(:'organisation_id')
224
+ self.organisation_id = attributes[:'organisation_id']
225
+ end
226
+
227
+ if attributes.key?(:'api_key')
228
+ self.api_key = attributes[:'api_key']
229
+ end
230
+
231
+ if attributes.key?(:'name')
232
+ self.name = attributes[:'name']
233
+ end
234
+
235
+ if attributes.key?(:'legal_name')
236
+ self.legal_name = attributes[:'legal_name']
237
+ end
238
+
239
+ if attributes.key?(:'pays_tax')
240
+ self.pays_tax = attributes[:'pays_tax']
241
+ end
242
+
243
+ if attributes.key?(:'version')
244
+ self.version = attributes[:'version']
245
+ end
246
+
247
+ if attributes.key?(:'organisation_type')
248
+ self.organisation_type = attributes[:'organisation_type']
249
+ end
250
+
251
+ if attributes.key?(:'base_currency')
252
+ self.base_currency = attributes[:'base_currency']
253
+ end
254
+
255
+ if attributes.key?(:'country_code')
256
+ self.country_code = attributes[:'country_code']
257
+ end
258
+
259
+ if attributes.key?(:'is_demo_company')
260
+ self.is_demo_company = attributes[:'is_demo_company']
261
+ end
262
+
263
+ if attributes.key?(:'organisation_status')
264
+ self.organisation_status = attributes[:'organisation_status']
265
+ end
266
+
267
+ if attributes.key?(:'registration_number')
268
+ self.registration_number = attributes[:'registration_number']
269
+ end
270
+
271
+ if attributes.key?(:'tax_number')
272
+ self.tax_number = attributes[:'tax_number']
273
+ end
274
+
275
+ if attributes.key?(:'financial_year_end_day')
276
+ self.financial_year_end_day = attributes[:'financial_year_end_day']
277
+ end
278
+
279
+ if attributes.key?(:'financial_year_end_month')
280
+ self.financial_year_end_month = attributes[:'financial_year_end_month']
281
+ end
282
+
283
+ if attributes.key?(:'sales_tax_basis')
284
+ self.sales_tax_basis = attributes[:'sales_tax_basis']
285
+ end
286
+
287
+ if attributes.key?(:'sales_tax_period')
288
+ self.sales_tax_period = attributes[:'sales_tax_period']
289
+ end
290
+
291
+ if attributes.key?(:'default_sales_tax')
292
+ self.default_sales_tax = attributes[:'default_sales_tax']
293
+ end
294
+
295
+ if attributes.key?(:'default_purchases_tax')
296
+ self.default_purchases_tax = attributes[:'default_purchases_tax']
297
+ end
298
+
299
+ if attributes.key?(:'period_lock_date')
300
+ self.period_lock_date = attributes[:'period_lock_date']
301
+ end
302
+
303
+ if attributes.key?(:'end_of_year_lock_date')
304
+ self.end_of_year_lock_date = attributes[:'end_of_year_lock_date']
305
+ end
306
+
307
+ if attributes.key?(:'created_date_utc')
308
+ self.created_date_utc = attributes[:'created_date_utc']
309
+ end
310
+
311
+ if attributes.key?(:'timezone')
312
+ self.timezone = attributes[:'timezone']
313
+ end
314
+
315
+ if attributes.key?(:'organisation_entity_type')
316
+ self.organisation_entity_type = attributes[:'organisation_entity_type']
317
+ end
318
+
319
+ if attributes.key?(:'short_code')
320
+ self.short_code = attributes[:'short_code']
321
+ end
322
+
323
+ if attributes.key?(:'_class')
324
+ self._class = attributes[:'_class']
325
+ end
326
+
327
+ if attributes.key?(:'edition')
328
+ self.edition = attributes[:'edition']
329
+ end
330
+
331
+ if attributes.key?(:'line_of_business')
332
+ self.line_of_business = attributes[:'line_of_business']
333
+ end
334
+
335
+ if attributes.key?(:'addresses')
336
+ if (value = attributes[:'addresses']).is_a?(Array)
337
+ self.addresses = value
338
+ end
339
+ end
340
+
341
+ if attributes.key?(:'phones')
342
+ if (value = attributes[:'phones']).is_a?(Array)
343
+ self.phones = value
344
+ end
345
+ end
346
+
347
+ if attributes.key?(:'external_links')
348
+ if (value = attributes[:'external_links']).is_a?(Array)
349
+ self.external_links = value
350
+ end
351
+ end
352
+
353
+ if attributes.key?(:'payment_terms')
354
+ self.payment_terms = attributes[:'payment_terms']
355
+ end
356
+ end
357
+
358
+ # Show invalid properties with the reasons. Usually used together with valid?
359
+ # @return Array for valid properties with the reasons
360
+ def list_invalid_properties
361
+ invalid_properties = Array.new
362
+ invalid_properties
363
+ end
364
+
365
+ # Check to see if the all the properties in the model are valid
366
+ # @return true if the model is valid
367
+ def valid?
368
+ version_validator = EnumAttributeValidator.new('String', ["AU", "NZ", "GLOBAL", "UK", "US", "AUONRAMP", "NZONRAMP", "GLOBALONRAMP", "UKONRAMP", "USONRAMP"])
369
+ return false unless version_validator.valid?(@version)
370
+ organisation_type_validator = EnumAttributeValidator.new('String', ["COMPANY", "CHARITY", "CLUB_OR_SOCIETY", "LOOK_THROUGH_COMPANY", "NOT_FOR_PROFIT", "PARTNERSHIP", "S_CORPORATION", "SELF_MANAGED_SUPERANNUATION_FUND", "SOLE_TRADER", "SUPERANNUATION_FUND", "TRUST"])
371
+ return false unless organisation_type_validator.valid?(@organisation_type)
372
+ sales_tax_basis_validator = EnumAttributeValidator.new('String', ["PAYMENTS", "INVOICE", "NONE", "CASH", "ACCRUAL", "FLATRATECASH", "FLATRATEACCRUAL", "ACCRUALS"])
373
+ return false unless sales_tax_basis_validator.valid?(@sales_tax_basis)
374
+ sales_tax_period_validator = EnumAttributeValidator.new('String', ["MONTHLY", "QUARTERLY1", "QUARTERLY2", "QUARTERLY3", "ANNUALLY", "ONEMONTHS", "TWOMONTHS", "SIXMONTHS", "1MONTHLY", "2MONTHLY", "3MONTHLY", "6MONTHLY", "QUARTERLY", "YEARLY"])
375
+ return false unless sales_tax_period_validator.valid?(@sales_tax_period)
376
+ organisation_entity_type_validator = EnumAttributeValidator.new('String', ["COMPANY", "CHARITY", "CLUB_OR_SOCIETY", "LOOK_THROUGH_COMPANY", "NOT_FOR_PROFIT", "PARTNERSHIP", "S_CORPORATION", "SELF_MANAGED_SUPERANNUATION_FUND", "SOLE_TRADER", "SUPERANNUATION_FUND", "TRUST"])
377
+ return false unless organisation_entity_type_validator.valid?(@organisation_entity_type)
378
+ _class_validator = EnumAttributeValidator.new('String', ["DEMO", "TRIAL", "STARTER", "STANDARD", "PREMIUM", "PREMIUM_20", "PREMIUM_50", "PREMIUM_100", "LEDGER", "GST_CASHBOOK", "NON_GST_CASHBOOK"])
379
+ return false unless _class_validator.valid?(@_class)
380
+ edition_validator = EnumAttributeValidator.new('String', ["BUSINESS", "PARTNER"])
381
+ return false unless edition_validator.valid?(@edition)
382
+ true
383
+ end
384
+
385
+ # Custom attribute writer method checking allowed values (enum).
386
+ # @param [Object] version Object to be assigned
387
+ def version=(version)
388
+ validator = EnumAttributeValidator.new('String', ["AU", "NZ", "GLOBAL", "UK", "US", "AUONRAMP", "NZONRAMP", "GLOBALONRAMP", "UKONRAMP", "USONRAMP"])
389
+ unless validator.valid?(version)
390
+ fail ArgumentError, "invalid value for \"version\", must be one of #{validator.allowable_values}."
391
+ end
392
+ @version = version
393
+ end
394
+
395
+ # Custom attribute writer method checking allowed values (enum).
396
+ # @param [Object] organisation_type Object to be assigned
397
+ def organisation_type=(organisation_type)
398
+ validator = EnumAttributeValidator.new('String', ["COMPANY", "CHARITY", "CLUB_OR_SOCIETY", "LOOK_THROUGH_COMPANY", "NOT_FOR_PROFIT", "PARTNERSHIP", "S_CORPORATION", "SELF_MANAGED_SUPERANNUATION_FUND", "SOLE_TRADER", "SUPERANNUATION_FUND", "TRUST"])
399
+ unless validator.valid?(organisation_type)
400
+ fail ArgumentError, "invalid value for \"organisation_type\", must be one of #{validator.allowable_values}."
401
+ end
402
+ @organisation_type = organisation_type
403
+ end
404
+
405
+ # Custom attribute writer method checking allowed values (enum).
406
+ # @param [Object] sales_tax_basis Object to be assigned
407
+ def sales_tax_basis=(sales_tax_basis)
408
+ validator = EnumAttributeValidator.new('String', ["PAYMENTS", "INVOICE", "NONE", "CASH", "ACCRUAL", "FLATRATECASH", "FLATRATEACCRUAL", "ACCRUALS"])
409
+ unless validator.valid?(sales_tax_basis)
410
+ fail ArgumentError, "invalid value for \"sales_tax_basis\", must be one of #{validator.allowable_values}."
411
+ end
412
+ @sales_tax_basis = sales_tax_basis
413
+ end
414
+
415
+ # Custom attribute writer method checking allowed values (enum).
416
+ # @param [Object] sales_tax_period Object to be assigned
417
+ def sales_tax_period=(sales_tax_period)
418
+ validator = EnumAttributeValidator.new('String', ["MONTHLY", "QUARTERLY1", "QUARTERLY2", "QUARTERLY3", "ANNUALLY", "ONEMONTHS", "TWOMONTHS", "SIXMONTHS", "1MONTHLY", "2MONTHLY", "3MONTHLY", "6MONTHLY", "QUARTERLY", "YEARLY"])
419
+ unless validator.valid?(sales_tax_period)
420
+ fail ArgumentError, "invalid value for \"sales_tax_period\", must be one of #{validator.allowable_values}."
421
+ end
422
+ @sales_tax_period = sales_tax_period
423
+ end
424
+
425
+ # Custom attribute writer method checking allowed values (enum).
426
+ # @param [Object] organisation_entity_type Object to be assigned
427
+ def organisation_entity_type=(organisation_entity_type)
428
+ validator = EnumAttributeValidator.new('String', ["COMPANY", "CHARITY", "CLUB_OR_SOCIETY", "LOOK_THROUGH_COMPANY", "NOT_FOR_PROFIT", "PARTNERSHIP", "S_CORPORATION", "SELF_MANAGED_SUPERANNUATION_FUND", "SOLE_TRADER", "SUPERANNUATION_FUND", "TRUST"])
429
+ unless validator.valid?(organisation_entity_type)
430
+ fail ArgumentError, "invalid value for \"organisation_entity_type\", must be one of #{validator.allowable_values}."
431
+ end
432
+ @organisation_entity_type = organisation_entity_type
433
+ end
434
+
435
+ # Custom attribute writer method checking allowed values (enum).
436
+ # @param [Object] _class Object to be assigned
437
+ def _class=(_class)
438
+ validator = EnumAttributeValidator.new('String', ["DEMO", "TRIAL", "STARTER", "STANDARD", "PREMIUM", "PREMIUM_20", "PREMIUM_50", "PREMIUM_100", "LEDGER", "GST_CASHBOOK", "NON_GST_CASHBOOK"])
439
+ unless validator.valid?(_class)
440
+ fail ArgumentError, "invalid value for \"_class\", must be one of #{validator.allowable_values}."
441
+ end
442
+ @_class = _class
443
+ end
444
+
445
+ # Custom attribute writer method checking allowed values (enum).
446
+ # @param [Object] edition Object to be assigned
447
+ def edition=(edition)
448
+ validator = EnumAttributeValidator.new('String', ["BUSINESS", "PARTNER"])
449
+ unless validator.valid?(edition)
450
+ fail ArgumentError, "invalid value for \"edition\", must be one of #{validator.allowable_values}."
451
+ end
452
+ @edition = edition
453
+ end
454
+
455
+ # Checks equality by comparing each attribute.
456
+ # @param [Object] Object to be compared
457
+ def ==(o)
458
+ return true if self.equal?(o)
459
+ self.class == o.class &&
460
+ organisation_id == o.organisation_id &&
461
+ api_key == o.api_key &&
462
+ name == o.name &&
463
+ legal_name == o.legal_name &&
464
+ pays_tax == o.pays_tax &&
465
+ version == o.version &&
466
+ organisation_type == o.organisation_type &&
467
+ base_currency == o.base_currency &&
468
+ country_code == o.country_code &&
469
+ is_demo_company == o.is_demo_company &&
470
+ organisation_status == o.organisation_status &&
471
+ registration_number == o.registration_number &&
472
+ tax_number == o.tax_number &&
473
+ financial_year_end_day == o.financial_year_end_day &&
474
+ financial_year_end_month == o.financial_year_end_month &&
475
+ sales_tax_basis == o.sales_tax_basis &&
476
+ sales_tax_period == o.sales_tax_period &&
477
+ default_sales_tax == o.default_sales_tax &&
478
+ default_purchases_tax == o.default_purchases_tax &&
479
+ period_lock_date == o.period_lock_date &&
480
+ end_of_year_lock_date == o.end_of_year_lock_date &&
481
+ created_date_utc == o.created_date_utc &&
482
+ timezone == o.timezone &&
483
+ organisation_entity_type == o.organisation_entity_type &&
484
+ short_code == o.short_code &&
485
+ _class == o._class &&
486
+ edition == o.edition &&
487
+ line_of_business == o.line_of_business &&
488
+ addresses == o.addresses &&
489
+ phones == o.phones &&
490
+ external_links == o.external_links &&
491
+ payment_terms == o.payment_terms
492
+ end
493
+
494
+ # @see the `==` method
495
+ # @param [Object] Object to be compared
496
+ def eql?(o)
497
+ self == o
498
+ end
499
+
500
+ # Calculates hash code according to all attributes.
501
+ # @return [Integer] Hash code
502
+ def hash
503
+ [organisation_id, api_key, name, legal_name, pays_tax, version, organisation_type, base_currency, country_code, is_demo_company, organisation_status, registration_number, tax_number, financial_year_end_day, financial_year_end_month, sales_tax_basis, sales_tax_period, default_sales_tax, default_purchases_tax, period_lock_date, end_of_year_lock_date, created_date_utc, timezone, organisation_entity_type, short_code, _class, edition, line_of_business, addresses, phones, external_links, payment_terms].hash
504
+ end
505
+
506
+ # Builds the object from hash
507
+ # @param [Hash] attributes Model attributes in the form of hash
508
+ # @return [Object] Returns the model itself
509
+ def self.build_from_hash(attributes)
510
+ new.build_from_hash(attributes)
511
+ end
512
+
513
+ # Builds the object from hash
514
+ # @param [Hash] attributes Model attributes in the form of hash
515
+ # @return [Object] Returns the model itself
516
+ def build_from_hash(attributes)
517
+ return nil unless attributes.is_a?(Hash)
518
+ self.class.openapi_types.each_pair do |key, type|
519
+ if type =~ /\AArray<(.*)>/i
520
+ # check to ensure the input is an array given that the attribute
521
+ # is documented as an array but the input is not
522
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
523
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
524
+ end
525
+ elsif !attributes[self.class.attribute_map[key]].nil?
526
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
527
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
528
+ end
529
+
530
+ self
531
+ end
532
+
533
+ # Deserializes the data based on type
534
+ # @param string type Data type
535
+ # @param string value Value to be deserialized
536
+ # @return [Object] Deserialized data
537
+ def _deserialize(type, value)
538
+ case type.to_sym
539
+ when :DateTime
540
+ DateTime.parse(parse_date(value))
541
+ when :Date
542
+ Date._iso8601(parse_date(value))
543
+ when :String
544
+ value.to_s
545
+ when :Integer
546
+ value.to_i
547
+ when :Float
548
+ value.to_f
549
+ when :Boolean
550
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
551
+ true
552
+ else
553
+ false
554
+ end
555
+ when :Object
556
+ # generic object (usually a Hash), return directly
557
+ value
558
+ when /\AArray<(?<inner_type>.+)>\z/
559
+ inner_type = Regexp.last_match[:inner_type]
560
+ value.map { |v| _deserialize(inner_type, v) }
561
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
562
+ k_type = Regexp.last_match[:k_type]
563
+ v_type = Regexp.last_match[:v_type]
564
+ {}.tap do |hash|
565
+ value.each do |k, v|
566
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
567
+ end
568
+ end
569
+ else # model
570
+ XeroRuby.const_get(type).build_from_hash(value)
571
+ end
572
+ end
573
+
574
+ # Returns the string representation of the object
575
+ # @return [String] String presentation of the object
576
+ def to_s
577
+ to_hash.to_s
578
+ end
579
+
580
+ # to_body is an alias to to_hash (backward compatibility)
581
+ # @return [Hash] Returns the object in the form of hash
582
+ def to_body
583
+ to_hash
584
+ end
585
+
586
+ # Returns the object in the form of hash
587
+ # @return [Hash] Returns the object in the form of hash
588
+ def to_hash
589
+ hash = {}
590
+ self.class.attribute_map.each_pair do |attr, param|
591
+ value = self.send(attr)
592
+ next if value.nil?
593
+ hash[param] = _to_hash(value)
594
+ end
595
+ hash
596
+ end
597
+
598
+ # Outputs non-array value in the form of hash
599
+ # For object, use to_hash. Otherwise, just return the value
600
+ # @param [Object] value Any valid value
601
+ # @return [Hash] Returns the value in the form of hash
602
+ def _to_hash(value)
603
+ if value.is_a?(Array)
604
+ value.compact.map { |v| _to_hash(v) }
605
+ elsif value.is_a?(Hash)
606
+ {}.tap do |hash|
607
+ value.each { |k, v| hash[k] = _to_hash(v) }
608
+ end
609
+ elsif value.respond_to? :to_hash
610
+ value.to_hash
611
+ else
612
+ value
613
+ end
614
+ end
615
+
616
+ # customized data_parser
617
+ def parse_date(datestring)
618
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
619
+ return Time.at(seconds_since_epoch).to_s
620
+ end
621
+ end
622
+ end