xero-apimatic-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +175 -0
- data/bin/console +15 -0
- data/lib/xero_ap_is/api_helper.rb +10 -0
- data/lib/xero_ap_is/apis/accounting_api.rb +8328 -0
- data/lib/xero_ap_is/apis/asset_api.rb +210 -0
- data/lib/xero_ap_is/apis/bank_feeds_api.rb +268 -0
- data/lib/xero_ap_is/apis/base_api.rb +67 -0
- data/lib/xero_ap_is/apis/identity_api.rb +51 -0
- data/lib/xero_ap_is/apis/oauth_authorization_api.rb +87 -0
- data/lib/xero_ap_is/apis/project_api.rb +662 -0
- data/lib/xero_ap_is/client.rb +110 -0
- data/lib/xero_ap_is/configuration.rb +196 -0
- data/lib/xero_ap_is/exceptions/api_exception.rb +21 -0
- data/lib/xero_ap_is/exceptions/asset_types400_error_exception.rb +72 -0
- data/lib/xero_ap_is/exceptions/assets400_error_exception.rb +72 -0
- data/lib/xero_ap_is/exceptions/error_error1_exception.rb +63 -0
- data/lib/xero_ap_is/exceptions/error_error2_exception.rb +51 -0
- data/lib/xero_ap_is/exceptions/error_exception.rb +72 -0
- data/lib/xero_ap_is/exceptions/feed_connections_error_exception.rb +60 -0
- data/lib/xero_ap_is/exceptions/oauth_provider_exception.rb +64 -0
- data/lib/xero_ap_is/exceptions/statements_error_exception.rb +60 -0
- data/lib/xero_ap_is/http/api_response.rb +19 -0
- data/lib/xero_ap_is/http/auth/basic_auth.rb +62 -0
- data/lib/xero_ap_is/http/auth/oauth_2.rb +161 -0
- data/lib/xero_ap_is/http/http_call_back.rb +10 -0
- data/lib/xero_ap_is/http/http_method_enum.rb +10 -0
- data/lib/xero_ap_is/http/http_request.rb +10 -0
- data/lib/xero_ap_is/http/http_response.rb +10 -0
- data/lib/xero_ap_is/http/proxy_settings.rb +22 -0
- data/lib/xero_ap_is/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/xero_ap_is/logging/sdk_logger.rb +17 -0
- data/lib/xero_ap_is/models/access_token.rb +116 -0
- data/lib/xero_ap_is/models/account.rb +300 -0
- data/lib/xero_ap_is/models/account_type.rb +100 -0
- data/lib/xero_ap_is/models/account_type1.rb +37 -0
- data/lib/xero_ap_is/models/accounts.rb +84 -0
- data/lib/xero_ap_is/models/accounts_payable.rb +85 -0
- data/lib/xero_ap_is/models/accounts_receivable.rb +85 -0
- data/lib/xero_ap_is/models/action.rb +85 -0
- data/lib/xero_ap_is/models/actions.rb +84 -0
- data/lib/xero_ap_is/models/address.rb +167 -0
- data/lib/xero_ap_is/models/address_for_organisation.rb +167 -0
- data/lib/xero_ap_is/models/address_type.rb +40 -0
- data/lib/xero_ap_is/models/address_type1.rb +36 -0
- data/lib/xero_ap_is/models/allocation.rb +174 -0
- data/lib/xero_ap_is/models/allocations.rb +85 -0
- data/lib/xero_ap_is/models/amount.rb +85 -0
- data/lib/xero_ap_is/models/asset.rb +249 -0
- data/lib/xero_ap_is/models/asset_status.rb +40 -0
- data/lib/xero_ap_is/models/asset_status_query_param.rb +40 -0
- data/lib/xero_ap_is/models/asset_type.rb +154 -0
- data/lib/xero_ap_is/models/assets.rb +94 -0
- data/lib/xero_ap_is/models/attachment.rb +126 -0
- data/lib/xero_ap_is/models/attachments.rb +85 -0
- data/lib/xero_ap_is/models/averaging_method.rb +36 -0
- data/lib/xero_ap_is/models/balance_details.rb +98 -0
- data/lib/xero_ap_is/models/balances.rb +89 -0
- data/lib/xero_ap_is/models/bank_account_type.rb +44 -0
- data/lib/xero_ap_is/models/bank_transaction.rb +319 -0
- data/lib/xero_ap_is/models/bank_transactions.rb +114 -0
- data/lib/xero_ap_is/models/bank_transfer.rb +224 -0
- data/lib/xero_ap_is/models/bank_transfers.rb +85 -0
- data/lib/xero_ap_is/models/base_model.rb +110 -0
- data/lib/xero_ap_is/models/batch_payment.rb +275 -0
- data/lib/xero_ap_is/models/batch_payment_delete.rb +84 -0
- data/lib/xero_ap_is/models/batch_payment_delete_by_url_param.rb +73 -0
- data/lib/xero_ap_is/models/batch_payment_details.rb +128 -0
- data/lib/xero_ap_is/models/batch_payments.rb +85 -0
- data/lib/xero_ap_is/models/bill.rb +85 -0
- data/lib/xero_ap_is/models/book_depreciation_detail.rb +243 -0
- data/lib/xero_ap_is/models/book_depreciation_setting.rb +170 -0
- data/lib/xero_ap_is/models/branding_theme.rb +129 -0
- data/lib/xero_ap_is/models/branding_themes.rb +85 -0
- data/lib/xero_ap_is/models/budget.rb +145 -0
- data/lib/xero_ap_is/models/budget_balance.rb +105 -0
- data/lib/xero_ap_is/models/budget_line.rb +105 -0
- data/lib/xero_ap_is/models/budgets.rb +84 -0
- data/lib/xero_ap_is/models/charge_type.rb +42 -0
- data/lib/xero_ap_is/models/cis_org_setting.rb +105 -0
- data/lib/xero_ap_is/models/cis_org_settings.rb +85 -0
- data/lib/xero_ap_is/models/cis_setting.rb +86 -0
- data/lib/xero_ap_is/models/cis_settings.rb +85 -0
- data/lib/xero_ap_is/models/class1.rb +113 -0
- data/lib/xero_ap_is/models/connection.rb +155 -0
- data/lib/xero_ap_is/models/contact.rb +661 -0
- data/lib/xero_ap_is/models/contact_group.rb +119 -0
- data/lib/xero_ap_is/models/contact_groups.rb +85 -0
- data/lib/xero_ap_is/models/contact_person.rb +108 -0
- data/lib/xero_ap_is/models/contact_status.rb +40 -0
- data/lib/xero_ap_is/models/contacts.rb +113 -0
- data/lib/xero_ap_is/models/conversion_balances.rb +108 -0
- data/lib/xero_ap_is/models/conversion_date.rb +87 -0
- data/lib/xero_ap_is/models/country_code.rb +990 -0
- data/lib/xero_ap_is/models/credit_debit_indicator.rb +37 -0
- data/lib/xero_ap_is/models/credit_note.rb +453 -0
- data/lib/xero_ap_is/models/credit_notes.rb +113 -0
- data/lib/xero_ap_is/models/currencies.rb +85 -0
- data/lib/xero_ap_is/models/currency.rb +85 -0
- data/lib/xero_ap_is/models/currency_code.rb +700 -0
- data/lib/xero_ap_is/models/currency_code1.rb +680 -0
- data/lib/xero_ap_is/models/depreciation_calculation_method.rb +40 -0
- data/lib/xero_ap_is/models/depreciation_method.rb +52 -0
- data/lib/xero_ap_is/models/due_date_type.rb +52 -0
- data/lib/xero_ap_is/models/edition.rb +38 -0
- data/lib/xero_ap_is/models/element.rb +160 -0
- data/lib/xero_ap_is/models/employee.rb +160 -0
- data/lib/xero_ap_is/models/employees.rb +85 -0
- data/lib/xero_ap_is/models/end_balance.rb +89 -0
- data/lib/xero_ap_is/models/error1.rb +138 -0
- data/lib/xero_ap_is/models/error2.rb +106 -0
- data/lib/xero_ap_is/models/error3.rb +85 -0
- data/lib/xero_ap_is/models/expense_claim.rb +209 -0
- data/lib/xero_ap_is/models/expense_claims.rb +85 -0
- data/lib/xero_ap_is/models/external_link.rb +95 -0
- data/lib/xero_ap_is/models/federal_tax_classification.rb +56 -0
- data/lib/xero_ap_is/models/feed_connection.rb +177 -0
- data/lib/xero_ap_is/models/feed_connections.rb +94 -0
- data/lib/xero_ap_is/models/field_validation_errors_element.rb +127 -0
- data/lib/xero_ap_is/models/history_record.rb +105 -0
- data/lib/xero_ap_is/models/history_records.rb +85 -0
- data/lib/xero_ap_is/models/import_summary.rb +87 -0
- data/lib/xero_ap_is/models/import_summary_accounts.rb +154 -0
- data/lib/xero_ap_is/models/import_summary_object.rb +76 -0
- data/lib/xero_ap_is/models/import_summary_organisation.rb +75 -0
- data/lib/xero_ap_is/models/invoice.rb +586 -0
- data/lib/xero_ap_is/models/invoice_address.rb +158 -0
- data/lib/xero_ap_is/models/invoice_address_type.rb +37 -0
- data/lib/xero_ap_is/models/invoice_reminder.rb +75 -0
- data/lib/xero_ap_is/models/invoice_reminders.rb +85 -0
- data/lib/xero_ap_is/models/invoices.rb +113 -0
- data/lib/xero_ap_is/models/item.rb +259 -0
- data/lib/xero_ap_is/models/items.rb +84 -0
- data/lib/xero_ap_is/models/journal.rb +157 -0
- data/lib/xero_ap_is/models/journal_line.rb +201 -0
- data/lib/xero_ap_is/models/journals.rb +103 -0
- data/lib/xero_ap_is/models/line_amount_types.rb +41 -0
- data/lib/xero_ap_is/models/line_item.rb +287 -0
- data/lib/xero_ap_is/models/line_item_item.rb +95 -0
- data/lib/xero_ap_is/models/line_item_tracking.rb +108 -0
- data/lib/xero_ap_is/models/link_type.rb +48 -0
- data/lib/xero_ap_is/models/linked_transaction.rb +215 -0
- data/lib/xero_ap_is/models/linked_transactions.rb +85 -0
- data/lib/xero_ap_is/models/manual_journal.rb +255 -0
- data/lib/xero_ap_is/models/manual_journal_line.rb +156 -0
- data/lib/xero_ap_is/models/manual_journals.rb +114 -0
- data/lib/xero_ap_is/models/mclass.rb +48 -0
- data/lib/xero_ap_is/models/oauth_provider_error.rb +62 -0
- data/lib/xero_ap_is/models/oauth_scope_oauth_2.rb +113 -0
- data/lib/xero_ap_is/models/oauth_token.rb +96 -0
- data/lib/xero_ap_is/models/online_invoice.rb +77 -0
- data/lib/xero_ap_is/models/online_invoices.rb +85 -0
- data/lib/xero_ap_is/models/order_by.rb +56 -0
- data/lib/xero_ap_is/models/organisation.rb +467 -0
- data/lib/xero_ap_is/models/organisation_entity_type.rb +80 -0
- data/lib/xero_ap_is/models/organisation_role.rb +61 -0
- data/lib/xero_ap_is/models/organisation_type.rb +80 -0
- data/lib/xero_ap_is/models/organisations.rb +85 -0
- data/lib/xero_ap_is/models/overpayment.rb +309 -0
- data/lib/xero_ap_is/models/overpayments.rb +113 -0
- data/lib/xero_ap_is/models/pagination.rb +105 -0
- data/lib/xero_ap_is/models/payment.rb +381 -0
- data/lib/xero_ap_is/models/payment_delete.rb +73 -0
- data/lib/xero_ap_is/models/payment_service.rb +143 -0
- data/lib/xero_ap_is/models/payment_services.rb +85 -0
- data/lib/xero_ap_is/models/payment_term.rb +85 -0
- data/lib/xero_ap_is/models/payment_term_type.rb +44 -0
- data/lib/xero_ap_is/models/payment_type.rb +60 -0
- data/lib/xero_ap_is/models/payments.rb +113 -0
- data/lib/xero_ap_is/models/phone.rb +108 -0
- data/lib/xero_ap_is/models/phone_type.rb +48 -0
- data/lib/xero_ap_is/models/prepayment.rb +309 -0
- data/lib/xero_ap_is/models/prepayments.rb +113 -0
- data/lib/xero_ap_is/models/project.rb +328 -0
- data/lib/xero_ap_is/models/project_create_or_update.rb +115 -0
- data/lib/xero_ap_is/models/project_patch.rb +73 -0
- data/lib/xero_ap_is/models/project_status.rb +36 -0
- data/lib/xero_ap_is/models/project_user.rb +95 -0
- data/lib/xero_ap_is/models/project_users.rb +94 -0
- data/lib/xero_ap_is/models/projects.rb +94 -0
- data/lib/xero_ap_is/models/purchase.rb +112 -0
- data/lib/xero_ap_is/models/purchase_order.rb +408 -0
- data/lib/xero_ap_is/models/purchase_orders.rb +114 -0
- data/lib/xero_ap_is/models/purchases_default_line_amount_type.rb +42 -0
- data/lib/xero_ap_is/models/quote.rb +338 -0
- data/lib/xero_ap_is/models/quote_line_amount_types.rb +41 -0
- data/lib/xero_ap_is/models/quote_status_codes.rb +52 -0
- data/lib/xero_ap_is/models/quotes.rb +84 -0
- data/lib/xero_ap_is/models/receipt.rb +287 -0
- data/lib/xero_ap_is/models/receipts.rb +84 -0
- data/lib/xero_ap_is/models/refresh_token.rb +106 -0
- data/lib/xero_ap_is/models/repeating_invoice.rb +290 -0
- data/lib/xero_ap_is/models/repeating_invoices.rb +85 -0
- data/lib/xero_ap_is/models/report.rb +136 -0
- data/lib/xero_ap_is/models/report_attribute.rb +85 -0
- data/lib/xero_ap_is/models/report_cell.rb +94 -0
- data/lib/xero_ap_is/models/report_fields.rb +95 -0
- data/lib/xero_ap_is/models/report_row.rb +104 -0
- data/lib/xero_ap_is/models/report_rows.rb +123 -0
- data/lib/xero_ap_is/models/report_tax_type.rb +424 -0
- data/lib/xero_ap_is/models/report_type.rb +26 -0
- data/lib/xero_ap_is/models/report_with_row.rb +176 -0
- data/lib/xero_ap_is/models/report_with_rows.rb +84 -0
- data/lib/xero_ap_is/models/reports.rb +84 -0
- data/lib/xero_ap_is/models/request_empty.rb +75 -0
- data/lib/xero_ap_is/models/resource_validation_errors_element.rb +116 -0
- data/lib/xero_ap_is/models/row_type.rb +44 -0
- data/lib/xero_ap_is/models/sales_default_line_amount_type.rb +42 -0
- data/lib/xero_ap_is/models/sales_tax_basis.rb +60 -0
- data/lib/xero_ap_is/models/sales_tax_period.rb +88 -0
- data/lib/xero_ap_is/models/sales_tracking_category.rb +89 -0
- data/lib/xero_ap_is/models/schedule.rb +140 -0
- data/lib/xero_ap_is/models/setting.rb +175 -0
- data/lib/xero_ap_is/models/setup.rb +117 -0
- data/lib/xero_ap_is/models/sort_direction.rb +36 -0
- data/lib/xero_ap_is/models/source_transaction_type_code.rb +38 -0
- data/lib/xero_ap_is/models/source_type.rb +128 -0
- data/lib/xero_ap_is/models/start_balance.rb +88 -0
- data/lib/xero_ap_is/models/statement.rb +194 -0
- data/lib/xero_ap_is/models/statement_line.rb +162 -0
- data/lib/xero_ap_is/models/statements.rb +94 -0
- data/lib/xero_ap_is/models/status.rb +41 -0
- data/lib/xero_ap_is/models/status1.rb +38 -0
- data/lib/xero_ap_is/models/status10.rb +40 -0
- data/lib/xero_ap_is/models/status11.rb +44 -0
- data/lib/xero_ap_is/models/status110.rb +40 -0
- data/lib/xero_ap_is/models/status111.rb +43 -0
- data/lib/xero_ap_is/models/status12.rb +48 -0
- data/lib/xero_ap_is/models/status13.rb +48 -0
- data/lib/xero_ap_is/models/status14.rb +52 -0
- data/lib/xero_ap_is/models/status15.rb +48 -0
- data/lib/xero_ap_is/models/status16.rb +36 -0
- data/lib/xero_ap_is/models/status17.rb +48 -0
- data/lib/xero_ap_is/models/status18.rb +40 -0
- data/lib/xero_ap_is/models/status19.rb +44 -0
- data/lib/xero_ap_is/models/status2.rb +40 -0
- data/lib/xero_ap_is/models/status20.rb +48 -0
- data/lib/xero_ap_is/models/status21.rb +36 -0
- data/lib/xero_ap_is/models/status22.rb +44 -0
- data/lib/xero_ap_is/models/status3.rb +52 -0
- data/lib/xero_ap_is/models/status4.rb +40 -0
- data/lib/xero_ap_is/models/status5.rb +40 -0
- data/lib/xero_ap_is/models/status6.rb +52 -0
- data/lib/xero_ap_is/models/status7.rb +36 -0
- data/lib/xero_ap_is/models/status8.rb +37 -0
- data/lib/xero_ap_is/models/status9.rb +40 -0
- data/lib/xero_ap_is/models/system_account.rb +110 -0
- data/lib/xero_ap_is/models/task.rb +234 -0
- data/lib/xero_ap_is/models/task_create_or_update.rb +105 -0
- data/lib/xero_ap_is/models/tasks.rb +94 -0
- data/lib/xero_ap_is/models/tax_breakdown_component.rb +172 -0
- data/lib/xero_ap_is/models/tax_component.rb +108 -0
- data/lib/xero_ap_is/models/tax_number_type.rb +45 -0
- data/lib/xero_ap_is/models/tax_rate.rb +213 -0
- data/lib/xero_ap_is/models/tax_rates.rb +85 -0
- data/lib/xero_ap_is/models/tax_type.rb +520 -0
- data/lib/xero_ap_is/models/taxability.rb +48 -0
- data/lib/xero_ap_is/models/ten_ninety_nine_contact.rb +318 -0
- data/lib/xero_ap_is/models/time_entries.rb +94 -0
- data/lib/xero_ap_is/models/time_entry.rb +179 -0
- data/lib/xero_ap_is/models/time_entry_create_or_update.rb +120 -0
- data/lib/xero_ap_is/models/time_zone.rb +592 -0
- data/lib/xero_ap_is/models/timeframe.rb +40 -0
- data/lib/xero_ap_is/models/tracking_categories.rb +85 -0
- data/lib/xero_ap_is/models/tracking_category.rb +140 -0
- data/lib/xero_ap_is/models/tracking_option.rb +109 -0
- data/lib/xero_ap_is/models/tracking_options.rb +84 -0
- data/lib/xero_ap_is/models/type.rb +60 -0
- data/lib/xero_ap_is/models/type1.rb +26 -0
- data/lib/xero_ap_is/models/type10.rb +36 -0
- data/lib/xero_ap_is/models/type11.rb +114 -0
- data/lib/xero_ap_is/models/type2.rb +48 -0
- data/lib/xero_ap_is/models/type3.rb +60 -0
- data/lib/xero_ap_is/models/type4.rb +44 -0
- data/lib/xero_ap_is/models/type5.rb +40 -0
- data/lib/xero_ap_is/models/type6.rb +36 -0
- data/lib/xero_ap_is/models/type7.rb +37 -0
- data/lib/xero_ap_is/models/type8.rb +36 -0
- data/lib/xero_ap_is/models/type9.rb +26 -0
- data/lib/xero_ap_is/models/unit.rb +36 -0
- data/lib/xero_ap_is/models/user.rb +139 -0
- data/lib/xero_ap_is/models/users.rb +84 -0
- data/lib/xero_ap_is/models/validation_error.rb +75 -0
- data/lib/xero_ap_is/models/version.rb +68 -0
- data/lib/xero_ap_is/utilities/date_time_helper.rb +11 -0
- data/lib/xero_ap_is/utilities/file_wrapper.rb +28 -0
- data/lib/xero_ap_is.rb +309 -0
- metadata +372 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# xero_ap_is client class.
|
|
8
|
+
class Client
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
attr_reader :config, :auth_managers
|
|
11
|
+
|
|
12
|
+
def user_agent_detail
|
|
13
|
+
config.user_agent_detail
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the configured authentication OAuth2 instance.
|
|
17
|
+
def oauth_2
|
|
18
|
+
@auth_managers['OAuth2']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Access to accounting controller.
|
|
22
|
+
# @return [AccountingApi] Returns the controller instance.
|
|
23
|
+
def accounting
|
|
24
|
+
@accounting ||= AccountingApi.new @global_configuration
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Access to asset controller.
|
|
28
|
+
# @return [AssetApi] Returns the controller instance.
|
|
29
|
+
def asset
|
|
30
|
+
@asset ||= AssetApi.new @global_configuration
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Access to bank_feeds controller.
|
|
34
|
+
# @return [BankFeedsApi] Returns the controller instance.
|
|
35
|
+
def bank_feeds
|
|
36
|
+
@bank_feeds ||= BankFeedsApi.new @global_configuration
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Access to identity controller.
|
|
40
|
+
# @return [IdentityApi] Returns the controller instance.
|
|
41
|
+
def identity
|
|
42
|
+
@identity ||= IdentityApi.new @global_configuration
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Access to project controller.
|
|
46
|
+
# @return [ProjectApi] Returns the controller instance.
|
|
47
|
+
def project
|
|
48
|
+
@project ||= ProjectApi.new @global_configuration
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Access to oauth_authorization controller.
|
|
52
|
+
# @return [OauthAuthorizationApi] Returns the controller instance.
|
|
53
|
+
def oauth_authorization
|
|
54
|
+
@oauth_authorization ||= OauthAuthorizationApi.new @global_configuration
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def initialize(
|
|
58
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
|
59
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
60
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
61
|
+
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
|
62
|
+
logging_configuration: nil, environment: Environment::PRODUCTION,
|
|
63
|
+
oauth_2_credentials: nil, basic_auth_credentials: nil, config: nil
|
|
64
|
+
)
|
|
65
|
+
@config = if config.nil?
|
|
66
|
+
Configuration.new(
|
|
67
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
|
68
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
69
|
+
backoff_factor: backoff_factor,
|
|
70
|
+
retry_statuses: retry_statuses,
|
|
71
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
72
|
+
proxy_settings: proxy_settings,
|
|
73
|
+
logging_configuration: logging_configuration,
|
|
74
|
+
environment: environment,
|
|
75
|
+
oauth_2_credentials: oauth_2_credentials,
|
|
76
|
+
basic_auth_credentials: basic_auth_credentials
|
|
77
|
+
)
|
|
78
|
+
else
|
|
79
|
+
config
|
|
80
|
+
end
|
|
81
|
+
user_agent_params = BaseApi.user_agent_parameters
|
|
82
|
+
|
|
83
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
|
84
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
|
85
|
+
.global_errors(BaseApi::GLOBAL_ERRORS)
|
|
86
|
+
.user_agent(BaseApi.user_agent,
|
|
87
|
+
agent_parameters: user_agent_params)
|
|
88
|
+
|
|
89
|
+
initialize_auth_managers(@global_configuration)
|
|
90
|
+
@global_configuration = @global_configuration.auth_managers(@auth_managers)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Initializes the auth managers hash used for authenticating API calls.
|
|
94
|
+
# @param [GlobalConfiguration] global_config The global configuration of the SDK)
|
|
95
|
+
def initialize_auth_managers(global_config)
|
|
96
|
+
@auth_managers = {}
|
|
97
|
+
http_client_config = global_config.client_configuration
|
|
98
|
+
%w[OAuth2 BasicAuth].each { |auth| @auth_managers[auth] = nil }
|
|
99
|
+
@auth_managers['OAuth2'] = Oauth2.new(http_client_config.oauth_2_credentials, global_config)
|
|
100
|
+
@auth_managers['BasicAuth'] = BasicAuth.new(http_client_config.basic_auth_credentials)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Creates a client directly from environment variables.
|
|
104
|
+
def self.from_env(**overrides)
|
|
105
|
+
default_config = Configuration.build_default_config_from_env
|
|
106
|
+
new_config = default_config.clone_with(**overrides)
|
|
107
|
+
new(config: new_config)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# An enum for SDK environments.
|
|
8
|
+
class Environment
|
|
9
|
+
# PRODUCTION: The Xero Accounting API exposes accounting and related functions of the main Xero application and can be used for a variety of purposes such as creating transactions like invoices and credit notes, right through to extracting accounting data via our reports endpoint., Xero API servers, Xero Bank Feeds API base url, Xero Identity service API, Xero API server for projects
|
|
10
|
+
ENVIRONMENT = [
|
|
11
|
+
PRODUCTION = 'production'.freeze
|
|
12
|
+
].freeze
|
|
13
|
+
|
|
14
|
+
# Converts a string or symbol into a valid Environment constant.
|
|
15
|
+
def self.from_value(value, default_value = PRODUCTION)
|
|
16
|
+
return default_value if value.nil?
|
|
17
|
+
|
|
18
|
+
default_value
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# An enum for API servers.
|
|
23
|
+
class Server
|
|
24
|
+
SERVER = [
|
|
25
|
+
DEFAULT = 'default'.freeze,
|
|
26
|
+
AUTH_SERVER = 'auth server'.freeze,
|
|
27
|
+
ACCESS_TOKEN_SERVER = 'access token server'.freeze,
|
|
28
|
+
DEFAULT1 = 'default1'.freeze,
|
|
29
|
+
DEFAULT2 = 'default2'.freeze,
|
|
30
|
+
DEFAULT3 = 'default3'.freeze,
|
|
31
|
+
DEFAULT4 = 'default4'.freeze
|
|
32
|
+
].freeze
|
|
33
|
+
|
|
34
|
+
# Converts a string or symbol into a valid Server constant.
|
|
35
|
+
def self.from_value(value, default_value = DEFAULT)
|
|
36
|
+
return default_value if value.nil?
|
|
37
|
+
|
|
38
|
+
str = value.to_s.strip.downcase
|
|
39
|
+
case str
|
|
40
|
+
when 'default' then DEFAULT
|
|
41
|
+
when 'auth_server' then AUTH_SERVER
|
|
42
|
+
when 'access_token_server' then ACCESS_TOKEN_SERVER
|
|
43
|
+
when 'default1' then DEFAULT1
|
|
44
|
+
when 'default2' then DEFAULT2
|
|
45
|
+
when 'default3' then DEFAULT3
|
|
46
|
+
when 'default4' then DEFAULT4
|
|
47
|
+
|
|
48
|
+
else
|
|
49
|
+
warn "[Server] Unknown server '#{value}', falling back to #{default_value} "
|
|
50
|
+
default_value
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# All configuration including auth info and base URI for the API access
|
|
56
|
+
# are configured in this class.
|
|
57
|
+
class Configuration < CoreLibrary::HttpClientConfiguration
|
|
58
|
+
# The attribute readers for properties.
|
|
59
|
+
attr_reader :environment, :oauth_2_credentials, :basic_auth_credentials
|
|
60
|
+
|
|
61
|
+
class << self
|
|
62
|
+
attr_reader :environments
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def initialize(
|
|
66
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
|
67
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
68
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
69
|
+
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
|
70
|
+
logging_configuration: nil, environment: Environment::PRODUCTION,
|
|
71
|
+
oauth_2_credentials: nil, basic_auth_credentials: nil
|
|
72
|
+
)
|
|
73
|
+
super connection: connection, adapter: adapter, timeout: timeout,
|
|
74
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
75
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
|
76
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
77
|
+
proxy_settings: proxy_settings,
|
|
78
|
+
logging_configuration: logging_configuration
|
|
79
|
+
|
|
80
|
+
# Current API environment
|
|
81
|
+
@environment = String(environment)
|
|
82
|
+
|
|
83
|
+
# The object holding OAuth 2 Authorization Code Grant credentials
|
|
84
|
+
@oauth_2_credentials = oauth_2_credentials
|
|
85
|
+
|
|
86
|
+
# The object holding Basic Authentication credentials
|
|
87
|
+
@basic_auth_credentials = basic_auth_credentials
|
|
88
|
+
|
|
89
|
+
# The Http Client to use for making requests.
|
|
90
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
|
94
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
|
95
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
|
96
|
+
proxy_settings: nil, logging_configuration: nil,
|
|
97
|
+
environment: nil, oauth_2_credentials: nil,
|
|
98
|
+
basic_auth_credentials: nil)
|
|
99
|
+
connection ||= self.connection
|
|
100
|
+
adapter ||= self.adapter
|
|
101
|
+
timeout ||= self.timeout
|
|
102
|
+
max_retries ||= self.max_retries
|
|
103
|
+
retry_interval ||= self.retry_interval
|
|
104
|
+
backoff_factor ||= self.backoff_factor
|
|
105
|
+
retry_statuses ||= self.retry_statuses
|
|
106
|
+
retry_methods ||= self.retry_methods
|
|
107
|
+
http_callback ||= self.http_callback
|
|
108
|
+
proxy_settings ||= self.proxy_settings
|
|
109
|
+
logging_configuration ||= self.logging_configuration
|
|
110
|
+
environment ||= self.environment
|
|
111
|
+
oauth_2_credentials ||= self.oauth_2_credentials
|
|
112
|
+
basic_auth_credentials ||= self.basic_auth_credentials
|
|
113
|
+
|
|
114
|
+
Configuration.new(connection: connection, adapter: adapter,
|
|
115
|
+
timeout: timeout, max_retries: max_retries,
|
|
116
|
+
retry_interval: retry_interval,
|
|
117
|
+
backoff_factor: backoff_factor,
|
|
118
|
+
retry_statuses: retry_statuses,
|
|
119
|
+
retry_methods: retry_methods,
|
|
120
|
+
http_callback: http_callback,
|
|
121
|
+
proxy_settings: proxy_settings,
|
|
122
|
+
logging_configuration: logging_configuration,
|
|
123
|
+
environment: environment,
|
|
124
|
+
oauth_2_credentials: oauth_2_credentials,
|
|
125
|
+
basic_auth_credentials: basic_auth_credentials)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# All the environments the SDK can run in.
|
|
130
|
+
ENVIRONMENTS = {
|
|
131
|
+
Environment::PRODUCTION => {
|
|
132
|
+
Server::DEFAULT => 'https://api.xero.com/api.xro/2.0',
|
|
133
|
+
Server::AUTH_SERVER => 'https://login.xero.com/identity/connect',
|
|
134
|
+
Server::ACCESS_TOKEN_SERVER => 'https://identity.xero.com/connect',
|
|
135
|
+
Server::DEFAULT1 => 'https://api.xero.com/assets.xro/1.0',
|
|
136
|
+
Server::DEFAULT2 => 'https://api.xero.com/bankfeeds.xro/1.0',
|
|
137
|
+
Server::DEFAULT3 => 'https://api.xero.com',
|
|
138
|
+
Server::DEFAULT4 => 'https://api.xero.com/projects.xro/2.0'
|
|
139
|
+
}
|
|
140
|
+
}.freeze
|
|
141
|
+
|
|
142
|
+
# Generates the appropriate base URI for the environment and the server.
|
|
143
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
|
144
|
+
# required.
|
|
145
|
+
# @return [String] The base URI.
|
|
146
|
+
def get_base_uri(server = Server::DEFAULT)
|
|
147
|
+
ENVIRONMENTS[environment][server].clone
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Builds a Configuration instance using environment variables.
|
|
151
|
+
def self.build_default_config_from_env
|
|
152
|
+
# === Core environment ===
|
|
153
|
+
environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
|
|
154
|
+
timeout = (ENV['TIMEOUT'] || 30).to_f
|
|
155
|
+
max_retries = (ENV['MAX_RETRIES'] || 0).to_i
|
|
156
|
+
retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
|
|
157
|
+
backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
|
|
158
|
+
retry_statuses = ENV.fetch('RETRY_STATUSES',
|
|
159
|
+
'[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
|
|
160
|
+
.split(',')
|
|
161
|
+
.map(&:strip)
|
|
162
|
+
.map do |item|
|
|
163
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
164
|
+
end
|
|
165
|
+
retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
|
|
166
|
+
.split(',')
|
|
167
|
+
.map(&:strip)
|
|
168
|
+
.map do |item|
|
|
169
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# === Authentication credentials ===
|
|
173
|
+
oauth_2_credentials = Oauth2Credentials.from_env
|
|
174
|
+
basic_auth_credentials = BasicAuthCredentials.from_env
|
|
175
|
+
|
|
176
|
+
# === Proxy settings ===
|
|
177
|
+
proxy_settings = ProxySettings.from_env
|
|
178
|
+
# === Logging Configuration ===
|
|
179
|
+
logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
|
|
180
|
+
|
|
181
|
+
Configuration.new(
|
|
182
|
+
environment: environment,
|
|
183
|
+
timeout: timeout,
|
|
184
|
+
max_retries: max_retries,
|
|
185
|
+
retry_interval: retry_interval,
|
|
186
|
+
backoff_factor: backoff_factor,
|
|
187
|
+
retry_statuses: retry_statuses,
|
|
188
|
+
retry_methods: retry_methods,
|
|
189
|
+
oauth_2_credentials: oauth_2_credentials,
|
|
190
|
+
basic_auth_credentials: basic_auth_credentials,
|
|
191
|
+
proxy_settings: proxy_settings,
|
|
192
|
+
logging_configuration: logging_configuration
|
|
193
|
+
)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
|
+
class APIException < CoreLibrary::ApiException
|
|
9
|
+
# Provides a human-readable string representation of the object.
|
|
10
|
+
def to_s
|
|
11
|
+
class_name = self.class.name.split('::').last
|
|
12
|
+
"<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
16
|
+
def inspect
|
|
17
|
+
class_name = self.class.name.split('::').last
|
|
18
|
+
"<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# AssetTypes 400 Error class.
|
|
8
|
+
class AssetTypes400ErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [Array[String]]
|
|
14
|
+
attr_accessor :resource_validation_errors
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for this method
|
|
17
|
+
# @return [Array[Object]]
|
|
18
|
+
attr_accessor :field_validation_errors
|
|
19
|
+
|
|
20
|
+
# TODO: Write general description for this method
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :type
|
|
23
|
+
|
|
24
|
+
# TODO: Write general description for this method
|
|
25
|
+
# @return [String]
|
|
26
|
+
attr_accessor :title
|
|
27
|
+
|
|
28
|
+
# TODO: Write general description for this method
|
|
29
|
+
# @return [String]
|
|
30
|
+
attr_accessor :detail
|
|
31
|
+
|
|
32
|
+
# The constructor.
|
|
33
|
+
# @param [String] reason The reason for raising an exception.
|
|
34
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
35
|
+
def initialize(reason, response)
|
|
36
|
+
super(reason, response)
|
|
37
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
38
|
+
unbox(hash)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Populates this object by extracting properties from a hash.
|
|
42
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
43
|
+
# response body.
|
|
44
|
+
def unbox(hash)
|
|
45
|
+
return nil unless hash
|
|
46
|
+
|
|
47
|
+
@resource_validation_errors =
|
|
48
|
+
hash.key?('resourceValidationErrors') ? hash['resourceValidationErrors'] : nil
|
|
49
|
+
@field_validation_errors =
|
|
50
|
+
hash.key?('fieldValidationErrors') ? hash['fieldValidationErrors'] : nil
|
|
51
|
+
@type = hash.key?('type') ? hash['type'] : nil
|
|
52
|
+
@title = hash.key?('title') ? hash['title'] : nil
|
|
53
|
+
@detail = hash.key?('detail') ? hash['detail'] : nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Provides a human-readable string representation of the object.
|
|
57
|
+
def to_s
|
|
58
|
+
class_name = self.class.name.split('::').last
|
|
59
|
+
"<#{class_name} resource_validation_errors: #{@resource_validation_errors},"\
|
|
60
|
+
" field_validation_errors: #{@field_validation_errors}, type: #{@type}, title: #{@title},"\
|
|
61
|
+
" detail: #{@detail}>"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
65
|
+
def inspect
|
|
66
|
+
class_name = self.class.name.split('::').last
|
|
67
|
+
"<#{class_name} resource_validation_errors: #{@resource_validation_errors.inspect},"\
|
|
68
|
+
" field_validation_errors: #{@field_validation_errors.inspect}, type: #{@type.inspect},"\
|
|
69
|
+
" title: #{@title.inspect}, detail: #{@detail.inspect}>"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# Assets 400 Error class.
|
|
8
|
+
class Assets400ErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [Array[String]]
|
|
14
|
+
attr_accessor :resource_validation_errors
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for this method
|
|
17
|
+
# @return [Array[Object]]
|
|
18
|
+
attr_accessor :field_validation_errors
|
|
19
|
+
|
|
20
|
+
# TODO: Write general description for this method
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :type
|
|
23
|
+
|
|
24
|
+
# TODO: Write general description for this method
|
|
25
|
+
# @return [String]
|
|
26
|
+
attr_accessor :title
|
|
27
|
+
|
|
28
|
+
# TODO: Write general description for this method
|
|
29
|
+
# @return [String]
|
|
30
|
+
attr_accessor :detail
|
|
31
|
+
|
|
32
|
+
# The constructor.
|
|
33
|
+
# @param [String] reason The reason for raising an exception.
|
|
34
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
35
|
+
def initialize(reason, response)
|
|
36
|
+
super(reason, response)
|
|
37
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
38
|
+
unbox(hash)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Populates this object by extracting properties from a hash.
|
|
42
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
43
|
+
# response body.
|
|
44
|
+
def unbox(hash)
|
|
45
|
+
return nil unless hash
|
|
46
|
+
|
|
47
|
+
@resource_validation_errors =
|
|
48
|
+
hash.key?('resourceValidationErrors') ? hash['resourceValidationErrors'] : nil
|
|
49
|
+
@field_validation_errors =
|
|
50
|
+
hash.key?('fieldValidationErrors') ? hash['fieldValidationErrors'] : nil
|
|
51
|
+
@type = hash.key?('type') ? hash['type'] : nil
|
|
52
|
+
@title = hash.key?('title') ? hash['title'] : nil
|
|
53
|
+
@detail = hash.key?('detail') ? hash['detail'] : nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Provides a human-readable string representation of the object.
|
|
57
|
+
def to_s
|
|
58
|
+
class_name = self.class.name.split('::').last
|
|
59
|
+
"<#{class_name} resource_validation_errors: #{@resource_validation_errors},"\
|
|
60
|
+
" field_validation_errors: #{@field_validation_errors}, type: #{@type}, title: #{@title},"\
|
|
61
|
+
" detail: #{@detail}>"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
65
|
+
def inspect
|
|
66
|
+
class_name = self.class.name.split('::').last
|
|
67
|
+
"<#{class_name} resource_validation_errors: #{@resource_validation_errors.inspect},"\
|
|
68
|
+
" field_validation_errors: #{@field_validation_errors.inspect}, type: #{@type.inspect},"\
|
|
69
|
+
" title: #{@title.inspect}, detail: #{@detail.inspect}>"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# On error, the API consumer will receive an HTTP response with a HTTP Status
|
|
8
|
+
# Code of 4xx or 5xx and a Content-Type of application/problem+json.
|
|
9
|
+
class ErrorError1Exception < APIException
|
|
10
|
+
SKIP = Object.new
|
|
11
|
+
private_constant :SKIP
|
|
12
|
+
|
|
13
|
+
# Human readable high level error description.
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :title
|
|
16
|
+
|
|
17
|
+
# The numeric HTTP Status Code, e.g. 404
|
|
18
|
+
# @return [Integer]
|
|
19
|
+
attr_accessor :status
|
|
20
|
+
|
|
21
|
+
# Human readable detailed error description.
|
|
22
|
+
# @return [String]
|
|
23
|
+
attr_accessor :detail
|
|
24
|
+
|
|
25
|
+
# Identifies the type of error.
|
|
26
|
+
# @return [Type11]
|
|
27
|
+
attr_accessor :type
|
|
28
|
+
|
|
29
|
+
# The constructor.
|
|
30
|
+
# @param [String] reason The reason for raising an exception.
|
|
31
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
32
|
+
def initialize(reason, response)
|
|
33
|
+
super(reason, response)
|
|
34
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
35
|
+
unbox(hash)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Populates this object by extracting properties from a hash.
|
|
39
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
40
|
+
# response body.
|
|
41
|
+
def unbox(hash)
|
|
42
|
+
return nil unless hash
|
|
43
|
+
|
|
44
|
+
@title = hash.key?('title') ? hash['title'] : SKIP
|
|
45
|
+
@status = hash.key?('status') ? hash['status'] : SKIP
|
|
46
|
+
@detail = hash.key?('detail') ? hash['detail'] : SKIP
|
|
47
|
+
@type = hash.key?('type') ? hash['type'] : SKIP
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Provides a human-readable string representation of the object.
|
|
51
|
+
def to_s
|
|
52
|
+
class_name = self.class.name.split('::').last
|
|
53
|
+
"<#{class_name} title: #{@title}, status: #{@status}, detail: #{@detail}, type: #{@type}>"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
57
|
+
def inspect
|
|
58
|
+
class_name = self.class.name.split('::').last
|
|
59
|
+
"<#{class_name} title: #{@title.inspect}, status: #{@status.inspect}, detail:"\
|
|
60
|
+
" #{@detail.inspect}, type: #{@type.inspect}>"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# Error_Error2 class.
|
|
8
|
+
class ErrorError2Exception < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Exception message
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :message
|
|
15
|
+
|
|
16
|
+
# Array of Elements of validation Errors
|
|
17
|
+
# @return [Object]
|
|
18
|
+
attr_accessor :model_state
|
|
19
|
+
|
|
20
|
+
# The constructor.
|
|
21
|
+
# @param [String] reason The reason for raising an exception.
|
|
22
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
23
|
+
def initialize(reason, response)
|
|
24
|
+
super(reason, response)
|
|
25
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
26
|
+
unbox(hash)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Populates this object by extracting properties from a hash.
|
|
30
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
31
|
+
# response body.
|
|
32
|
+
def unbox(hash)
|
|
33
|
+
return nil unless hash
|
|
34
|
+
|
|
35
|
+
@message = hash.key?('message') ? hash['message'] : SKIP
|
|
36
|
+
@model_state = hash.key?('modelState') ? hash['modelState'] : SKIP
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Provides a human-readable string representation of the object.
|
|
40
|
+
def to_s
|
|
41
|
+
class_name = self.class.name.split('::').last
|
|
42
|
+
"<#{class_name} message: #{@message}, model_state: #{@model_state}>"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
46
|
+
def inspect
|
|
47
|
+
class_name = self.class.name.split('::').last
|
|
48
|
+
"<#{class_name} message: #{@message.inspect}, model_state: #{@model_state.inspect}>"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# xero_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module XeroApIs
|
|
7
|
+
# Error class.
|
|
8
|
+
class ErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Exception number
|
|
13
|
+
# @return [Integer]
|
|
14
|
+
attr_accessor :error_number
|
|
15
|
+
|
|
16
|
+
# Exception type
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :type
|
|
19
|
+
|
|
20
|
+
# Exception message
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :message
|
|
23
|
+
|
|
24
|
+
# Array of Elements of validation Errors
|
|
25
|
+
# @return [Array[Element]]
|
|
26
|
+
attr_accessor :elements
|
|
27
|
+
|
|
28
|
+
# The constructor.
|
|
29
|
+
# @param [String] reason The reason for raising an exception.
|
|
30
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
31
|
+
def initialize(reason, response)
|
|
32
|
+
super(reason, response)
|
|
33
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
34
|
+
unbox(hash)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Populates this object by extracting properties from a hash.
|
|
38
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
39
|
+
# response body.
|
|
40
|
+
def unbox(hash)
|
|
41
|
+
return nil unless hash
|
|
42
|
+
|
|
43
|
+
@error_number = hash.key?('ErrorNumber') ? hash['ErrorNumber'] : SKIP
|
|
44
|
+
@type = hash.key?('Type') ? hash['Type'] : SKIP
|
|
45
|
+
@message = hash.key?('Message') ? hash['Message'] : SKIP
|
|
46
|
+
# Parameter is an array, so we need to iterate through it
|
|
47
|
+
@elements = nil
|
|
48
|
+
unless hash['Elements'].nil?
|
|
49
|
+
@elements = []
|
|
50
|
+
hash['Elements'].each do |structure|
|
|
51
|
+
@elements << (Element.from_hash(structure) if structure)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
@elements = SKIP unless hash.key?('Elements')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Provides a human-readable string representation of the object.
|
|
59
|
+
def to_s
|
|
60
|
+
class_name = self.class.name.split('::').last
|
|
61
|
+
"<#{class_name} error_number: #{@error_number}, type: #{@type}, message: #{@message},"\
|
|
62
|
+
" elements: #{@elements}>"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
66
|
+
def inspect
|
|
67
|
+
class_name = self.class.name.split('::').last
|
|
68
|
+
"<#{class_name} error_number: #{@error_number.inspect}, type: #{@type.inspect}, message:"\
|
|
69
|
+
" #{@message.inspect}, elements: #{@elements.inspect}>"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|