xero-ruby 2.9.0 → 3.0.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 +133 -97
- data/lib/xero-ruby/api/accounting_api.rb +6 -0
- data/lib/xero-ruby/api_client.rb +96 -16
- data/lib/xero-ruby/configuration.rb +14 -1
- data/lib/xero-ruby/models/accounting/account.rb +11 -7
- data/lib/xero-ruby/models/accounting/accounts.rb +11 -7
- data/lib/xero-ruby/models/accounting/accounts_payable.rb +11 -7
- data/lib/xero-ruby/models/accounting/accounts_receivable.rb +11 -7
- data/lib/xero-ruby/models/accounting/action.rb +11 -7
- data/lib/xero-ruby/models/accounting/actions.rb +11 -7
- data/lib/xero-ruby/models/accounting/address.rb +11 -7
- data/lib/xero-ruby/models/accounting/address_for_organisation.rb +11 -7
- data/lib/xero-ruby/models/accounting/allocation.rb +11 -7
- data/lib/xero-ruby/models/accounting/allocations.rb +11 -7
- data/lib/xero-ruby/models/accounting/attachment.rb +11 -7
- data/lib/xero-ruby/models/accounting/attachments.rb +11 -7
- data/lib/xero-ruby/models/accounting/balance_details.rb +11 -7
- data/lib/xero-ruby/models/accounting/balances.rb +11 -7
- data/lib/xero-ruby/models/accounting/bank_transaction.rb +11 -7
- data/lib/xero-ruby/models/accounting/bank_transactions.rb +11 -7
- data/lib/xero-ruby/models/accounting/bank_transfer.rb +11 -7
- data/lib/xero-ruby/models/accounting/bank_transfers.rb +11 -7
- data/lib/xero-ruby/models/accounting/batch_payment.rb +11 -7
- data/lib/xero-ruby/models/accounting/batch_payment_details.rb +11 -7
- data/lib/xero-ruby/models/accounting/batch_payments.rb +11 -7
- data/lib/xero-ruby/models/accounting/bill.rb +11 -7
- data/lib/xero-ruby/models/accounting/branding_theme.rb +11 -7
- data/lib/xero-ruby/models/accounting/branding_themes.rb +11 -7
- data/lib/xero-ruby/models/accounting/cis_org_setting.rb +11 -7
- data/lib/xero-ruby/models/accounting/cis_org_settings.rb +11 -7
- data/lib/xero-ruby/models/accounting/cis_setting.rb +11 -7
- data/lib/xero-ruby/models/accounting/cis_settings.rb +11 -7
- data/lib/xero-ruby/models/accounting/contact.rb +11 -7
- data/lib/xero-ruby/models/accounting/contact_group.rb +11 -7
- data/lib/xero-ruby/models/accounting/contact_groups.rb +11 -7
- data/lib/xero-ruby/models/accounting/contact_person.rb +11 -7
- data/lib/xero-ruby/models/accounting/contacts.rb +11 -7
- data/lib/xero-ruby/models/accounting/conversion_balances.rb +11 -7
- data/lib/xero-ruby/models/accounting/conversion_date.rb +11 -7
- data/lib/xero-ruby/models/accounting/credit_note.rb +11 -7
- data/lib/xero-ruby/models/accounting/credit_notes.rb +11 -7
- data/lib/xero-ruby/models/accounting/currencies.rb +11 -7
- data/lib/xero-ruby/models/accounting/currency.rb +11 -7
- data/lib/xero-ruby/models/accounting/element.rb +11 -7
- data/lib/xero-ruby/models/accounting/employee.rb +11 -7
- data/lib/xero-ruby/models/accounting/employees.rb +11 -7
- data/lib/xero-ruby/models/accounting/error.rb +11 -7
- data/lib/xero-ruby/models/accounting/expense_claim.rb +11 -7
- data/lib/xero-ruby/models/accounting/expense_claims.rb +11 -7
- data/lib/xero-ruby/models/accounting/external_link.rb +11 -7
- data/lib/xero-ruby/models/accounting/history_record.rb +11 -7
- data/lib/xero-ruby/models/accounting/history_records.rb +11 -7
- data/lib/xero-ruby/models/accounting/import_summary.rb +11 -7
- data/lib/xero-ruby/models/accounting/import_summary_accounts.rb +11 -7
- data/lib/xero-ruby/models/accounting/import_summary_object.rb +11 -7
- data/lib/xero-ruby/models/accounting/import_summary_organisation.rb +11 -7
- data/lib/xero-ruby/models/accounting/invoice.rb +11 -7
- data/lib/xero-ruby/models/accounting/invoice_reminder.rb +11 -7
- data/lib/xero-ruby/models/accounting/invoice_reminders.rb +11 -7
- data/lib/xero-ruby/models/accounting/invoices.rb +11 -7
- data/lib/xero-ruby/models/accounting/item.rb +11 -7
- data/lib/xero-ruby/models/accounting/items.rb +11 -7
- data/lib/xero-ruby/models/accounting/journal.rb +11 -7
- data/lib/xero-ruby/models/accounting/journal_line.rb +11 -7
- data/lib/xero-ruby/models/accounting/journals.rb +11 -7
- data/lib/xero-ruby/models/accounting/line_item.rb +11 -7
- data/lib/xero-ruby/models/accounting/line_item_tracking.rb +11 -7
- data/lib/xero-ruby/models/accounting/linked_transaction.rb +11 -7
- data/lib/xero-ruby/models/accounting/linked_transactions.rb +11 -7
- data/lib/xero-ruby/models/accounting/manual_journal.rb +11 -7
- data/lib/xero-ruby/models/accounting/manual_journal_line.rb +11 -7
- data/lib/xero-ruby/models/accounting/manual_journals.rb +11 -7
- data/lib/xero-ruby/models/accounting/online_invoice.rb +11 -7
- data/lib/xero-ruby/models/accounting/online_invoices.rb +11 -7
- data/lib/xero-ruby/models/accounting/organisation.rb +11 -7
- data/lib/xero-ruby/models/accounting/organisations.rb +11 -7
- data/lib/xero-ruby/models/accounting/overpayment.rb +11 -7
- data/lib/xero-ruby/models/accounting/overpayments.rb +11 -7
- data/lib/xero-ruby/models/accounting/payment.rb +11 -7
- data/lib/xero-ruby/models/accounting/payment_delete.rb +11 -7
- data/lib/xero-ruby/models/accounting/payment_service.rb +11 -7
- data/lib/xero-ruby/models/accounting/payment_services.rb +11 -7
- data/lib/xero-ruby/models/accounting/payment_term.rb +11 -7
- data/lib/xero-ruby/models/accounting/payments.rb +11 -7
- data/lib/xero-ruby/models/accounting/phone.rb +11 -7
- data/lib/xero-ruby/models/accounting/prepayment.rb +24 -8
- data/lib/xero-ruby/models/accounting/prepayments.rb +11 -7
- data/lib/xero-ruby/models/accounting/purchase.rb +11 -7
- data/lib/xero-ruby/models/accounting/purchase_order.rb +11 -7
- data/lib/xero-ruby/models/accounting/purchase_orders.rb +11 -7
- data/lib/xero-ruby/models/accounting/quote.rb +11 -7
- data/lib/xero-ruby/models/accounting/quotes.rb +11 -7
- data/lib/xero-ruby/models/accounting/receipt.rb +11 -7
- data/lib/xero-ruby/models/accounting/receipts.rb +11 -7
- data/lib/xero-ruby/models/accounting/repeating_invoice.rb +11 -7
- data/lib/xero-ruby/models/accounting/repeating_invoices.rb +11 -7
- data/lib/xero-ruby/models/accounting/report.rb +11 -7
- data/lib/xero-ruby/models/accounting/report_attribute.rb +11 -7
- data/lib/xero-ruby/models/accounting/report_cell.rb +11 -7
- data/lib/xero-ruby/models/accounting/report_fields.rb +11 -7
- data/lib/xero-ruby/models/accounting/report_row.rb +11 -7
- data/lib/xero-ruby/models/accounting/report_rows.rb +11 -7
- data/lib/xero-ruby/models/accounting/report_with_row.rb +11 -7
- data/lib/xero-ruby/models/accounting/report_with_rows.rb +11 -7
- data/lib/xero-ruby/models/accounting/reports.rb +11 -7
- data/lib/xero-ruby/models/accounting/request_empty.rb +11 -7
- data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +11 -7
- data/lib/xero-ruby/models/accounting/schedule.rb +11 -7
- data/lib/xero-ruby/models/accounting/setup.rb +11 -7
- data/lib/xero-ruby/models/accounting/tax_component.rb +11 -7
- data/lib/xero-ruby/models/accounting/tax_rate.rb +11 -7
- data/lib/xero-ruby/models/accounting/tax_rates.rb +11 -7
- data/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +11 -7
- data/lib/xero-ruby/models/accounting/tracking_categories.rb +11 -7
- data/lib/xero-ruby/models/accounting/tracking_category.rb +11 -7
- data/lib/xero-ruby/models/accounting/tracking_option.rb +11 -7
- data/lib/xero-ruby/models/accounting/tracking_options.rb +11 -7
- data/lib/xero-ruby/models/accounting/user.rb +11 -7
- data/lib/xero-ruby/models/accounting/users.rb +11 -7
- data/lib/xero-ruby/models/accounting/validation_error.rb +11 -7
- data/lib/xero-ruby/models/assets/asset.rb +11 -7
- data/lib/xero-ruby/models/assets/asset_type.rb +11 -7
- data/lib/xero-ruby/models/assets/assets.rb +11 -7
- data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +11 -7
- data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +11 -7
- data/lib/xero-ruby/models/assets/error.rb +11 -7
- data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +11 -7
- data/lib/xero-ruby/models/assets/pagination.rb +11 -7
- data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +11 -7
- data/lib/xero-ruby/models/assets/setting.rb +11 -7
- data/lib/xero-ruby/models/files/association.rb +11 -7
- data/lib/xero-ruby/models/files/file_object.rb +11 -7
- data/lib/xero-ruby/models/files/files.rb +11 -7
- data/lib/xero-ruby/models/files/folder.rb +11 -7
- data/lib/xero-ruby/models/files/folders.rb +11 -7
- data/lib/xero-ruby/models/files/upload_object.rb +11 -7
- data/lib/xero-ruby/models/files/user.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/account.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/api_exception.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/bank_account.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/deduction_line.rb +11 -12
- data/lib/xero-ruby/models/payroll_au/deduction_type.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/employee.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/employees.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/home_address.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_application.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_applications.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_balance.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_lines.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_period.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/leave_type.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/opening_balances.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/pay_item.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/pay_items.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/pay_run.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/pay_runs.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/pay_template.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/payroll_calendars.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/payslip.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/payslip_lines.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/payslip_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/payslip_summary.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/payslips.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/reimbursement_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/reimbursement_type.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/settings.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/settings_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/super_fund.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/super_fund_product.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/super_fund_products.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/super_funds.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/super_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/super_membership.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/superannuation_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/tax_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/timesheet.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/timesheet_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/timesheet_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/timesheets.rb +11 -7
- data/lib/xero-ruby/models/payroll_au/validation_error.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/account.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/accounts.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/address.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/bank_account.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/benefit.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/deduction.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/deduction_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/deduction_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/deductions.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_order.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_orders.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_rate.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_rates.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_template.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_leaves.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_tax.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employees.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employment.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/employment_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/invalid_field.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/leave_period.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/leave_periods.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/leave_type.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/leave_type_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/leave_types.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pagination.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_run.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_run_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_runs.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_slip.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/pay_slips.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/payment_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/payment_method.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/payment_method_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/problem.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/reimbursement.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/reimbursements.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/settings.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/superannuation_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/superannuation_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/superannuations.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/tax_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/tax_settings.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/timesheet.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/timesheet_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/timesheet_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/timesheets.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/tracking_categories.rb +11 -7
- data/lib/xero-ruby/models/payroll_nz/tracking_category.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/account.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/accounts.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/address.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/bank_account.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/benefit.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/benefit_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/benefit_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/benefits.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/court_order_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/deduction.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/deduction_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/deduction_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/deductions.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_order.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_orders.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_rates.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_template.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leave.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_leaves.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_tax.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employees.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employment.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/employment_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/invalid_field.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/leave_period.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/leave_periods.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/leave_type.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/leave_type_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/leave_types.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/pagination.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/pay_run.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/pay_run_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/pay_runs.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/payment_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/payment_method.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/payment_method_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/payslip.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/payslip_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/payslips.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/problem.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/reimbursement.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/reimbursements.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/settings.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/tax_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/timesheet.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/timesheet_line.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/timesheet_object.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/timesheets.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/tracking_categories.rb +11 -7
- data/lib/xero-ruby/models/payroll_uk/tracking_category.rb +11 -7
- data/lib/xero-ruby/models/projects/amount.rb +11 -7
- data/lib/xero-ruby/models/projects/error.rb +11 -7
- data/lib/xero-ruby/models/projects/pagination.rb +11 -7
- data/lib/xero-ruby/models/projects/project.rb +11 -7
- data/lib/xero-ruby/models/projects/project_create_or_update.rb +11 -7
- data/lib/xero-ruby/models/projects/project_patch.rb +11 -7
- data/lib/xero-ruby/models/projects/project_user.rb +11 -7
- data/lib/xero-ruby/models/projects/project_users.rb +11 -7
- data/lib/xero-ruby/models/projects/projects.rb +11 -7
- data/lib/xero-ruby/models/projects/task.rb +11 -7
- data/lib/xero-ruby/models/projects/task_create_or_update.rb +11 -7
- data/lib/xero-ruby/models/projects/tasks.rb +11 -7
- data/lib/xero-ruby/models/projects/time_entries.rb +11 -7
- data/lib/xero-ruby/models/projects/time_entry.rb +14 -9
- data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +11 -7
- data/lib/xero-ruby/version.rb +2 -2
- data/spec/api_client_spec.rb +160 -4
- data/spec/helper_methods_spec.rb +28 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 318fb48f176b7958600aff1846180a94028bcafd1802e7620622c5bfaa3598a9
|
4
|
+
data.tar.gz: 3d6cf058f85c0ab341932ae6ca4f838a6915a8fb2f75dcd45269cf9d5bbdeee0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06d8ad44f3611f0d4c403916ff8f67c456225d8dca591c9ef7a25062fbcd77c638f5ffd6c408d63a0dac5307d1ecc9d5e274bdc9c22b517273363dc6859f4517
|
7
|
+
data.tar.gz: 4556718e67afd15190357406cba150b83cb901bbbfd677752a12a10053dd400167d23b7fc373a6e1dd987c2fef5be9467ddfd8b2df944e3d6180ac79a737ae12
|
data/README.md
CHANGED
@@ -5,45 +5,36 @@ Xero Ruby SDK for OAuth 2.0 generated from [Xero API OpenAPI Spec](https://githu
|
|
5
5
|
|
6
6
|
# Documentation
|
7
7
|
Xero Ruby SDK supports Xero's OAuth2.0 authentication and the following Xero API sets.
|
8
|
-
|
9
|
-
## SDK Documentation
|
8
|
+
### API Client Documentation
|
10
9
|
* [API client methods](https://xeroapi.github.io/xero-ruby/accounting/index.html)
|
11
|
-
|
12
|
-
|
13
|
-
* [
|
14
|
-
|
15
|
-
* [Project Api Docs](docs/projects/)
|
16
|
-
* [Files Api Docs](docs/files/)
|
17
|
-
* [Payroll Docs (AU)](docs/payroll_au/)
|
18
|
-
* [Payroll Docs (NZ)](docs/payroll_nz/)
|
19
|
-
* [Payroll Docs (UK)](docs/payroll_uk/)
|
20
|
-
|
10
|
+
> This describes to ~200+ accounting API endpoints and their expected params. There are also method reference docs for the Assets, Files, Projects, and Payroll endpoints sets, though we are still working on accurately generating usable parameter examples for all! (feedback welcome)
|
11
|
+
### Model Docs
|
12
|
+
* [Models](/docs/)
|
13
|
+
> Directory of markdown files, describing the object models for the Accounting, Asset, Projects, Files, Payroll (AU, UK, NZ) Xero API sets.
|
21
14
|
## Sample Apps
|
22
|
-
We have two apps showing SDK usage
|
23
|
-
* https://github.com/XeroAPI/xero-ruby-oauth2-starter (**Sinatra** - session based
|
24
|
-
* https://github.com/XeroAPI/xero-ruby-oauth2-app (**Rails** - token management
|
15
|
+
We have two sample apps showing SDK usage:
|
16
|
+
* https://github.com/XeroAPI/xero-ruby-oauth2-starter (**Sinatra** - bare minimum to hello world and simple session based storage)
|
17
|
+
* https://github.com/XeroAPI/xero-ruby-oauth2-app (**Rails** - token management with robust usage examples)
|
25
18
|
|
26
19
|
![sample-app](https://i.imgur.com/OOEn55G.png)
|
27
20
|
|
28
|
-
|
21
|
+
## Xero Pre-Requisites
|
22
|
+
* Create a [free Xero user account](https://www.xero.com/us/signup/api/)
|
23
|
+
* Login to your Xero developer [/myapps](https://developer.xero.com/myapps) dashboard & create an API application
|
24
|
+
* Copy the credentials from your API app and store/access them using a secure ENV variable strategy
|
25
|
+
* Resaearch and include the [neccesary scopes](https://developer.xero.com/documentation/oauth2/scopes) for your app's functionality as a space-seperated list, ex. "`SCOPES="openid profile email accounting.transactions accounting.settings"`"
|
29
26
|
## Installation
|
30
|
-
To install this gem to your
|
27
|
+
To install this gem to your project:
|
31
28
|
```
|
32
29
|
gem install 'xero-ruby'
|
33
30
|
```
|
34
|
-
Or add to your gemfile and run `bundle install
|
31
|
+
Or more commonly in Ruby on Rails usage add to your gemfile and run `bundle install`:
|
35
32
|
```
|
36
33
|
gem 'xero-ruby'
|
37
34
|
```
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
* Login to your Xero developer [/myapps](https://developer.xero.com/myapps) dashboard & create an API application and note your API app's credentials.
|
42
|
-
|
43
|
-
### Creating a client
|
44
|
-
* Get the credential values from an API application at https://developer.xero.com/myapps/.
|
45
|
-
* Include [neccesary scopes](https://developer.xero.com/documentation/oauth2/scopes) as a space-seperated list
|
46
|
-
* example => "`openid profile email accounting.transactions accounting.settings`"
|
36
|
+
---
|
37
|
+
## Usage
|
47
38
|
```
|
48
39
|
require 'xero-ruby'
|
49
40
|
```
|
@@ -58,56 +49,77 @@ creds = {
|
|
58
49
|
xero_client ||= XeroRuby::ApiClient.new(credentials: creds)
|
59
50
|
```
|
60
51
|
|
61
|
-
|
52
|
+
For additional logging or timeout, add or override any [config](/lib/xero-ruby/configuration.rb) option by passing an optional named parameter `config: {..}`.
|
62
53
|
```ruby
|
63
54
|
config = { timeout: 30, debugging: true }
|
64
55
|
@xero_client ||= XeroRuby::ApiClient.new(credentials: creds, config: config)
|
65
56
|
```
|
66
57
|
|
67
|
-
##
|
68
|
-
All API requests require a valid access token to be set on the
|
58
|
+
## OAuth2.0 Authorization & Callback
|
59
|
+
All API requests require a valid access token to be set on the xero_client.
|
69
60
|
|
70
|
-
|
61
|
+
### Step 1
|
62
|
+
Send the user to the `authorization_url` after you have configured your xero_client
|
71
63
|
```ruby
|
72
64
|
@authorization_url = xero_client.authorization_url
|
73
65
|
|
74
66
|
redirect_to @authorization_url
|
75
67
|
```
|
76
68
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
69
|
+
### Step 2
|
70
|
+
On successful authorization, Xero identity will redirect to the URI defined in your `redirect_uri` config which must match **exactly** with the variable in your /myapps dashboard.
|
71
|
+
```
|
72
|
+
=> /oauth/redirect_uri
|
73
|
+
```
|
74
|
+
### Step 3
|
75
|
+
In your server defined callback route, exchange the temporary code for a valid `token_set` that will get set on your client.
|
82
76
|
```ruby
|
83
|
-
# => http://localhost:3000/oauth/callback
|
84
|
-
|
85
77
|
token_set = xero_client.get_token_set_from_callback(params)
|
78
|
+
```
|
79
|
+
At this point you should save the token_set as JSON in a datastore in relation to the authenticating user or entity.
|
86
80
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
81
|
+
The sample [Rails app](https://github.com/XeroAPI/xero-ruby-oauth2-app/blob/master/app/controllers/application_controller.rb#L11) shows a solid pattern you can tweak to fit your needs:
|
82
|
+
```ruby
|
83
|
+
# /oauth/redirect_uri -> 'application#callback'
|
84
|
+
def callback
|
85
|
+
@token_set = @xero_client.get_token_set_from_callback(params)
|
86
|
+
|
87
|
+
current_user.token_set = @token_set
|
88
|
+
current_user.token_set['connections'] = @xero_client.connections
|
89
|
+
current_user.active_tenant_id = latest_connection(current_user.token_set['connections'])
|
90
|
+
current_user.save!
|
91
|
+
flash.notice = "Successfully authenticated with Xero!"
|
92
|
+
end
|
91
93
|
```
|
94
|
+
---
|
95
|
+
### What is a Token Set?
|
96
|
+
A `token_set` is what we call the XeroAPI response that contains data about your API connection:
|
97
|
+
```json
|
98
|
+
{
|
99
|
+
"id_token": "xxx.yyy.zz", (if you requested `openid profile email` scope)
|
100
|
+
"access_token": "xxx.yyy.zzz",
|
101
|
+
"expires_in": 1800,
|
102
|
+
"token_type": "Bearer",
|
103
|
+
"refresh_token": "xxxxxx", (if you requested `offline_access` scope)
|
104
|
+
"scope": "email profile openid accounting.transactions offline_access"
|
105
|
+
}
|
106
|
+
```
|
107
|
+
|
108
|
+
Note that an `access_token` is valid for 30 minutes but a `refresh_token` can be used once in up to a 60 day window. If a refresh_token is used to refresh access you must replace the entire token_set.
|
92
109
|
|
93
|
-
|
94
|
-
|
110
|
+
Both the `id_token` & `access_token` are JWT's, and can be decoded to see additional metadata described in the Token Helpers section:
|
111
|
+
## Making API calls with a valid token_set
|
112
|
+
After the initial user interaction you can simply setup a xero_client by passing the whole token_set to the client.
|
95
113
|
```ruby
|
96
114
|
xero_client.set_token_set(user.token_set)
|
97
115
|
|
98
116
|
xero_client.refresh_token_set(user.token_set)
|
99
|
-
# this will set the access_token on the client, and return a refreshed `token_set` you need to save.
|
100
117
|
```
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
**An `access_token` is valid 30 minutes and a `refresh_token` is valid for 60 days**
|
107
|
-
|
108
|
-
Example Token set:
|
109
|
-
> You can decode the `id_token` & `access_token` for additional metadata by using a [decoding library](https://github.com/jwt/ruby-jwt):
|
110
|
-
```json
|
118
|
+
This sets the access_token on the client, and returns a refreshed `token_set` that you should save in your datastore for the next time you need to connect to Xero's API.
|
119
|
+
## Token Helpers
|
120
|
+
```ruby
|
121
|
+
xero_client.token_set
|
122
|
+
=>
|
111
123
|
{
|
112
124
|
"id_token": "xxx.yyy.zz",
|
113
125
|
"access_token": "xxx.yyy.zzz",
|
@@ -116,17 +128,63 @@ Example Token set:
|
|
116
128
|
"refresh_token": "xxxxxx",
|
117
129
|
"scope": "email profile openid accounting.transactions offline_access"
|
118
130
|
}
|
119
|
-
```
|
120
131
|
|
121
|
-
|
122
|
-
|
132
|
+
xero_client.access_token
|
133
|
+
=> "xxx.yyy.zzz"
|
134
|
+
|
135
|
+
xero_client.decoded_access_token
|
136
|
+
=> {
|
137
|
+
"exp": 1619715843,
|
138
|
+
"xero_userid": "xero-user-uuid",
|
139
|
+
"scope": [
|
140
|
+
"email",
|
141
|
+
"profile",
|
142
|
+
"openid",
|
143
|
+
"accounting.transactions",
|
144
|
+
"offline_access"
|
145
|
+
]
|
146
|
+
}
|
147
|
+
|
148
|
+
|
149
|
+
xero_client.id_token
|
150
|
+
=> "aaa.bbb.ccc"
|
151
|
+
|
152
|
+
xero_client.decoded_id_token
|
153
|
+
=> {
|
154
|
+
"iss": "https://identity.xero.com",
|
155
|
+
"email": "luca.pacioli@accounting-services.com",
|
156
|
+
"given_name": "Luca",
|
157
|
+
"family_name": "Pacioli"
|
158
|
+
}
|
159
|
+
|
160
|
+
xero_client.set_token_set(token_set)
|
161
|
+
=> true
|
162
|
+
|
163
|
+
xero_client.get_token_set_from_callback(callback_url_params)
|
164
|
+
=> new_xero_token_set
|
165
|
+
|
166
|
+
xero_client.refresh_token_set(token_set)
|
167
|
+
=> new_xero_token_set
|
168
|
+
|
169
|
+
# These are automatically populated with `set_token_set`
|
170
|
+
# But if you need to set just an access or id token on the client
|
171
|
+
xero_client.set_access_token(access_token)
|
172
|
+
xero_client.set_id_token(id_token)
|
173
|
+
|
174
|
+
# Automatically run on initial OAuth flow - can be called its own if desired
|
175
|
+
# Read about why we have included this in the default library: https://auth0.com/docs/tokens/access-tokens/validate-access-tokens
|
176
|
+
xero_client.validate_tokens(token_set)
|
177
|
+
xero_client.decode_jwt(tkn)
|
178
|
+
```
|
179
|
+
# Connection Helpers
|
123
180
|
```ruby
|
124
|
-
|
181
|
+
xero_client.authorization_url
|
182
|
+
=> # https://login.xero.com/identity/connect/authorize?response_type=code&client_id=<client_id>&redirect_uri=<redirect_uri>&scope=<scopes>&state=<my-state>
|
125
183
|
|
126
|
-
#
|
127
|
-
|
184
|
+
# To completely Revoke a user's access token and all their connections
|
185
|
+
xero_client.revoke_token(token_set)
|
128
186
|
|
129
|
-
#
|
187
|
+
# In case there are > 1 tenants connected the `updatedDateUtc` will show you the most recently authorized tenant (aka organisation) - it is important to store the `tenantId` of the Org your user specified in their API authorization
|
130
188
|
connections = xero_client.connections
|
131
189
|
[{
|
132
190
|
"id" => "xxx-yyy-zzz",
|
@@ -137,38 +195,19 @@ connections = xero_client.connections
|
|
137
195
|
"updatedDateUtc" => "2020-04-15T22:37:10.4943410"
|
138
196
|
}]
|
139
197
|
|
140
|
-
# To
|
141
|
-
#
|
142
|
-
|
143
|
-
xero_client.revoke_token(user.token_set)
|
144
|
-
|
145
|
-
# disconnect an org from a user's connections. Pass the connection ['id'] not ['tenantId'].
|
146
|
-
# Useful if you want to enforce only a single org connection per token.
|
198
|
+
# To disconnect a single org from a user's active connections pass the connection ['id'] (not ['tenantId'])
|
199
|
+
# If you want to enforce only a single org connection per token do this prior to sending user through Xero authorize flow a 2nd time.
|
147
200
|
remaining_connections = xero_client.disconnect(connections[0]['id'])
|
148
201
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
# access token_set once it is set on the client
|
153
|
-
token_set = xero_client.token_set
|
154
|
-
```
|
155
|
-
|
156
|
-
Example token expiry helper
|
157
|
-
```ruby
|
158
|
-
require 'jwt'
|
159
|
-
|
160
|
-
def token_expired?
|
161
|
-
token_expiry = Time.at(decoded_access_token['exp'])
|
162
|
-
token_expiry < Time.now
|
163
|
-
end
|
202
|
+
xero_client.token_expired?
|
203
|
+
=> true || false
|
164
204
|
|
165
|
-
|
166
|
-
|
167
|
-
|
205
|
+
# This will check against the following logic
|
206
|
+
token_expiry = Time.at(decoded_access_token['exp'])
|
207
|
+
token_expiry < Time.now
|
168
208
|
```
|
169
209
|
|
170
|
-
|
171
|
-
|
210
|
+
# API Usage
|
172
211
|
### Accounting API
|
173
212
|
> https://xeroapi.github.io/xero-ruby/accounting/index.html
|
174
213
|
```ruby
|
@@ -177,7 +216,7 @@ require 'xero-ruby'
|
|
177
216
|
xero_client.refresh_token_set(user.token_set)
|
178
217
|
|
179
218
|
tenant_id = user.active_tenant_id
|
180
|
-
#
|
219
|
+
# Example 'active tenant' logic storage of the tenant the user specified, xero_client.connections[0] is not a safe assumption in case they authorized multiple orgs.
|
181
220
|
|
182
221
|
# Get Accounts
|
183
222
|
accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts
|
@@ -186,10 +225,13 @@ accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts
|
|
186
225
|
invoices = { invoices: [{ type: XeroRuby::Accounting::Invoice::ACCREC, contact: { contact_id: contacts[0].contact_id }, line_items: [{ description: "Big Agency", quantity: BigDecimal("2.0"), unit_amount: BigDecimal("50.99"), account_code: "600", tax_type: XeroRuby::Accounting::TaxType::NONE }], date: "2019-03-11", due_date: "2018-12-10", reference: "Website Design", status: XeroRuby::Accounting::Invoice::DRAFT }]}
|
187
226
|
invoice = xero_client.accounting_api.create_invoices(tenant_id, invoices).invoices.first
|
188
227
|
|
189
|
-
# display out all the serialized data as a hash
|
228
|
+
# display out all the serialized data as a snake_case hash
|
190
229
|
puts invoices.to_attributes
|
191
230
|
=> {type: 'ACCREC', line_items: [...]}
|
192
231
|
|
232
|
+
puts invoices.to_hash(downcase: false)
|
233
|
+
=> {'Type': 'ACCREC', 'LineItems': [...]}
|
234
|
+
|
193
235
|
# Create History
|
194
236
|
payment = xero_client.accounting_api.get_payments(tenant_id).payments.first
|
195
237
|
history_records = { history_records: [{ details: "This payment now has some History!" }]}
|
@@ -331,19 +373,13 @@ opts = {
|
|
331
373
|
}
|
332
374
|
xero_client.accounting_api.get_bank_transfers(tenant_id, opts).bank_transfers
|
333
375
|
```
|
334
|
-
|
376
|
+
|
335
377
|
1) Not all `opts` parameter combinations are available for all endpoints, and there are likely some undiscovered edge cases. If you encounter a filter / sort / where clause that seems buggy open an issue and we will dig.
|
336
378
|
|
337
379
|
2) Some opts string values may need PascalCasing to match casing defined in our [core API docs](https://developer.xero.com/documentation/api/api-overview).
|
338
380
|
* `opts = { order: 'UpdatedDateUtc DESC'}`
|
339
381
|
|
340
382
|
3) If you have use cases outside of these examples let us know.
|
341
|
-
|
342
|
-
## Sample App
|
343
|
-
The best resource to understanding how to best leverage this SDK is the sample applications showing all the features of the gem.
|
344
|
-
> https://github.com/XeroAPI/xero-ruby-oauth2-starter (Sinatra - simple getting started)
|
345
|
-
> https://github.com/XeroAPI/xero-ruby-oauth2-app (Rails - full featured examples)
|
346
|
-
|
347
383
|
## Developing locally
|
348
384
|
To develop this gem locally against your project you can use the following development pattern:
|
349
385
|
|
@@ -7728,6 +7728,7 @@ module XeroRuby
|
|
7728
7728
|
# @option opts [Array<String>] :i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call.
|
7729
7729
|
# @option opts [Integer] :page e.g. page=1 - Up to 100 contacts will be returned in a single API call.
|
7730
7730
|
# @option opts [Boolean] :include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response
|
7731
|
+
# @option opts [Boolean] :summary_only Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient. (default to false)
|
7731
7732
|
# @return [Contacts]
|
7732
7733
|
def get_contacts(xero_tenant_id, opts = {})
|
7733
7734
|
data, _status_code, _headers = get_contacts_with_http_info(xero_tenant_id, opts)
|
@@ -7743,6 +7744,7 @@ module XeroRuby
|
|
7743
7744
|
# @option opts [Array<String>] :i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call.
|
7744
7745
|
# @option opts [Integer] :page e.g. page=1 - Up to 100 contacts will be returned in a single API call.
|
7745
7746
|
# @option opts [Boolean] :include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response
|
7747
|
+
# @option opts [Boolean] :summary_only Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
|
7746
7748
|
# @return [Array<(Contacts, Integer, Hash)>] Contacts data, response status code and response headers
|
7747
7749
|
def get_contacts_with_http_info(xero_tenant_id, options = {})
|
7748
7750
|
opts = options.dup
|
@@ -7766,6 +7768,7 @@ module XeroRuby
|
|
7766
7768
|
query_params[:'IDs'] = @api_client.build_collection_param(opts[:'i_ds'], :csv) if !opts[:'i_ds'].nil?
|
7767
7769
|
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
7768
7770
|
query_params[:'includeArchived'] = opts[:'include_archived'] if !opts[:'include_archived'].nil?
|
7771
|
+
query_params[:'summaryOnly'] = opts[:'summary_only'] if !opts[:'summary_only'].nil?
|
7769
7772
|
|
7770
7773
|
# XeroAPI's `IDs` convention openapi-generator does not snake_case properly.. manual over-riding `i_ds` malformations:
|
7771
7774
|
query_params[:'IDs'] = @api_client.build_collection_param(opts[:'ids'], :csv) if !opts[:'ids'].nil?
|
@@ -9386,6 +9389,7 @@ module XeroRuby
|
|
9386
9389
|
# @option opts [Integer] :page e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice
|
9387
9390
|
# @option opts [Boolean] :include_archived e.g. includeArchived=true - Invoices with a status of ARCHIVED will be included in the response
|
9388
9391
|
# @option opts [Boolean] :created_by_my_app When set to true you'll only retrieve Invoices created by your app
|
9392
|
+
# @option opts [Boolean] :summary_only Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient. (default to false)
|
9389
9393
|
# @option opts [Integer] :unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts
|
9390
9394
|
# @return [Invoices]
|
9391
9395
|
def get_invoices(xero_tenant_id, opts = {})
|
@@ -9406,6 +9410,7 @@ module XeroRuby
|
|
9406
9410
|
# @option opts [Integer] :page e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice
|
9407
9411
|
# @option opts [Boolean] :include_archived e.g. includeArchived=true - Invoices with a status of ARCHIVED will be included in the response
|
9408
9412
|
# @option opts [Boolean] :created_by_my_app When set to true you'll only retrieve Invoices created by your app
|
9413
|
+
# @option opts [Boolean] :summary_only Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient.
|
9409
9414
|
# @option opts [Integer] :unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts
|
9410
9415
|
# @return [Array<(Invoices, Integer, Hash)>] Invoices data, response status code and response headers
|
9411
9416
|
def get_invoices_with_http_info(xero_tenant_id, options = {})
|
@@ -9434,6 +9439,7 @@ module XeroRuby
|
|
9434
9439
|
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
9435
9440
|
query_params[:'includeArchived'] = opts[:'include_archived'] if !opts[:'include_archived'].nil?
|
9436
9441
|
query_params[:'createdByMyApp'] = opts[:'created_by_my_app'] if !opts[:'created_by_my_app'].nil?
|
9442
|
+
query_params[:'summaryOnly'] = opts[:'summary_only'] if !opts[:'summary_only'].nil?
|
9437
9443
|
query_params[:'unitdp'] = opts[:'unitdp'] if !opts[:'unitdp'].nil?
|
9438
9444
|
|
9439
9445
|
# XeroAPI's `IDs` convention openapi-generator does not snake_case properly.. manual over-riding `i_ds` malformations:
|
data/lib/xero-ruby/api_client.rb
CHANGED
@@ -17,6 +17,7 @@ require 'find'
|
|
17
17
|
require 'faraday'
|
18
18
|
require 'base64'
|
19
19
|
require 'cgi'
|
20
|
+
require 'json/jwt'
|
20
21
|
|
21
22
|
module XeroRuby
|
22
23
|
class ApiClient
|
@@ -38,7 +39,8 @@ module XeroRuby
|
|
38
39
|
@redirect_uri = credentials[:redirect_uri]
|
39
40
|
@scopes = credentials[:scopes]
|
40
41
|
@state = credentials[:state]
|
41
|
-
|
42
|
+
default_config = Configuration.default.clone
|
43
|
+
@config = append_to_default_config(default_config, config)
|
42
44
|
|
43
45
|
@user_agent = "xero-ruby-#{VERSION}"
|
44
46
|
@default_headers = {
|
@@ -47,9 +49,9 @@ module XeroRuby
|
|
47
49
|
}
|
48
50
|
end
|
49
51
|
|
50
|
-
def append_to_default_config(user_config)
|
51
|
-
config =
|
52
|
-
user_config.each{|k,v| config.send("#{k}=", v)
|
52
|
+
def append_to_default_config(default_config, user_config)
|
53
|
+
config = default_config
|
54
|
+
user_config.each{|k,v| config.send("#{k}=", v)}
|
53
55
|
config
|
54
56
|
end
|
55
57
|
|
@@ -96,22 +98,41 @@ module XeroRuby
|
|
96
98
|
|
97
99
|
# Token Helpers
|
98
100
|
def token_set
|
99
|
-
|
101
|
+
@config.token_set
|
100
102
|
end
|
101
103
|
|
102
104
|
def access_token
|
103
|
-
|
105
|
+
@config.access_token
|
106
|
+
end
|
107
|
+
|
108
|
+
def id_token
|
109
|
+
@config.id_token
|
110
|
+
end
|
111
|
+
|
112
|
+
def decoded_access_token
|
113
|
+
decode_jwt(@config.access_token, false)
|
114
|
+
end
|
115
|
+
|
116
|
+
def decoded_id_token
|
117
|
+
decode_jwt(@config.id_token, false)
|
104
118
|
end
|
105
119
|
|
106
120
|
def set_token_set(token_set)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
set_access_token(token_set[
|
121
|
+
token_set = token_set.with_indifferent_access
|
122
|
+
@config.token_set = token_set
|
123
|
+
|
124
|
+
set_access_token(token_set[:access_token]) if token_set[:access_token]
|
125
|
+
set_id_token(token_set[:id_token]) if token_set[:id_token]
|
126
|
+
|
127
|
+
return true
|
111
128
|
end
|
112
129
|
|
113
130
|
def set_access_token(access_token)
|
114
|
-
|
131
|
+
@config.access_token = access_token
|
132
|
+
end
|
133
|
+
|
134
|
+
def set_id_token(id_token)
|
135
|
+
@config.id_token = id_token
|
115
136
|
end
|
116
137
|
|
117
138
|
def get_token_set_from_callback(params)
|
@@ -120,20 +141,59 @@ module XeroRuby
|
|
120
141
|
code: params['code'],
|
121
142
|
redirect_uri: @redirect_uri
|
122
143
|
}
|
123
|
-
|
144
|
+
token_set = token_request(data, '/token')
|
145
|
+
|
146
|
+
validate_tokens(token_set)
|
147
|
+
validate_state(params)
|
148
|
+
return token_set
|
149
|
+
end
|
150
|
+
|
151
|
+
def validate_tokens(token_set)
|
152
|
+
token_set = token_set.with_indifferent_access
|
153
|
+
id_token = token_set[:id_token]
|
154
|
+
access_token = token_set[:access_token]
|
155
|
+
if id_token || access_token
|
156
|
+
decode_jwt(access_token) if access_token
|
157
|
+
decode_jwt(id_token) if id_token
|
158
|
+
end
|
159
|
+
return true
|
160
|
+
end
|
161
|
+
|
162
|
+
def validate_state(params)
|
163
|
+
if params[:state] != @state
|
164
|
+
raise StandardError.new "WARNING: @config.state: #{@state} and OAuth callback state: #{params['state']} do not match!"
|
165
|
+
end
|
166
|
+
return true
|
167
|
+
end
|
168
|
+
|
169
|
+
def decode_jwt(tkn, verify=true)
|
170
|
+
if verify == true
|
171
|
+
jwks_data = JSON.parse(Faraday.get('https://identity.xero.com/.well-known/openid-configuration/jwks').body)
|
172
|
+
jwk_set = JSON::JWK::Set.new(jwks_data)
|
173
|
+
JSON::JWT.decode(tkn, jwk_set)
|
174
|
+
else
|
175
|
+
JSON::JWT.decode(tkn, :skip_verification)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def token_expired?
|
180
|
+
token_expiry = Time.at(decoded_access_token['exp'])
|
181
|
+
token_expiry < Time.now
|
124
182
|
end
|
125
183
|
|
126
184
|
def refresh_token_set(token_set)
|
185
|
+
token_set = token_set.with_indifferent_access
|
127
186
|
data = {
|
128
187
|
grant_type: 'refresh_token',
|
129
|
-
refresh_token: token_set[
|
188
|
+
refresh_token: token_set[:refresh_token]
|
130
189
|
}
|
131
190
|
return token_request(data, '/token')
|
132
191
|
end
|
133
192
|
|
134
193
|
def revoke_token(token_set)
|
194
|
+
token_set = token_set.with_indifferent_access
|
135
195
|
data = {
|
136
|
-
token: token_set[
|
196
|
+
token: token_set[:refresh_token]
|
137
197
|
}
|
138
198
|
return token_request(data, '/revocation')
|
139
199
|
end
|
@@ -182,7 +242,26 @@ module XeroRuby
|
|
182
242
|
:client_key => @config.ssl_client_key
|
183
243
|
}
|
184
244
|
|
185
|
-
|
245
|
+
case api_client
|
246
|
+
when "AccountingApi"
|
247
|
+
method_base_url = @config.accounting_url
|
248
|
+
when "AssetApi"
|
249
|
+
method_base_url = @config.asset_url
|
250
|
+
when "FilesApi"
|
251
|
+
method_base_url = @config.files_url
|
252
|
+
when "PayrollAuApi"
|
253
|
+
method_base_url = @config.payroll_au_url
|
254
|
+
when "PayrollNzApi"
|
255
|
+
method_base_url = @config.payroll_nz_url
|
256
|
+
when "PayrollUkApi"
|
257
|
+
method_base_url = @config.payroll_uk_url
|
258
|
+
when "ProjectApi"
|
259
|
+
method_base_url = @config.project_url
|
260
|
+
else
|
261
|
+
method_base_url = @config.accounting_url
|
262
|
+
end
|
263
|
+
|
264
|
+
connection = Faraday.new(:url => method_base_url, :ssl => ssl_options) do |conn|
|
186
265
|
conn.basic_auth(config.username, config.password)
|
187
266
|
if opts[:header_params]["Content-Type"] == "multipart/form-data"
|
188
267
|
conn.request :multipart
|
@@ -265,7 +344,8 @@ module XeroRuby
|
|
265
344
|
end
|
266
345
|
end
|
267
346
|
request.headers = header_params
|
268
|
-
|
347
|
+
timeout = @config.timeout
|
348
|
+
request.options.timeout = timeout if timeout > 0
|
269
349
|
request.body = req_body
|
270
350
|
request.url url
|
271
351
|
request.params = query_params
|