xero-ruby 1.1.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +181 -72
- data/build_notes.md +43 -0
- data/docs/accounting/AccountingApi.md +1503 -779
- data/docs/accounting/Allocation.md +11 -1
- data/docs/accounting/Attachment.md +1 -1
- data/docs/accounting/BankTransfer.md +1 -1
- data/docs/accounting/BatchPayment.md +1 -1
- data/docs/accounting/Contact.md +2 -2
- data/docs/accounting/CreditNote.md +2 -2
- data/docs/accounting/Invoice.md +2 -2
- data/docs/accounting/ManualJournalLine.md +2 -0
- data/docs/accounting/Organisation.md +3 -1
- data/docs/accounting/Payment.md +4 -4
- data/docs/accounting/Quote.md +5 -1
- data/docs/accounting/Report.md +1 -1
- data/docs/accounting/{TenNinteyNineContact.md → TenNinetyNineContact.md} +2 -2
- data/docs/assets/AssetApi.md +40 -16
- data/docs/assets/AssetType.md +1 -1
- data/docs/projects/Amount.md +19 -0
- data/docs/projects/ChargeType.md +16 -0
- data/docs/projects/CurrencyCode.md +16 -0
- data/docs/projects/Error.md +19 -0
- data/docs/projects/Pagination.md +23 -0
- data/docs/projects/Project.md +59 -0
- data/docs/projects/ProjectApi.md +979 -0
- data/docs/projects/ProjectCreateOrUpdate.md +23 -0
- data/docs/projects/ProjectPatch.md +17 -0
- data/docs/projects/ProjectStatus.md +16 -0
- data/docs/projects/ProjectUser.md +21 -0
- data/docs/projects/ProjectUsers.md +19 -0
- data/docs/projects/Projects.md +19 -0
- data/docs/projects/Task.md +45 -0
- data/docs/projects/TaskCreateOrUpdate.md +23 -0
- data/docs/projects/Tasks.md +19 -0
- data/docs/projects/TimeEntries.md +19 -0
- data/docs/projects/TimeEntry.md +33 -0
- data/docs/projects/TimeEntryCreateOrUpdate.md +25 -0
- data/lib/xero-ruby.rb +22 -3
- data/lib/xero-ruby/api/accounting_api.rb +1368 -72
- data/lib/xero-ruby/api/asset_api.rb +39 -3
- data/lib/xero-ruby/api/project_api.rb +1113 -0
- data/lib/xero-ruby/api_client.rb +104 -38
- data/lib/xero-ruby/api_error.rb +2 -2
- data/lib/xero-ruby/configuration.rb +4 -5
- data/lib/xero-ruby/models/accounting/account.rb +61 -20
- data/lib/xero-ruby/models/accounting/account_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/accounts.rb +8 -3
- data/lib/xero-ruby/models/accounting/accounts_payable.rb +11 -5
- data/lib/xero-ruby/models/accounting/accounts_receivable.rb +11 -5
- data/lib/xero-ruby/models/accounting/address.rb +19 -12
- data/lib/xero-ruby/models/accounting/allocation.rb +66 -9
- data/lib/xero-ruby/models/accounting/allocations.rb +8 -3
- data/lib/xero-ruby/models/accounting/attachment.rb +13 -9
- data/lib/xero-ruby/models/accounting/attachments.rb +8 -3
- data/lib/xero-ruby/models/accounting/balances.rb +9 -3
- data/lib/xero-ruby/models/accounting/bank_transaction.rb +43 -24
- data/lib/xero-ruby/models/accounting/bank_transactions.rb +8 -3
- data/lib/xero-ruby/models/accounting/bank_transfer.rb +20 -14
- data/lib/xero-ruby/models/accounting/bank_transfers.rb +8 -3
- data/lib/xero-ruby/models/accounting/batch_payment.rb +29 -19
- data/lib/xero-ruby/models/accounting/batch_payment_details.rb +11 -7
- data/lib/xero-ruby/models/accounting/batch_payments.rb +8 -3
- data/lib/xero-ruby/models/accounting/bill.rb +8 -3
- data/lib/xero-ruby/models/accounting/branding_theme.rb +13 -8
- data/lib/xero-ruby/models/accounting/branding_themes.rb +8 -3
- data/lib/xero-ruby/models/accounting/cis_org_setting.rb +9 -5
- data/lib/xero-ruby/models/accounting/cis_setting.rb +8 -4
- data/lib/xero-ruby/models/accounting/cis_settings.rb +8 -3
- data/lib/xero-ruby/models/accounting/contact.rb +51 -37
- data/lib/xero-ruby/models/accounting/contact_group.rb +12 -6
- data/lib/xero-ruby/models/accounting/contact_groups.rb +8 -3
- data/lib/xero-ruby/models/accounting/contact_person.rb +10 -6
- data/lib/xero-ruby/models/accounting/contacts.rb +8 -3
- data/lib/xero-ruby/models/accounting/country_code.rb +2 -2
- data/lib/xero-ruby/models/accounting/credit_note.rb +47 -30
- data/lib/xero-ruby/models/accounting/credit_notes.rb +8 -3
- data/lib/xero-ruby/models/accounting/currencies.rb +8 -3
- data/lib/xero-ruby/models/accounting/currency.rb +9 -4
- data/lib/xero-ruby/models/accounting/currency_code.rb +2 -2
- data/lib/xero-ruby/models/accounting/element.rb +14 -4
- data/lib/xero-ruby/models/accounting/employee.rb +17 -8
- data/lib/xero-ruby/models/accounting/employees.rb +8 -3
- data/lib/xero-ruby/models/accounting/error.rb +10 -6
- data/lib/xero-ruby/models/accounting/expense_claim.rb +26 -15
- data/lib/xero-ruby/models/accounting/expense_claims.rb +8 -3
- data/lib/xero-ruby/models/accounting/external_link.rb +14 -4
- data/lib/xero-ruby/models/accounting/history_record.rb +10 -6
- data/lib/xero-ruby/models/accounting/history_records.rb +8 -3
- data/lib/xero-ruby/models/accounting/invoice.rb +69 -46
- data/lib/xero-ruby/models/accounting/invoice_reminder.rb +7 -3
- data/lib/xero-ruby/models/accounting/invoice_reminders.rb +8 -3
- data/lib/xero-ruby/models/accounting/invoices.rb +8 -3
- data/lib/xero-ruby/models/accounting/item.rb +24 -18
- data/lib/xero-ruby/models/accounting/items.rb +8 -3
- data/lib/xero-ruby/models/accounting/journal.rb +39 -10
- data/lib/xero-ruby/models/accounting/journal_line.rb +21 -16
- data/lib/xero-ruby/models/accounting/journals.rb +8 -3
- data/lib/xero-ruby/models/accounting/line_amount_types.rb +2 -2
- data/lib/xero-ruby/models/accounting/line_item.rb +25 -21
- data/lib/xero-ruby/models/accounting/line_item_tracking.rb +10 -6
- data/lib/xero-ruby/models/accounting/linked_transaction.rb +25 -13
- data/lib/xero-ruby/models/accounting/linked_transactions.rb +8 -3
- data/lib/xero-ruby/models/accounting/manual_journal.rb +25 -15
- data/lib/xero-ruby/models/accounting/manual_journal_line.rb +26 -12
- data/lib/xero-ruby/models/accounting/manual_journals.rb +8 -3
- data/lib/xero-ruby/models/accounting/online_invoice.rb +7 -3
- data/lib/xero-ruby/models/accounting/online_invoices.rb +8 -3
- data/lib/xero-ruby/models/accounting/organisation.rb +122 -32
- data/lib/xero-ruby/models/accounting/organisations.rb +8 -3
- data/lib/xero-ruby/models/accounting/overpayment.rb +36 -23
- data/lib/xero-ruby/models/accounting/overpayments.rb +8 -3
- data/lib/xero-ruby/models/accounting/payment.rb +47 -24
- data/lib/xero-ruby/models/accounting/payment_delete.rb +7 -3
- data/lib/xero-ruby/models/accounting/payment_service.rb +12 -8
- data/lib/xero-ruby/models/accounting/payment_services.rb +8 -3
- data/lib/xero-ruby/models/accounting/payment_term.rb +9 -3
- data/lib/xero-ruby/models/accounting/payment_term_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/payments.rb +8 -3
- data/lib/xero-ruby/models/accounting/phone.rb +16 -6
- data/lib/xero-ruby/models/accounting/prepayment.rb +37 -23
- data/lib/xero-ruby/models/accounting/prepayments.rb +8 -3
- data/lib/xero-ruby/models/accounting/purchase.rb +11 -7
- data/lib/xero-ruby/models/accounting/purchase_order.rb +45 -33
- data/lib/xero-ruby/models/accounting/purchase_orders.rb +8 -3
- data/lib/xero-ruby/models/accounting/quote.rb +58 -28
- data/lib/xero-ruby/models/accounting/quote_line_amount_types.rb +2 -2
- data/lib/xero-ruby/models/accounting/quote_status_codes.rb +3 -2
- data/lib/xero-ruby/models/accounting/quotes.rb +8 -3
- data/lib/xero-ruby/models/accounting/receipt.rb +32 -19
- data/lib/xero-ruby/models/accounting/receipts.rb +8 -3
- data/lib/xero-ruby/models/accounting/repeating_invoice.rb +30 -17
- data/lib/xero-ruby/models/accounting/repeating_invoices.rb +8 -3
- data/lib/xero-ruby/models/accounting/report.rb +15 -9
- data/lib/xero-ruby/models/accounting/report_attribute.rb +9 -3
- data/lib/xero-ruby/models/accounting/report_cell.rb +9 -3
- data/lib/xero-ruby/models/accounting/report_fields.rb +10 -3
- data/lib/xero-ruby/models/accounting/report_row.rb +10 -3
- data/lib/xero-ruby/models/accounting/report_rows.rb +11 -3
- data/lib/xero-ruby/models/accounting/report_with_row.rb +15 -9
- data/lib/xero-ruby/models/accounting/report_with_rows.rb +8 -3
- data/lib/xero-ruby/models/accounting/reports.rb +8 -3
- data/lib/xero-ruby/models/accounting/request_empty.rb +7 -3
- data/lib/xero-ruby/models/accounting/row_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +8 -4
- data/lib/xero-ruby/models/accounting/schedule.rb +23 -11
- data/lib/xero-ruby/models/accounting/tax_component.rb +11 -7
- data/lib/xero-ruby/models/accounting/tax_rate.rb +100 -18
- data/lib/xero-ruby/models/accounting/tax_rates.rb +8 -3
- data/lib/xero-ruby/models/accounting/tax_type.rb +2 -2
- data/lib/xero-ruby/models/accounting/{ten_nintey_nine_contact.rb → ten_ninety_nine_contact.rb} +44 -40
- data/lib/xero-ruby/models/accounting/time_zone.rb +2 -2
- data/lib/xero-ruby/models/accounting/tracking_categories.rb +8 -3
- data/lib/xero-ruby/models/accounting/tracking_category.rb +15 -8
- data/lib/xero-ruby/models/accounting/tracking_option.rb +13 -6
- data/lib/xero-ruby/models/accounting/tracking_options.rb +8 -3
- data/lib/xero-ruby/models/accounting/user.rb +20 -9
- data/lib/xero-ruby/models/accounting/users.rb +8 -3
- data/lib/xero-ruby/models/accounting/validation_error.rb +7 -3
- data/lib/xero-ruby/models/assets/asset.rb +24 -17
- data/lib/xero-ruby/models/assets/asset_status.rb +2 -2
- data/lib/xero-ruby/models/assets/asset_status_query_param.rb +2 -2
- data/lib/xero-ruby/models/assets/asset_type.rb +13 -13
- data/lib/xero-ruby/models/assets/assets.rb +9 -3
- data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +19 -15
- data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +26 -11
- data/lib/xero-ruby/models/assets/error.rb +11 -7
- data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +12 -8
- data/lib/xero-ruby/models/assets/pagination.rb +11 -3
- data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +11 -7
- data/lib/xero-ruby/models/assets/setting.rb +14 -10
- data/lib/xero-ruby/models/projects/amount.rb +218 -0
- data/lib/xero-ruby/models/projects/charge_type.rb +38 -0
- data/lib/xero-ruby/models/projects/currency_code.rb +199 -0
- data/lib/xero-ruby/models/projects/error.rb +218 -0
- data/lib/xero-ruby/models/projects/pagination.rb +238 -0
- data/lib/xero-ruby/models/projects/project.rb +423 -0
- data/lib/xero-ruby/models/projects/project_create_or_update.rb +243 -0
- data/lib/xero-ruby/models/projects/project_patch.rb +213 -0
- data/lib/xero-ruby/models/projects/project_status.rb +37 -0
- data/lib/xero-ruby/models/projects/project_user.rb +228 -0
- data/lib/xero-ruby/models/projects/project_users.rb +220 -0
- data/lib/xero-ruby/models/projects/projects.rb +220 -0
- data/lib/xero-ruby/models/projects/task.rb +385 -0
- data/lib/xero-ruby/models/projects/task_create_or_update.rb +253 -0
- data/lib/xero-ruby/models/projects/tasks.rb +220 -0
- data/lib/xero-ruby/models/projects/time_entries.rb +220 -0
- data/lib/xero-ruby/models/projects/time_entry.rb +324 -0
- data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +268 -0
- data/lib/xero-ruby/version.rb +3 -3
- data/spec/accounting/api/accounting_api_spec.rb +3 -3
- data/spec/accounting/models/ten_nintey_nine_contact_spec.rb +6 -6
- data/spec/api_client_spec.rb +125 -38
- data/spec/assets/api/asset_api_spec.rb +3 -3
- data/spec/configuration_spec.rb +7 -23
- data/spec/projects/api/project_api_spec.rb +229 -0
- data/spec/projects/models/amount_spec.rb +47 -0
- data/spec/projects/models/charge_type_spec.rb +35 -0
- data/spec/projects/models/currency_code_spec.rb +35 -0
- data/spec/projects/models/error_spec.rb +47 -0
- data/spec/projects/models/pagination_spec.rb +59 -0
- data/spec/projects/models/project_create_or_update_spec.rb +59 -0
- data/spec/projects/models/project_patch_spec.rb +41 -0
- data/spec/projects/models/project_spec.rb +167 -0
- data/spec/projects/models/project_status_spec.rb +35 -0
- data/spec/projects/models/project_user_spec.rb +53 -0
- data/spec/projects/models/project_users_spec.rb +47 -0
- data/spec/projects/models/projects_spec.rb +47 -0
- data/spec/projects/models/task_create_or_update_spec.rb +59 -0
- data/spec/projects/models/task_spec.rb +129 -0
- data/spec/projects/models/tasks_spec.rb +47 -0
- data/spec/projects/models/time_entries_spec.rb +47 -0
- data/spec/projects/models/time_entry_create_or_update_spec.rb +65 -0
- data/spec/projects/models/time_entry_spec.rb +93 -0
- data/xero-ruby.gemspec +3 -4
- metadata +85 -10
- data/xero-ruby-1.0.gem +0 -0
- data/xero-ruby.gem +0 -0
data/lib/xero-ruby/api_client.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
5
|
|
6
|
-
The version of the OpenAPI document: 2.
|
6
|
+
The version of the OpenAPI document: 2.2.12
|
7
7
|
Contact: api@xero.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.3.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -14,6 +14,7 @@ require 'date'
|
|
14
14
|
require 'json'
|
15
15
|
require 'logger'
|
16
16
|
require 'tempfile'
|
17
|
+
require 'find'
|
17
18
|
require 'faraday'
|
18
19
|
|
19
20
|
module XeroRuby
|
@@ -56,6 +57,11 @@ module XeroRuby
|
|
56
57
|
XeroRuby::AssetApi.new(self)
|
57
58
|
end
|
58
59
|
|
60
|
+
def project_api
|
61
|
+
@config.base_url = @config.project_url
|
62
|
+
XeroRuby::ProjectApi.new(self)
|
63
|
+
end
|
64
|
+
|
59
65
|
# Token Helpers
|
60
66
|
def token_set
|
61
67
|
XeroRuby.configure.token_set
|
@@ -170,6 +176,7 @@ module XeroRuby
|
|
170
176
|
end
|
171
177
|
|
172
178
|
if opts[:return_type]
|
179
|
+
prepare_file(response) if opts[:return_type] == 'File'
|
173
180
|
data = deserialize(response, opts[:return_type])
|
174
181
|
else
|
175
182
|
data = nil
|
@@ -185,7 +192,7 @@ module XeroRuby
|
|
185
192
|
# @option opts [Hash] :query_params Query parameters
|
186
193
|
# @option opts [Hash] :form_params Query parameters
|
187
194
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
188
|
-
# @return
|
195
|
+
# @return A Faraday Request
|
189
196
|
def build_request(http_method, path, request, opts = {})
|
190
197
|
url = build_request_url(path)
|
191
198
|
http_method = http_method.to_sym.downcase
|
@@ -216,7 +223,6 @@ module XeroRuby
|
|
216
223
|
request.body = req_body
|
217
224
|
request.url url
|
218
225
|
request.params = query_params
|
219
|
-
download_file(request) if opts[:return_type] == 'File'
|
220
226
|
request
|
221
227
|
end
|
222
228
|
|
@@ -293,9 +299,9 @@ module XeroRuby
|
|
293
299
|
else
|
294
300
|
raise e
|
295
301
|
end
|
296
|
-
end
|
302
|
+
end
|
297
303
|
|
298
|
-
convert_to_type
|
304
|
+
convert_to_type(data, return_type)
|
299
305
|
end
|
300
306
|
|
301
307
|
# Convert data to the given return type.
|
@@ -333,14 +339,34 @@ module XeroRuby
|
|
333
339
|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
334
340
|
end
|
335
341
|
else
|
336
|
-
|
342
|
+
api_set = api_set_prefix(return_type)
|
343
|
+
case api_set
|
344
|
+
when 'accounting'
|
337
345
|
XeroRuby::Accounting.const_get(return_type).build_from_hash(data)
|
338
|
-
|
346
|
+
when 'assets'
|
339
347
|
XeroRuby::Assets.const_get(return_type).build_from_hash(data)
|
340
|
-
|
348
|
+
when 'projects'
|
349
|
+
XeroRuby::Projects.const_get(return_type).build_from_hash(data)
|
350
|
+
# when 'newapiset' # add new namespace
|
341
351
|
# XeroRuby::<NewAPISet>.const_get(return_type).build_from_hash(data)
|
352
|
+
else
|
353
|
+
XeroRuby::Accounting.const_get(return_type).build_from_hash(data)
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
# Traverses the model tree to find the model's namespacing
|
359
|
+
# based on the deserializing model/return_type name
|
360
|
+
def api_set_prefix(return_type)
|
361
|
+
api_set = ''
|
362
|
+
Find.find("#{File.dirname(__FILE__)}/models/") do |path|
|
363
|
+
model_path = path.split('/')
|
364
|
+
matching_name = model_path.last.gsub('.rb','').gsub("_",'')
|
365
|
+
if return_type.downcase === matching_name
|
366
|
+
api_set = path.split('/')[-2]
|
342
367
|
end
|
343
368
|
end
|
369
|
+
return api_set
|
344
370
|
end
|
345
371
|
|
346
372
|
# Save response body into a file in (the defined) temporary folder, using the filename
|
@@ -350,33 +376,24 @@ module XeroRuby
|
|
350
376
|
# process can use.
|
351
377
|
#
|
352
378
|
# @see Configuration#temp_folder_path
|
353
|
-
def
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
prefix = sanitize_filename(filename)
|
361
|
-
else
|
362
|
-
prefix = 'download-'
|
363
|
-
end
|
364
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
365
|
-
encoding = response.body.encoding
|
366
|
-
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
367
|
-
@tempfile = tempfile
|
368
|
-
end
|
369
|
-
request.on_body do |chunk|
|
370
|
-
chunk.force_encoding(encoding)
|
371
|
-
tempfile.write(chunk)
|
372
|
-
end
|
373
|
-
request.on_complete do |response|
|
374
|
-
tempfile.close if tempfile
|
375
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
376
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
377
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
378
|
-
"explicitly with `tempfile.delete`"
|
379
|
+
def prepare_file(response)
|
380
|
+
content_disposition = response.headers['Content-Disposition']
|
381
|
+
if content_disposition && content_disposition =~ /filename=/i
|
382
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
383
|
+
prefix = sanitize_filename(filename)
|
384
|
+
else
|
385
|
+
prefix = 'download-'
|
379
386
|
end
|
387
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
388
|
+
encoding = response.body.encoding
|
389
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
390
|
+
@tempfile = tempfile
|
391
|
+
tempfile.write(response.body)
|
392
|
+
tempfile.close if tempfile
|
393
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
394
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
395
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
396
|
+
"explicitly with `tempfile.delete`"
|
380
397
|
end
|
381
398
|
|
382
399
|
# Sanitize filename by removing path.
|
@@ -459,12 +476,61 @@ module XeroRuby
|
|
459
476
|
# @return [String] JSON string representation of the object
|
460
477
|
def object_to_hash(obj)
|
461
478
|
if obj.respond_to?(:to_hash)
|
462
|
-
obj.to_hash
|
479
|
+
to_camel_keys(obj).to_hash
|
463
480
|
else
|
464
|
-
obj
|
481
|
+
to_camel_keys(obj)
|
465
482
|
end
|
466
483
|
end
|
467
484
|
|
485
|
+
# START - Re-serializes snake_cased params to PascalCase required by XeroAPI
|
486
|
+
def to_camel_keys(value = self)
|
487
|
+
case value
|
488
|
+
when Array
|
489
|
+
value.map { |v| to_camel_keys(v) }
|
490
|
+
when Hash
|
491
|
+
Hash[value.map { |k, v| [camelize_key(k), to_camel_keys(v)] }]
|
492
|
+
else
|
493
|
+
value
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
def camelize_key(key, first_upper = true)
|
498
|
+
if key.is_a? Symbol
|
499
|
+
camelize(key.to_s, first_upper).to_sym
|
500
|
+
elsif key.is_a? String
|
501
|
+
camelize(key, first_upper)
|
502
|
+
else
|
503
|
+
key # can't camelize anything except strings and symbols
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
def camelize(word, first_upper = true)
|
508
|
+
if first_upper
|
509
|
+
str = word.to_s
|
510
|
+
str = gsubbed(str, /(?:^|_)([^_\s]+)/)
|
511
|
+
str = gsubbed(str, %r{/([^/]*)}, "::")
|
512
|
+
str
|
513
|
+
else
|
514
|
+
parts = word.split("_", 2)
|
515
|
+
parts[0] << camelize(parts[1]) if parts.size > 1
|
516
|
+
parts[0] || ""
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
def gsubbed(str, pattern, extra = "")
|
521
|
+
key_map_scronyms = {}
|
522
|
+
str = str.gsub(pattern) do
|
523
|
+
extra + (key_map_scronyms[Regexp.last_match(1)] || capitalize_first(Regexp.last_match(1)))
|
524
|
+
end
|
525
|
+
str
|
526
|
+
end
|
527
|
+
|
528
|
+
def capitalize_first(word)
|
529
|
+
split = word.split('')
|
530
|
+
"#{split[0].capitalize}#{split[1..-1].join}"
|
531
|
+
end
|
532
|
+
# END - Re-serializes snake_cased params to PascalCase required by XeroAPI
|
533
|
+
|
468
534
|
# Build parameter value according to the given collection format.
|
469
535
|
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
470
536
|
def build_collection_param(param, collection_format)
|
@@ -478,7 +544,7 @@ module XeroRuby
|
|
478
544
|
when :pipes
|
479
545
|
param.join('|')
|
480
546
|
when :multi
|
481
|
-
# return the array directly as
|
547
|
+
# return the array directly as http client will handle it as expected
|
482
548
|
param
|
483
549
|
else
|
484
550
|
fail "unknown collection format: #{collection_format.inspect}"
|
data/lib/xero-ruby/api_error.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
5
|
|
6
|
-
The version of the OpenAPI document: 2.
|
6
|
+
The version of the OpenAPI document: 2.2.12
|
7
7
|
Contact: api@xero.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.3.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
5
|
|
6
|
-
The version of the OpenAPI document: 2.
|
6
|
+
The version of the OpenAPI document: 2.2.12
|
7
7
|
Contact: api@xero.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.3.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -29,6 +29,7 @@ module XeroRuby
|
|
29
29
|
# Defines base paths for seperate API's
|
30
30
|
attr_accessor :accounting_url
|
31
31
|
attr_accessor :asset_url
|
32
|
+
attr_accessor :project_url
|
32
33
|
|
33
34
|
# Defines API keys used with API Key authentications.
|
34
35
|
#
|
@@ -123,9 +124,6 @@ module XeroRuby
|
|
123
124
|
|
124
125
|
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
125
126
|
# Default to nil.
|
126
|
-
#
|
127
|
-
# @see The params_encoding option of Ethon. Related source code:
|
128
|
-
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
129
127
|
attr_accessor :params_encoding
|
130
128
|
|
131
129
|
attr_accessor :inject_format
|
@@ -140,6 +138,7 @@ module XeroRuby
|
|
140
138
|
@token_url = 'https://identity.xero.com/connect/token'
|
141
139
|
@accounting_url = 'https://api.xero.com/api.xro/2.0'
|
142
140
|
@asset_url = 'https://api.xero.com/assets.xro/1.0'
|
141
|
+
@project_url = 'https://api.xero.com/projects.xro/2.0/'
|
143
142
|
@api_key = {}
|
144
143
|
@api_key_prefix = {}
|
145
144
|
@timeout = 0
|
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
5
|
|
6
|
-
The version of the OpenAPI document: 2.
|
6
|
+
The version of the OpenAPI document: 2.2.12
|
7
7
|
Contact: api@xero.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.3.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -14,65 +14,104 @@ require 'time'
|
|
14
14
|
require 'date'
|
15
15
|
|
16
16
|
module XeroRuby::Accounting
|
17
|
+
require 'bigdecimal'
|
18
|
+
|
17
19
|
class Account
|
18
20
|
# Customer defined alpha numeric account code e.g 200 or SALES (max length = 10)
|
19
21
|
attr_accessor :code
|
20
|
-
|
22
|
+
|
21
23
|
# Name of account (max length = 150)
|
22
24
|
attr_accessor :name
|
23
|
-
|
25
|
+
|
24
26
|
# The Xero identifier for an account – specified as a string following the endpoint name e.g. /297c2dc5-cc47-4afd-8ec8-74990b8761e9
|
25
27
|
attr_accessor :account_id
|
28
|
+
|
26
29
|
|
27
30
|
attr_accessor :type
|
28
|
-
|
31
|
+
|
29
32
|
# For bank accounts only (Account Type BANK)
|
30
33
|
attr_accessor :bank_account_number
|
31
|
-
|
34
|
+
|
32
35
|
# Accounts with a status of ACTIVE can be updated to ARCHIVED. See Account Status Codes
|
33
36
|
attr_accessor :status
|
34
|
-
|
37
|
+
ACTIVE = "ACTIVE".freeze
|
38
|
+
ARCHIVED = "ARCHIVED".freeze
|
39
|
+
DELETED = "DELETED".freeze
|
40
|
+
|
35
41
|
# Description of the Account. Valid for all types of accounts except bank accounts (max length = 4000)
|
36
42
|
attr_accessor :description
|
37
|
-
|
43
|
+
|
38
44
|
# For bank accounts only. See Bank Account types
|
39
45
|
attr_accessor :bank_account_type
|
46
|
+
BANK = "BANK".freeze
|
47
|
+
CREDITCARD = "CREDITCARD".freeze
|
48
|
+
PAYPAL = "PAYPAL".freeze
|
49
|
+
NONE = "NONE".freeze
|
50
|
+
EMPTY = "".freeze
|
51
|
+
|
40
52
|
|
41
53
|
attr_accessor :currency_code
|
42
|
-
|
54
|
+
|
43
55
|
# The tax type from TaxRates
|
44
56
|
attr_accessor :tax_type
|
45
|
-
|
57
|
+
|
46
58
|
# Boolean – describes whether account can have payments applied to it
|
47
59
|
attr_accessor :enable_payments_to_account
|
48
|
-
|
60
|
+
|
49
61
|
# Boolean – describes whether account code is available for use with expense claims
|
50
62
|
attr_accessor :show_in_expense_claims
|
51
|
-
|
63
|
+
|
52
64
|
# See Account Class Types
|
53
65
|
attr_accessor :_class
|
54
|
-
|
66
|
+
ASSET = "ASSET".freeze
|
67
|
+
EQUITY = "EQUITY".freeze
|
68
|
+
EXPENSE = "EXPENSE".freeze
|
69
|
+
LIABILITY = "LIABILITY".freeze
|
70
|
+
REVENUE = "REVENUE".freeze
|
71
|
+
|
55
72
|
# If this is a system account then this element is returned. See System Account types. Note that non-system accounts may have this element set as either “” or null.
|
56
73
|
attr_accessor :system_account
|
57
|
-
|
74
|
+
DEBTORS = "DEBTORS".freeze
|
75
|
+
CREDITORS = "CREDITORS".freeze
|
76
|
+
BANKCURRENCYGAIN = "BANKCURRENCYGAIN".freeze
|
77
|
+
GST = "GST".freeze
|
78
|
+
GSTONIMPORTS = "GSTONIMPORTS".freeze
|
79
|
+
HISTORICAL = "HISTORICAL".freeze
|
80
|
+
REALISEDCURRENCYGAIN = "REALISEDCURRENCYGAIN".freeze
|
81
|
+
RETAINEDEARNINGS = "RETAINEDEARNINGS".freeze
|
82
|
+
ROUNDING = "ROUNDING".freeze
|
83
|
+
TRACKINGTRANSFERS = "TRACKINGTRANSFERS".freeze
|
84
|
+
UNPAIDEXPCLM = "UNPAIDEXPCLM".freeze
|
85
|
+
UNREALISEDCURRENCYGAIN = "UNREALISEDCURRENCYGAIN".freeze
|
86
|
+
WAGEPAYABLES = "WAGEPAYABLES".freeze
|
87
|
+
CISASSETS = "CISASSETS".freeze
|
88
|
+
CISASSET = "CISASSET".freeze
|
89
|
+
CISLABOUR = "CISLABOUR".freeze
|
90
|
+
CISLABOUREXPENSE = "CISLABOUREXPENSE".freeze
|
91
|
+
CISLABOURINCOME = "CISLABOURINCOME".freeze
|
92
|
+
CISLIABILITY = "CISLIABILITY".freeze
|
93
|
+
CISMATERIALS = "CISMATERIALS".freeze
|
94
|
+
# duplicate definitions generated: https://github.com/XeroAPI/xero-ruby/issues/53#issuecomment-668893305
|
95
|
+
# EMPTY = "".freeze
|
96
|
+
|
58
97
|
# Shown if set
|
59
98
|
attr_accessor :reporting_code
|
60
|
-
|
99
|
+
|
61
100
|
# Shown if set
|
62
101
|
attr_accessor :reporting_code_name
|
63
|
-
|
102
|
+
|
64
103
|
# boolean to indicate if an account has an attachment (read only)
|
65
104
|
attr_accessor :has_attachments
|
66
|
-
|
105
|
+
|
67
106
|
# Last modified date UTC format
|
68
107
|
attr_accessor :updated_date_utc
|
69
|
-
|
108
|
+
|
70
109
|
# Boolean – describes whether the account is shown in the watchlist widget on the dashboard
|
71
110
|
attr_accessor :add_to_watchlist
|
72
|
-
|
111
|
+
|
73
112
|
# Displays array of validation error messages from the API
|
74
113
|
attr_accessor :validation_errors
|
75
|
-
|
114
|
+
|
76
115
|
class EnumAttributeValidator
|
77
116
|
attr_reader :datatype
|
78
117
|
attr_reader :allowable_values
|
@@ -420,6 +459,8 @@ module XeroRuby::Accounting
|
|
420
459
|
value.to_i
|
421
460
|
when :Float
|
422
461
|
value.to_f
|
462
|
+
when :BigDecimal
|
463
|
+
BigDecimal(value.to_s)
|
423
464
|
when :Boolean
|
424
465
|
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
425
466
|
true
|
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
5
|
|
6
|
-
The version of the OpenAPI document: 2.
|
6
|
+
The version of the OpenAPI document: 2.2.12
|
7
7
|
Contact: api@xero.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.3.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
5
|
|
6
|
-
The version of the OpenAPI document: 2.
|
6
|
+
The version of the OpenAPI document: 2.2.12
|
7
7
|
Contact: api@xero.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.3.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -14,9 +14,12 @@ require 'time'
|
|
14
14
|
require 'date'
|
15
15
|
|
16
16
|
module XeroRuby::Accounting
|
17
|
+
require 'bigdecimal'
|
18
|
+
|
17
19
|
class Accounts
|
18
|
-
attr_accessor :accounts
|
19
20
|
|
21
|
+
attr_accessor :accounts
|
22
|
+
|
20
23
|
# Attribute mapping from ruby-style variable name to JSON key.
|
21
24
|
def self.attribute_map
|
22
25
|
{
|
@@ -129,6 +132,8 @@ module XeroRuby::Accounting
|
|
129
132
|
value.to_i
|
130
133
|
when :Float
|
131
134
|
value.to_f
|
135
|
+
when :BigDecimal
|
136
|
+
BigDecimal(value.to_s)
|
132
137
|
when :Boolean
|
133
138
|
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
134
139
|
true
|