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,310 @@
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 Journal
18
+ # Xero identifier
19
+ attr_accessor :journal_id
20
+
21
+ # Date the journal was posted
22
+ attr_accessor :journal_date
23
+
24
+ # Xero generated journal number
25
+ attr_accessor :journal_number
26
+
27
+ # Created date UTC format
28
+ attr_accessor :created_date_utc
29
+
30
+ # reference field for additional indetifying information
31
+ attr_accessor :reference
32
+
33
+ # The identifier for the source transaction (e.g. InvoiceID)
34
+ attr_accessor :source_id
35
+
36
+ # The journal source type. The type of transaction that created the journal
37
+ attr_accessor :source_type
38
+
39
+ # See JournalLines
40
+ attr_accessor :journal_lines
41
+
42
+ class EnumAttributeValidator
43
+ attr_reader :datatype
44
+ attr_reader :allowable_values
45
+
46
+ def initialize(datatype, allowable_values)
47
+ @allowable_values = allowable_values.map do |value|
48
+ case datatype.to_s
49
+ when /Integer/i
50
+ value.to_i
51
+ when /Float/i
52
+ value.to_f
53
+ else
54
+ value
55
+ end
56
+ end
57
+ end
58
+
59
+ def valid?(value)
60
+ !value || allowable_values.include?(value)
61
+ end
62
+ end
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'journal_id' => :'JournalID',
68
+ :'journal_date' => :'JournalDate',
69
+ :'journal_number' => :'JournalNumber',
70
+ :'created_date_utc' => :'CreatedDateUTC',
71
+ :'reference' => :'Reference',
72
+ :'source_id' => :'SourceID',
73
+ :'source_type' => :'SourceType',
74
+ :'journal_lines' => :'JournalLines'
75
+ }
76
+ end
77
+
78
+ # Attribute type mapping.
79
+ def self.openapi_types
80
+ {
81
+ :'journal_id' => :'String',
82
+ :'journal_date' => :'Date',
83
+ :'journal_number' => :'String',
84
+ :'created_date_utc' => :'DateTime',
85
+ :'reference' => :'String',
86
+ :'source_id' => :'String',
87
+ :'source_type' => :'String',
88
+ :'journal_lines' => :'Array<JournalLine>'
89
+ }
90
+ end
91
+
92
+ # Initializes the object
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ def initialize(attributes = {})
95
+ if (!attributes.is_a?(Hash))
96
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Journal` initialize method"
97
+ end
98
+
99
+ # check to see if the attribute exists and convert string to symbol for hash key
100
+ attributes = attributes.each_with_object({}) { |(k, v), h|
101
+ if (!self.class.attribute_map.key?(k.to_sym))
102
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Journal`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
103
+ end
104
+ h[k.to_sym] = v
105
+ }
106
+
107
+ if attributes.key?(:'journal_id')
108
+ self.journal_id = attributes[:'journal_id']
109
+ end
110
+
111
+ if attributes.key?(:'journal_date')
112
+ self.journal_date = attributes[:'journal_date']
113
+ end
114
+
115
+ if attributes.key?(:'journal_number')
116
+ self.journal_number = attributes[:'journal_number']
117
+ end
118
+
119
+ if attributes.key?(:'created_date_utc')
120
+ self.created_date_utc = attributes[:'created_date_utc']
121
+ end
122
+
123
+ if attributes.key?(:'reference')
124
+ self.reference = attributes[:'reference']
125
+ end
126
+
127
+ if attributes.key?(:'source_id')
128
+ self.source_id = attributes[:'source_id']
129
+ end
130
+
131
+ if attributes.key?(:'source_type')
132
+ self.source_type = attributes[:'source_type']
133
+ end
134
+
135
+ if attributes.key?(:'journal_lines')
136
+ if (value = attributes[:'journal_lines']).is_a?(Array)
137
+ self.journal_lines = value
138
+ end
139
+ end
140
+ end
141
+
142
+ # Show invalid properties with the reasons. Usually used together with valid?
143
+ # @return Array for valid properties with the reasons
144
+ def list_invalid_properties
145
+ invalid_properties = Array.new
146
+ invalid_properties
147
+ end
148
+
149
+ # Check to see if the all the properties in the model are valid
150
+ # @return true if the model is valid
151
+ def valid?
152
+ source_type_validator = EnumAttributeValidator.new('String', ["ACCREC", "ACCPAY", "ACCRECCREDIT", "ACCPAYCREDIT", "ACCRECPAYMENT", "ACCPAYPAYMENT", "ARCREDITPAYMENT", "APCREDITPAYMENT", "CASHREC", "CASHPAID", "TRANSFER", "ARPREPAYMENT", "APPREPAYMENT", "AROVERPAYMENT", "APOVERPAYMENT", "EXPCLAIM", "EXPPAYMENT", "MANJOURNAL", "PAYSLIP", "WAGEPAYABLE", "INTEGRATEDPAYROLLPE", "INTEGRATEDPAYROLLPT", "EXTERNALSPENDMONEY", "INTEGRATEDPAYROLLPTPAYMENT", "INTEGRATEDPAYROLLCN"])
153
+ return false unless source_type_validator.valid?(@source_type)
154
+ true
155
+ end
156
+
157
+ # Custom attribute writer method checking allowed values (enum).
158
+ # @param [Object] source_type Object to be assigned
159
+ def source_type=(source_type)
160
+ validator = EnumAttributeValidator.new('String', ["ACCREC", "ACCPAY", "ACCRECCREDIT", "ACCPAYCREDIT", "ACCRECPAYMENT", "ACCPAYPAYMENT", "ARCREDITPAYMENT", "APCREDITPAYMENT", "CASHREC", "CASHPAID", "TRANSFER", "ARPREPAYMENT", "APPREPAYMENT", "AROVERPAYMENT", "APOVERPAYMENT", "EXPCLAIM", "EXPPAYMENT", "MANJOURNAL", "PAYSLIP", "WAGEPAYABLE", "INTEGRATEDPAYROLLPE", "INTEGRATEDPAYROLLPT", "EXTERNALSPENDMONEY", "INTEGRATEDPAYROLLPTPAYMENT", "INTEGRATEDPAYROLLCN"])
161
+ unless validator.valid?(source_type)
162
+ fail ArgumentError, "invalid value for \"source_type\", must be one of #{validator.allowable_values}."
163
+ end
164
+ @source_type = source_type
165
+ end
166
+
167
+ # Checks equality by comparing each attribute.
168
+ # @param [Object] Object to be compared
169
+ def ==(o)
170
+ return true if self.equal?(o)
171
+ self.class == o.class &&
172
+ journal_id == o.journal_id &&
173
+ journal_date == o.journal_date &&
174
+ journal_number == o.journal_number &&
175
+ created_date_utc == o.created_date_utc &&
176
+ reference == o.reference &&
177
+ source_id == o.source_id &&
178
+ source_type == o.source_type &&
179
+ journal_lines == o.journal_lines
180
+ end
181
+
182
+ # @see the `==` method
183
+ # @param [Object] Object to be compared
184
+ def eql?(o)
185
+ self == o
186
+ end
187
+
188
+ # Calculates hash code according to all attributes.
189
+ # @return [Integer] Hash code
190
+ def hash
191
+ [journal_id, journal_date, journal_number, created_date_utc, reference, source_id, source_type, journal_lines].hash
192
+ end
193
+
194
+ # Builds the object from hash
195
+ # @param [Hash] attributes Model attributes in the form of hash
196
+ # @return [Object] Returns the model itself
197
+ def self.build_from_hash(attributes)
198
+ new.build_from_hash(attributes)
199
+ end
200
+
201
+ # Builds the object from hash
202
+ # @param [Hash] attributes Model attributes in the form of hash
203
+ # @return [Object] Returns the model itself
204
+ def build_from_hash(attributes)
205
+ return nil unless attributes.is_a?(Hash)
206
+ self.class.openapi_types.each_pair do |key, type|
207
+ if type =~ /\AArray<(.*)>/i
208
+ # check to ensure the input is an array given that the attribute
209
+ # is documented as an array but the input is not
210
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
211
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
212
+ end
213
+ elsif !attributes[self.class.attribute_map[key]].nil?
214
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
215
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
216
+ end
217
+
218
+ self
219
+ end
220
+
221
+ # Deserializes the data based on type
222
+ # @param string type Data type
223
+ # @param string value Value to be deserialized
224
+ # @return [Object] Deserialized data
225
+ def _deserialize(type, value)
226
+ case type.to_sym
227
+ when :DateTime
228
+ DateTime.parse(parse_date(value))
229
+ when :Date
230
+ Date._iso8601(parse_date(value))
231
+ when :String
232
+ value.to_s
233
+ when :Integer
234
+ value.to_i
235
+ when :Float
236
+ value.to_f
237
+ when :Boolean
238
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
239
+ true
240
+ else
241
+ false
242
+ end
243
+ when :Object
244
+ # generic object (usually a Hash), return directly
245
+ value
246
+ when /\AArray<(?<inner_type>.+)>\z/
247
+ inner_type = Regexp.last_match[:inner_type]
248
+ value.map { |v| _deserialize(inner_type, v) }
249
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
250
+ k_type = Regexp.last_match[:k_type]
251
+ v_type = Regexp.last_match[:v_type]
252
+ {}.tap do |hash|
253
+ value.each do |k, v|
254
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
255
+ end
256
+ end
257
+ else # model
258
+ XeroRuby.const_get(type).build_from_hash(value)
259
+ end
260
+ end
261
+
262
+ # Returns the string representation of the object
263
+ # @return [String] String presentation of the object
264
+ def to_s
265
+ to_hash.to_s
266
+ end
267
+
268
+ # to_body is an alias to to_hash (backward compatibility)
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_body
271
+ to_hash
272
+ end
273
+
274
+ # Returns the object in the form of hash
275
+ # @return [Hash] Returns the object in the form of hash
276
+ def to_hash
277
+ hash = {}
278
+ self.class.attribute_map.each_pair do |attr, param|
279
+ value = self.send(attr)
280
+ next if value.nil?
281
+ hash[param] = _to_hash(value)
282
+ end
283
+ hash
284
+ end
285
+
286
+ # Outputs non-array value in the form of hash
287
+ # For object, use to_hash. Otherwise, just return the value
288
+ # @param [Object] value Any valid value
289
+ # @return [Hash] Returns the value in the form of hash
290
+ def _to_hash(value)
291
+ if value.is_a?(Array)
292
+ value.compact.map { |v| _to_hash(v) }
293
+ elsif value.is_a?(Hash)
294
+ {}.tap do |hash|
295
+ value.each { |k, v| hash[k] = _to_hash(v) }
296
+ end
297
+ elsif value.respond_to? :to_hash
298
+ value.to_hash
299
+ else
300
+ value
301
+ end
302
+ end
303
+
304
+ # customized data_parser
305
+ def parse_date(datestring)
306
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
307
+ return Time.at(seconds_since_epoch).to_s
308
+ end
309
+ end
310
+ end
@@ -0,0 +1,315 @@
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 JournalLine
18
+ # Xero identifier for Journal
19
+ attr_accessor :journal_line_id
20
+
21
+ # See Accounts
22
+ attr_accessor :account_id
23
+
24
+ # See Accounts
25
+ attr_accessor :account_code
26
+
27
+ attr_accessor :account_type
28
+
29
+ # See AccountCodes
30
+ attr_accessor :account_name
31
+
32
+ # The description from the source transaction line item. Only returned if populated.
33
+ attr_accessor :description
34
+
35
+ # Net amount of journal line. This will be a positive value for a debit and negative for a credit
36
+ attr_accessor :net_amount
37
+
38
+ # Gross amount of journal line (NetAmount + TaxAmount).
39
+ attr_accessor :gross_amount
40
+
41
+ # Total tax on a journal line
42
+ attr_accessor :tax_amount
43
+
44
+ # The tax type from TaxRates
45
+ attr_accessor :tax_type
46
+
47
+ # see TaxRates
48
+ attr_accessor :tax_name
49
+
50
+ # Optional Tracking Category – see Tracking. Any JournalLine can have a maximum of 2 <TrackingCategory> elements.
51
+ attr_accessor :tracking_categories
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'journal_line_id' => :'JournalLineID',
57
+ :'account_id' => :'AccountID',
58
+ :'account_code' => :'AccountCode',
59
+ :'account_type' => :'AccountType',
60
+ :'account_name' => :'AccountName',
61
+ :'description' => :'Description',
62
+ :'net_amount' => :'NetAmount',
63
+ :'gross_amount' => :'GrossAmount',
64
+ :'tax_amount' => :'TaxAmount',
65
+ :'tax_type' => :'TaxType',
66
+ :'tax_name' => :'TaxName',
67
+ :'tracking_categories' => :'TrackingCategories'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'journal_line_id' => :'String',
75
+ :'account_id' => :'String',
76
+ :'account_code' => :'String',
77
+ :'account_type' => :'AccountType',
78
+ :'account_name' => :'String',
79
+ :'description' => :'String',
80
+ :'net_amount' => :'Float',
81
+ :'gross_amount' => :'Float',
82
+ :'tax_amount' => :'Float',
83
+ :'tax_type' => :'String',
84
+ :'tax_name' => :'String',
85
+ :'tracking_categories' => :'Array<TrackingCategory>'
86
+ }
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ if (!attributes.is_a?(Hash))
93
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::JournalLine` initialize method"
94
+ end
95
+
96
+ # check to see if the attribute exists and convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!self.class.attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::JournalLine`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'journal_line_id')
105
+ self.journal_line_id = attributes[:'journal_line_id']
106
+ end
107
+
108
+ if attributes.key?(:'account_id')
109
+ self.account_id = attributes[:'account_id']
110
+ end
111
+
112
+ if attributes.key?(:'account_code')
113
+ self.account_code = attributes[:'account_code']
114
+ end
115
+
116
+ if attributes.key?(:'account_type')
117
+ self.account_type = attributes[:'account_type']
118
+ end
119
+
120
+ if attributes.key?(:'account_name')
121
+ self.account_name = attributes[:'account_name']
122
+ end
123
+
124
+ if attributes.key?(:'description')
125
+ self.description = attributes[:'description']
126
+ end
127
+
128
+ if attributes.key?(:'net_amount')
129
+ self.net_amount = attributes[:'net_amount']
130
+ end
131
+
132
+ if attributes.key?(:'gross_amount')
133
+ self.gross_amount = attributes[:'gross_amount']
134
+ end
135
+
136
+ if attributes.key?(:'tax_amount')
137
+ self.tax_amount = attributes[:'tax_amount']
138
+ end
139
+
140
+ if attributes.key?(:'tax_type')
141
+ self.tax_type = attributes[:'tax_type']
142
+ end
143
+
144
+ if attributes.key?(:'tax_name')
145
+ self.tax_name = attributes[:'tax_name']
146
+ end
147
+
148
+ if attributes.key?(:'tracking_categories')
149
+ if (value = attributes[:'tracking_categories']).is_a?(Array)
150
+ self.tracking_categories = value
151
+ end
152
+ end
153
+ end
154
+
155
+ # Show invalid properties with the reasons. Usually used together with valid?
156
+ # @return Array for valid properties with the reasons
157
+ def list_invalid_properties
158
+ invalid_properties = Array.new
159
+ invalid_properties
160
+ end
161
+
162
+ # Check to see if the all the properties in the model are valid
163
+ # @return true if the model is valid
164
+ def valid?
165
+ true
166
+ end
167
+
168
+ # Checks equality by comparing each attribute.
169
+ # @param [Object] Object to be compared
170
+ def ==(o)
171
+ return true if self.equal?(o)
172
+ self.class == o.class &&
173
+ journal_line_id == o.journal_line_id &&
174
+ account_id == o.account_id &&
175
+ account_code == o.account_code &&
176
+ account_type == o.account_type &&
177
+ account_name == o.account_name &&
178
+ description == o.description &&
179
+ net_amount == o.net_amount &&
180
+ gross_amount == o.gross_amount &&
181
+ tax_amount == o.tax_amount &&
182
+ tax_type == o.tax_type &&
183
+ tax_name == o.tax_name &&
184
+ tracking_categories == o.tracking_categories
185
+ end
186
+
187
+ # @see the `==` method
188
+ # @param [Object] Object to be compared
189
+ def eql?(o)
190
+ self == o
191
+ end
192
+
193
+ # Calculates hash code according to all attributes.
194
+ # @return [Integer] Hash code
195
+ def hash
196
+ [journal_line_id, account_id, account_code, account_type, account_name, description, net_amount, gross_amount, tax_amount, tax_type, tax_name, tracking_categories].hash
197
+ end
198
+
199
+ # Builds the object from hash
200
+ # @param [Hash] attributes Model attributes in the form of hash
201
+ # @return [Object] Returns the model itself
202
+ def self.build_from_hash(attributes)
203
+ new.build_from_hash(attributes)
204
+ end
205
+
206
+ # Builds the object from hash
207
+ # @param [Hash] attributes Model attributes in the form of hash
208
+ # @return [Object] Returns the model itself
209
+ def build_from_hash(attributes)
210
+ return nil unless attributes.is_a?(Hash)
211
+ self.class.openapi_types.each_pair do |key, type|
212
+ if type =~ /\AArray<(.*)>/i
213
+ # check to ensure the input is an array given that the attribute
214
+ # is documented as an array but the input is not
215
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
216
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
217
+ end
218
+ elsif !attributes[self.class.attribute_map[key]].nil?
219
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
220
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
221
+ end
222
+
223
+ self
224
+ end
225
+
226
+ # Deserializes the data based on type
227
+ # @param string type Data type
228
+ # @param string value Value to be deserialized
229
+ # @return [Object] Deserialized data
230
+ def _deserialize(type, value)
231
+ case type.to_sym
232
+ when :DateTime
233
+ DateTime.parse(parse_date(value))
234
+ when :Date
235
+ Date._iso8601(parse_date(value))
236
+ when :String
237
+ value.to_s
238
+ when :Integer
239
+ value.to_i
240
+ when :Float
241
+ value.to_f
242
+ when :Boolean
243
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
244
+ true
245
+ else
246
+ false
247
+ end
248
+ when :Object
249
+ # generic object (usually a Hash), return directly
250
+ value
251
+ when /\AArray<(?<inner_type>.+)>\z/
252
+ inner_type = Regexp.last_match[:inner_type]
253
+ value.map { |v| _deserialize(inner_type, v) }
254
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
255
+ k_type = Regexp.last_match[:k_type]
256
+ v_type = Regexp.last_match[:v_type]
257
+ {}.tap do |hash|
258
+ value.each do |k, v|
259
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
260
+ end
261
+ end
262
+ else # model
263
+ XeroRuby.const_get(type).build_from_hash(value)
264
+ end
265
+ end
266
+
267
+ # Returns the string representation of the object
268
+ # @return [String] String presentation of the object
269
+ def to_s
270
+ to_hash.to_s
271
+ end
272
+
273
+ # to_body is an alias to to_hash (backward compatibility)
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_body
276
+ to_hash
277
+ end
278
+
279
+ # Returns the object in the form of hash
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_hash
282
+ hash = {}
283
+ self.class.attribute_map.each_pair do |attr, param|
284
+ value = self.send(attr)
285
+ next if value.nil?
286
+ hash[param] = _to_hash(value)
287
+ end
288
+ hash
289
+ end
290
+
291
+ # Outputs non-array value in the form of hash
292
+ # For object, use to_hash. Otherwise, just return the value
293
+ # @param [Object] value Any valid value
294
+ # @return [Hash] Returns the value in the form of hash
295
+ def _to_hash(value)
296
+ if value.is_a?(Array)
297
+ value.compact.map { |v| _to_hash(v) }
298
+ elsif value.is_a?(Hash)
299
+ {}.tap do |hash|
300
+ value.each { |k, v| hash[k] = _to_hash(v) }
301
+ end
302
+ elsif value.respond_to? :to_hash
303
+ value.to_hash
304
+ else
305
+ value
306
+ end
307
+ end
308
+
309
+ # customized data_parser
310
+ def parse_date(datestring)
311
+ seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0
312
+ return Time.at(seconds_since_epoch).to_s
313
+ end
314
+ end
315
+ end