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