xero-ruby 2.4.1 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +240 -189
- data/lib/xero-ruby.rb +10 -4
- data/lib/xero-ruby/api/accounting_api.rb +1308 -920
- data/lib/xero-ruby/api/asset_api.rb +15 -14
- data/lib/xero-ruby/api/files_api.rb +204 -85
- data/lib/xero-ruby/api/payroll_au_api.rb +121 -93
- data/lib/xero-ruby/api/payroll_nz_api.rb +307 -240
- data/lib/xero-ruby/api/payroll_uk_api.rb +317 -254
- data/lib/xero-ruby/api/project_api.rb +71 -59
- data/lib/xero-ruby/api_client.rb +182 -128
- data/lib/xero-ruby/api_error.rb +4 -4
- data/lib/xero-ruby/configuration.rb +17 -5
- data/lib/xero-ruby/models/accounting/account.rb +25 -12
- data/lib/xero-ruby/models/accounting/account_type.rb +1 -2
- data/lib/xero-ruby/models/accounting/accounts.rb +25 -11
- data/lib/xero-ruby/models/accounting/accounts_payable.rb +25 -11
- data/lib/xero-ruby/models/accounting/accounts_receivable.rb +25 -11
- data/lib/xero-ruby/models/accounting/action.rb +25 -11
- data/lib/xero-ruby/models/accounting/actions.rb +25 -11
- data/lib/xero-ruby/models/accounting/address.rb +27 -14
- data/lib/xero-ruby/models/accounting/address_for_organisation.rb +484 -0
- data/lib/xero-ruby/models/accounting/allocation.rb +25 -11
- data/lib/xero-ruby/models/accounting/allocations.rb +25 -11
- data/lib/xero-ruby/models/accounting/attachment.rb +25 -11
- data/lib/xero-ruby/models/accounting/attachments.rb +25 -11
- data/lib/xero-ruby/models/accounting/balance_details.rb +25 -11
- data/lib/xero-ruby/models/accounting/balances.rb +25 -11
- data/lib/xero-ruby/models/accounting/bank_transaction.rb +25 -11
- data/lib/xero-ruby/models/accounting/bank_transactions.rb +25 -11
- data/lib/xero-ruby/models/accounting/bank_transfer.rb +25 -11
- data/lib/xero-ruby/models/accounting/bank_transfers.rb +25 -11
- data/lib/xero-ruby/models/accounting/batch_payment.rb +41 -15
- data/lib/xero-ruby/models/accounting/batch_payment_details.rb +25 -11
- data/lib/xero-ruby/models/accounting/batch_payments.rb +25 -11
- data/lib/xero-ruby/models/accounting/bill.rb +25 -11
- data/lib/xero-ruby/models/accounting/branding_theme.rb +25 -11
- data/lib/xero-ruby/models/accounting/branding_themes.rb +25 -11
- data/lib/xero-ruby/models/accounting/budget.rb +327 -0
- data/lib/xero-ruby/models/accounting/budget_balance.rb +267 -0
- data/lib/xero-ruby/models/accounting/budget_line.rb +244 -0
- data/lib/xero-ruby/models/{files/file_response204.rb → accounting/budgets.rb} +40 -24
- data/lib/xero-ruby/models/accounting/cis_org_setting.rb +26 -12
- data/lib/xero-ruby/models/accounting/cis_org_settings.rb +224 -0
- data/lib/xero-ruby/models/accounting/cis_setting.rb +26 -12
- data/lib/xero-ruby/models/accounting/cis_settings.rb +25 -11
- data/lib/xero-ruby/models/accounting/contact.rb +25 -11
- data/lib/xero-ruby/models/accounting/contact_group.rb +25 -11
- data/lib/xero-ruby/models/accounting/contact_groups.rb +25 -11
- data/lib/xero-ruby/models/accounting/contact_person.rb +25 -11
- data/lib/xero-ruby/models/accounting/contacts.rb +25 -11
- data/lib/xero-ruby/models/accounting/conversion_balances.rb +25 -11
- data/lib/xero-ruby/models/accounting/conversion_date.rb +25 -11
- data/lib/xero-ruby/models/accounting/country_code.rb +1 -2
- data/lib/xero-ruby/models/accounting/credit_note.rb +62 -16
- data/lib/xero-ruby/models/accounting/credit_notes.rb +25 -11
- data/lib/xero-ruby/models/accounting/currencies.rb +25 -11
- data/lib/xero-ruby/models/accounting/currency.rb +25 -11
- data/lib/xero-ruby/models/accounting/currency_code.rb +1 -2
- data/lib/xero-ruby/models/accounting/element.rb +25 -11
- data/lib/xero-ruby/models/accounting/employee.rb +25 -11
- data/lib/xero-ruby/models/accounting/employees.rb +25 -11
- data/lib/xero-ruby/models/accounting/error.rb +25 -11
- data/lib/xero-ruby/models/accounting/expense_claim.rb +25 -11
- data/lib/xero-ruby/models/accounting/expense_claims.rb +25 -11
- data/lib/xero-ruby/models/accounting/external_link.rb +25 -11
- data/lib/xero-ruby/models/accounting/history_record.rb +25 -11
- data/lib/xero-ruby/models/accounting/history_records.rb +25 -11
- data/lib/xero-ruby/models/accounting/import_summary.rb +25 -11
- data/lib/xero-ruby/models/accounting/import_summary_accounts.rb +33 -19
- data/lib/xero-ruby/models/accounting/import_summary_object.rb +25 -11
- data/lib/xero-ruby/models/accounting/import_summary_organisation.rb +25 -11
- data/lib/xero-ruby/models/accounting/invoice.rb +37 -28
- data/lib/xero-ruby/models/accounting/invoice_reminder.rb +25 -11
- data/lib/xero-ruby/models/accounting/invoice_reminders.rb +25 -11
- data/lib/xero-ruby/models/accounting/invoices.rb +25 -11
- data/lib/xero-ruby/models/accounting/item.rb +25 -11
- data/lib/xero-ruby/models/accounting/items.rb +25 -11
- data/lib/xero-ruby/models/accounting/journal.rb +25 -11
- data/lib/xero-ruby/models/accounting/journal_line.rb +25 -11
- data/lib/xero-ruby/models/accounting/journals.rb +25 -11
- data/lib/xero-ruby/models/accounting/line_amount_types.rb +1 -2
- data/lib/xero-ruby/models/accounting/line_item.rb +36 -12
- data/lib/xero-ruby/models/accounting/line_item_tracking.rb +25 -11
- data/lib/xero-ruby/models/accounting/linked_transaction.rb +25 -11
- data/lib/xero-ruby/models/accounting/linked_transactions.rb +25 -11
- data/lib/xero-ruby/models/accounting/manual_journal.rb +25 -11
- data/lib/xero-ruby/models/accounting/manual_journal_line.rb +25 -11
- data/lib/xero-ruby/models/accounting/manual_journals.rb +25 -11
- data/lib/xero-ruby/models/accounting/online_invoice.rb +25 -11
- data/lib/xero-ruby/models/accounting/online_invoices.rb +25 -11
- data/lib/xero-ruby/models/accounting/organisation.rb +26 -14
- data/lib/xero-ruby/models/accounting/organisations.rb +25 -11
- data/lib/xero-ruby/models/accounting/overpayment.rb +25 -11
- data/lib/xero-ruby/models/accounting/overpayments.rb +25 -11
- data/lib/xero-ruby/models/accounting/payment.rb +36 -12
- data/lib/xero-ruby/models/accounting/payment_delete.rb +25 -11
- data/lib/xero-ruby/models/accounting/payment_service.rb +25 -11
- data/lib/xero-ruby/models/accounting/payment_services.rb +25 -11
- data/lib/xero-ruby/models/accounting/payment_term.rb +25 -11
- data/lib/xero-ruby/models/accounting/payment_term_type.rb +1 -2
- data/lib/xero-ruby/models/accounting/payments.rb +25 -11
- data/lib/xero-ruby/models/accounting/phone.rb +25 -11
- data/lib/xero-ruby/models/accounting/prepayment.rb +38 -12
- data/lib/xero-ruby/models/accounting/prepayments.rb +25 -11
- data/lib/xero-ruby/models/accounting/purchase.rb +25 -11
- data/lib/xero-ruby/models/accounting/purchase_order.rb +25 -11
- data/lib/xero-ruby/models/accounting/purchase_orders.rb +25 -11
- data/lib/xero-ruby/models/accounting/quote.rb +25 -11
- data/lib/xero-ruby/models/accounting/quote_line_amount_types.rb +1 -2
- data/lib/xero-ruby/models/accounting/quote_status_codes.rb +1 -2
- data/lib/xero-ruby/models/accounting/quotes.rb +25 -11
- data/lib/xero-ruby/models/accounting/receipt.rb +25 -11
- data/lib/xero-ruby/models/accounting/receipts.rb +25 -11
- data/lib/xero-ruby/models/accounting/repeating_invoice.rb +25 -11
- data/lib/xero-ruby/models/accounting/repeating_invoices.rb +25 -11
- data/lib/xero-ruby/models/accounting/report.rb +26 -22
- data/lib/xero-ruby/models/accounting/report_attribute.rb +25 -11
- data/lib/xero-ruby/models/accounting/report_cell.rb +25 -11
- data/lib/xero-ruby/models/accounting/report_fields.rb +25 -11
- data/lib/xero-ruby/models/accounting/report_row.rb +25 -11
- data/lib/xero-ruby/models/accounting/report_rows.rb +25 -11
- data/lib/xero-ruby/models/accounting/report_with_row.rb +26 -12
- data/lib/xero-ruby/models/accounting/report_with_rows.rb +25 -11
- data/lib/xero-ruby/models/accounting/reports.rb +25 -11
- data/lib/xero-ruby/models/accounting/request_empty.rb +25 -11
- data/lib/xero-ruby/models/accounting/row_type.rb +1 -2
- data/lib/xero-ruby/models/accounting/sales_tracking_category.rb +25 -11
- data/lib/xero-ruby/models/accounting/schedule.rb +25 -11
- data/lib/xero-ruby/models/accounting/setup.rb +25 -11
- data/lib/xero-ruby/models/accounting/tax_component.rb +25 -11
- data/lib/xero-ruby/models/accounting/tax_rate.rb +25 -11
- data/lib/xero-ruby/models/accounting/tax_rates.rb +25 -11
- data/lib/xero-ruby/models/accounting/tax_type.rb +1 -2
- data/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +25 -11
- data/lib/xero-ruby/models/accounting/time_zone.rb +1 -2
- data/lib/xero-ruby/models/accounting/tracking_categories.rb +25 -11
- data/lib/xero-ruby/models/accounting/tracking_category.rb +25 -11
- data/lib/xero-ruby/models/accounting/tracking_option.rb +25 -11
- data/lib/xero-ruby/models/accounting/tracking_options.rb +25 -11
- data/lib/xero-ruby/models/accounting/user.rb +25 -11
- data/lib/xero-ruby/models/accounting/users.rb +25 -11
- data/lib/xero-ruby/models/accounting/validation_error.rb +25 -11
- data/lib/xero-ruby/models/assets/asset.rb +25 -11
- data/lib/xero-ruby/models/assets/asset_status.rb +1 -2
- data/lib/xero-ruby/models/assets/asset_status_query_param.rb +1 -2
- data/lib/xero-ruby/models/assets/asset_type.rb +25 -11
- data/lib/xero-ruby/models/assets/assets.rb +25 -11
- data/lib/xero-ruby/models/assets/book_depreciation_detail.rb +25 -11
- data/lib/xero-ruby/models/assets/book_depreciation_setting.rb +25 -11
- data/lib/xero-ruby/models/assets/error.rb +25 -11
- data/lib/xero-ruby/models/assets/field_validation_errors_element.rb +26 -12
- data/lib/xero-ruby/models/assets/pagination.rb +25 -11
- data/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +26 -12
- data/lib/xero-ruby/models/assets/setting.rb +25 -11
- data/lib/xero-ruby/models/files/association.rb +25 -11
- data/lib/xero-ruby/models/files/file_object.rb +25 -11
- data/lib/xero-ruby/models/files/files.rb +25 -11
- data/lib/xero-ruby/models/files/folder.rb +25 -11
- data/lib/xero-ruby/models/files/folders.rb +25 -11
- data/lib/xero-ruby/models/files/object_group.rb +1 -2
- data/lib/xero-ruby/models/files/object_type.rb +1 -2
- data/lib/xero-ruby/models/files/{inline_object.rb → upload_object.rb} +43 -14
- data/lib/xero-ruby/models/files/user.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/account.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/account_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/allowance_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/api_exception.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/bank_account.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/calendar_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/deduction_line.rb +25 -16
- data/lib/xero-ruby/models/payroll_au/deduction_type.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/deduction_type_calculation_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/earnings_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/earnings_rate.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/earnings_rate_calculation_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/earnings_type.rb +2 -2
- data/lib/xero-ruby/models/payroll_au/employee.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/employee_status.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/employees.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/employment_basis.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/employment_termination_payment_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/entitlement_final_pay_payout_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/home_address.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_application.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_applications.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_balance.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_line_calculation_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/leave_lines.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_period.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_period_status.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/leave_type.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/leave_type_contribution_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/manual_tax_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/opening_balances.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/pay_item.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/pay_items.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/pay_run.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/pay_run_status.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/pay_runs.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/pay_template.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/payment_frequency_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/payroll_calendars.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/payslip.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/payslip_lines.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/payslip_object.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/payslip_summary.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/payslips.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/rate_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/reimbursement_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/reimbursement_type.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/residency_status.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/settings.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/settings_object.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/state.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/super_fund.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/super_fund_product.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/super_fund_products.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/super_fund_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/super_funds.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/super_line.rb +26 -12
- data/lib/xero-ruby/models/payroll_au/super_membership.rb +26 -12
- data/lib/xero-ruby/models/payroll_au/superannuation_calculation_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/superannuation_contribution_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/superannuation_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/tax_declaration.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/tax_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/tfn_exemption_type.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/timesheet.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/timesheet_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/timesheet_object.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/timesheet_status.rb +1 -2
- data/lib/xero-ruby/models/payroll_au/timesheets.rb +25 -11
- data/lib/xero-ruby/models/payroll_au/validation_error.rb +25 -11
- data/lib/xero-ruby/models/payroll_nz/account.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/accounts.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/address.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/bank_account.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/benefit.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/calendar_type.rb +0 -1
- data/lib/xero-ruby/models/payroll_nz/deduction.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/deduction_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/deduction_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/deductions.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_nz/earnings_order.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_orders.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_rate.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_rates.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_template.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_leaves.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb +25 -11
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_tax.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employees.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employment.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/employment_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/invalid_field.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_nz/leave_period.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/leave_periods.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/leave_type.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/leave_type_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/leave_types.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pagination.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_run.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_run_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_runs.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_slip.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/pay_slips.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/payment_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/payment_method.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/payment_method_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/problem.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/reimbursement.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/reimbursements.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +28 -13
- data/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/settings.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/statutory_deduction_category.rb +0 -1
- data/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/superannuation_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_nz/superannuation_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/superannuations.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/tax_code.rb +0 -1
- data/lib/xero-ruby/models/payroll_nz/tax_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/tax_settings.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/timesheet.rb +28 -13
- data/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb +25 -11
- data/lib/xero-ruby/models/payroll_nz/timesheet_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/timesheet_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/timesheets.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/tracking_categories.rb +24 -10
- data/lib/xero-ruby/models/payroll_nz/tracking_category.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/account.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/accounts.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/address.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/bank_account.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/benefit.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/benefit_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/benefit_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/benefits.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/court_order_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/deduction.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/deduction_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/deduction_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/deductions.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_order.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_orders.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +34 -12
- data/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_rates.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_template.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leave.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_leaves.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb +25 -11
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_tax.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employees.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employment.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/employment_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/invalid_field.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/leave_period.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/leave_periods.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/leave_type.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/leave_type_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/leave_types.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/pagination.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/pay_run.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/pay_run_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/pay_runs.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/payment_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/payment_method.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/payment_method_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/payslip.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/payslip_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/payslips.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/problem.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/reimbursement.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/reimbursements.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +27 -12
- data/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/settings.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/statutory_deduction_category.rb +0 -1
- data/lib/xero-ruby/models/payroll_uk/tax_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/timesheet.rb +25 -11
- data/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/timesheet_line.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/timesheet_object.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/timesheets.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/tracking_categories.rb +24 -10
- data/lib/xero-ruby/models/payroll_uk/tracking_category.rb +24 -10
- data/lib/xero-ruby/models/projects/amount.rb +24 -10
- data/lib/xero-ruby/models/projects/charge_type.rb +0 -1
- data/lib/xero-ruby/models/projects/currency_code.rb +0 -1
- data/lib/xero-ruby/models/projects/error.rb +24 -10
- data/lib/xero-ruby/models/projects/pagination.rb +24 -10
- data/lib/xero-ruby/models/projects/project.rb +24 -10
- data/lib/xero-ruby/models/projects/project_create_or_update.rb +24 -10
- data/lib/xero-ruby/models/projects/project_patch.rb +24 -10
- data/lib/xero-ruby/models/projects/project_status.rb +0 -1
- data/lib/xero-ruby/models/projects/project_user.rb +24 -10
- data/lib/xero-ruby/models/projects/project_users.rb +24 -10
- data/lib/xero-ruby/models/projects/projects.rb +24 -10
- data/lib/xero-ruby/models/projects/task.rb +24 -10
- data/lib/xero-ruby/models/projects/task_create_or_update.rb +24 -10
- data/lib/xero-ruby/models/projects/tasks.rb +24 -10
- data/lib/xero-ruby/models/projects/time_entries.rb +24 -10
- data/lib/xero-ruby/models/projects/time_entry.rb +27 -12
- data/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +24 -10
- data/lib/xero-ruby/string_serialization.rb +52 -0
- data/lib/xero-ruby/version.rb +3 -3
- data/lib/xero-ruby/where.rb +65 -0
- data/spec/api_client_spec.rb +292 -14
- data/spec/api_error_spec.rb +45 -0
- data/spec/configuration_spec.rb +26 -16
- data/spec/files/models/inline_object_spec.rb +3 -3
- data/spec/helper_methods_spec.rb +110 -0
- data/spec/where_spec.rb +82 -0
- metadata +43 -12
- data/spec/files/models/file_response204_spec.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcc8e88d077eb5b42f9a9c8a206ce6c7fb62589e7179932764a70cc28c3f821a
|
4
|
+
data.tar.gz: 8c25945749aaca49892462186f749701255022d05ea498645a3b1e59c10a5e52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4196ec14ceaa6179bbbedb856b447e7af947ba96e4af24ab8130835af5660a8e6787fbf3261c3f6c5c605d0f81436559bd37e1e0a7252bab42feb752f4634d31
|
7
|
+
data.tar.gz: c99e89b1f45563b72023ad5d5ceb3632fe5661068ad5ee89d672194fca72ddccbb1967d9f9796098d12ff9b649f03dfa5b26d3eb08b3daf756bef0e3a7f3fe5f
|
data/README.md
CHANGED
@@ -1,176 +1,228 @@
|
|
1
1
|
# xero-ruby
|
2
|
-
|
3
|
-
|
4
|
-
[![
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/xero-ruby.svg)](https://badge.fury.io/rb/xero-ruby)
|
3
|
+
[![Github forks](https://img.shields.io/github/forks/XeroAPI/xero-ruby.svg)](https://github.com/XeroAPI/xero-ruby/network)
|
4
|
+
[![Github stars](https://img.shields.io/github/stars/XeroAPI/xero-ruby.svg)](https://github.com/XeroAPI/xero-ruby/stargazers)
|
5
|
+
![total downloads](https://ruby-gem-downloads-badge.herokuapp.com/xero-ruby?type=total)
|
6
|
+
|
7
|
+
The xero-ruby SDK makes it easy for developers to access Xero's APIs in their Ruby code, and build robust applications and software using small business & general ledget accounting data.
|
8
|
+
# Table of Contents
|
9
|
+
- [API Client documentation](#api-client-documentation)
|
10
|
+
- [Sample Applications](#sample-applications)
|
11
|
+
- [Xero Account Requirements](#xero-account-requirements)
|
12
|
+
- [Installation](#installation)
|
13
|
+
- [Configuration](#configuration)
|
14
|
+
- [Authentication](#authentication)
|
15
|
+
- [Custom Connections](#custom-connections)
|
16
|
+
- [API Clients](#api-clients)
|
17
|
+
- [Helper Methods](#helper-methods)
|
18
|
+
- [Usage Examples](#usage-examples)
|
19
|
+
- [SDK conventions](#sdk-conventions)
|
20
|
+
- [Contributing](#contributing)
|
21
|
+
|
22
|
+
<hr>
|
23
|
+
|
24
|
+
## API Client documentation
|
25
|
+
This SDK supports full method coverage for the following Xero API sets:
|
26
|
+
|
27
|
+
| API Set | Description |
|
28
|
+
| --- | --- |
|
29
|
+
| [`Accounting`](https://xeroapi.github.io/xero-ruby/accounting/index.html) | The Accounting API exposes accounting functions of the main Xero application *(most commonly used)*
|
30
|
+
| [Assets](https://xeroapi.github.io/xero-ruby/assets/index.html) | The Assets API exposes fixed asset related functions of the Xero Accounting application |
|
31
|
+
| [Files](https://xeroapi.github.io/xero-ruby/files/index.html) | The Files API provides access to the files, folders, and the association of files within a Xero organisation |
|
32
|
+
| [Projects](https://xeroapi.github.io/xero-ruby/projects/index.html) | Xero Projects allows businesses to track time and costs on projects/jobs and report on profitability |
|
33
|
+
| [Payroll (AU)](https://xeroapi.github.io/xero-ruby/payroll_au/index.html) | The (AU) Payroll API exposes payroll related functions of the payroll Xero application |
|
34
|
+
| [Payroll (UK)](https://xeroapi.github.io/xero-ruby/payroll_uk/index.html) | The (UK) Payroll API exposes payroll related functions of the payroll Xero application |
|
35
|
+
| [Payroll (NZ)](https://xeroapi.github.io/xero-ruby/payroll_nz/index.html) | The (NZ) Payroll API exposes payroll related functions of the payroll Xero application |
|
36
|
+
| [`Ruby Models`](/docs/) | Directory of markdown files, describing the object models for all supported API sets |
|
37
|
+
|
38
|
+
<img src="https://i.imgur.com/0MsvkGB.png" alt="drawing" width="350"/>
|
39
|
+
|
40
|
+
<hr>
|
41
|
+
|
42
|
+
## Sample Applications
|
43
|
+
Sample apps can get you started quickly with simple auth flows to advanced usage.
|
44
|
+
| Sample App | Description | Screenshot |
|
45
|
+
| --- | --- | --- |
|
46
|
+
| [`xero-ruby-oauth2-starter`](https://github.com/XeroAPI/Xero-ruby-oauth2-starter) | A Sinatra application showing the basic getting started code to work with the sdk | <img src="https://i.imgur.com/9H4F98M.png" alt="drawing" width="300"/>
|
47
|
+
| [`xero-ruby-oauth2-app`](https://github.com/XeroAPI/Xero-ruby-oauth2-app) | Complete rails app with +95% of api set examples, complex filters, pagination, and user/token management in postgres | <img src="https://i.imgur.com/XsAp9Ww.png" alt="drawing" width="500"/>
|
48
|
+
| [`xero-ruby-custom-connections-starter`](https://github.com/XeroAPI/xero-ruby-custom-connections-starter) | A getting started Sinatra app showing Custom Connections - a Xero [premium option](https://developer.xero.com/documentation/oauth2/custom-connections) for building M2M integrations to a single org | <img src="https://i.imgur.com/YEkScui.png" alt="drawing" width="300"/>
|
49
|
+
|
50
|
+
<hr>
|
51
|
+
|
52
|
+
## Xero Account Requirements
|
53
|
+
- Create a [free Xero user account](https://www.xero.com/us/signup/api/)
|
54
|
+
- Login to your Xero developer [dashboard](https://developer.xero.com/app/manage) and create an API application
|
55
|
+
- Copy the credentials from your API app and store them using a secure ENV variable strategy
|
56
|
+
- Decide the [neccesary scopes](https://developer.xero.com/documentation/oauth2/scopes) for your app's functionality
|
57
|
+
|
58
|
+
# Installation
|
59
|
+
To install this gem to your project
|
40
60
|
```
|
41
61
|
gem install 'xero-ruby'
|
42
62
|
```
|
43
|
-
Or add to your gemfile and run `bundle install
|
63
|
+
Or add to your gemfile and run `bundle install`
|
44
64
|
```
|
45
65
|
gem 'xero-ruby'
|
46
66
|
```
|
47
67
|
|
48
|
-
|
49
|
-
|
50
|
-
* Login to your Xero developer [/myapps](https://developer.xero.com/myapps) dashboard & create an API application and note your API app's credentials.
|
51
|
-
|
52
|
-
### Creating a Client
|
53
|
-
* Get the credential values from an API application at https://developer.xero.com/myapps/.
|
54
|
-
* Include [neccesary scopes](https://developer.xero.com/documentation/oauth2/scopes) as comma seperated list
|
55
|
-
* example => "`openid profile email accounting.transactions accounting.settings`"
|
56
|
-
```
|
57
|
-
require 'xero-ruby'
|
58
|
-
```
|
68
|
+
---
|
69
|
+
## Configuration
|
59
70
|
```ruby
|
71
|
+
require 'xero-ruby'
|
72
|
+
|
60
73
|
creds = {
|
61
74
|
client_id: ENV['CLIENT_ID'],
|
62
75
|
client_secret: ENV['CLIENT_SECRET'],
|
63
76
|
redirect_uri: ENV['REDIRECT_URI'],
|
64
|
-
scopes: ENV['SCOPES']
|
77
|
+
scopes: ENV['SCOPES'],
|
78
|
+
state: "Optional value to pass through auth flow"
|
65
79
|
}
|
66
80
|
xero_client ||= XeroRuby::ApiClient.new(credentials: creds)
|
67
81
|
```
|
68
82
|
|
69
|
-
|
70
|
-
|
83
|
+
For additional [config](/lib/xero-ruby/configuration.rb) options you can pass an optional named parameter `config: {}`
|
84
|
+
```ruby
|
85
|
+
config = { timeout: 30, debugging: true }
|
86
|
+
@xero_client ||= XeroRuby::ApiClient.new(credentials: creds, config: config)
|
87
|
+
```
|
88
|
+
---
|
89
|
+
## Authentication
|
90
|
+
All API requests go through Xero's OAuth2.0 gateway and require a valid `access_token` to be set on the `xero_client`, which autmoatically appends the `access_token` [JWT](https://jwt.io/) to the header of each request.
|
91
|
+
|
92
|
+
If you are making an API call for the first time:
|
71
93
|
|
72
|
-
|
94
|
+
1. Send the user to the Xero authorization URL
|
73
95
|
```ruby
|
74
96
|
@authorization_url = xero_client.authorization_url
|
75
|
-
|
76
97
|
redirect_to @authorization_url
|
77
98
|
```
|
78
|
-
|
79
|
-
Xero will then redirect back to the URI defined in your ENV['REDIRECT_URI'] variable.
|
80
|
-
*This must match **exactly** with the variable in your /myapps dashboard.*
|
81
|
-
|
82
|
-
In your callback route catch, calling `get_token_set_from_callback` will exchange the temp code in your params, with a valid `token_set` that you can use to make API calls.
|
99
|
+
2. The user will authorize your API application and be sent to your `redirect_uri`
|
83
100
|
```ruby
|
84
|
-
|
85
|
-
|
86
|
-
token_set = xero_client.get_token_set_from_callback(params)
|
87
|
-
|
88
|
-
# save token_set JSON in a datastore in relation to the user authentication
|
101
|
+
ENV['REDIRECT_URI']
|
102
|
+
=> /xero-callback?code=xyz123
|
89
103
|
```
|
90
|
-
|
91
|
-
## Making API calls once you have a token_set
|
92
|
-
For use outside of the initial auth flow, setup the client by passing the whole token_set to `refresh_token_set` or `set_token_set`.
|
104
|
+
3. You exchange a temporary `authorization_code` for a valid `token_set`
|
93
105
|
```ruby
|
94
|
-
xero_client.
|
95
|
-
|
96
|
-
xero_client.set_token_set(user.token_set)
|
106
|
+
@token_set = @xero_client.get_token_set_from_callback(params)
|
107
|
+
# save the @token_set
|
97
108
|
```
|
98
|
-
A `token_set` contains data about your API connection most importantly :
|
99
|
-
* `access_token`
|
100
|
-
* `refresh_token`
|
101
|
-
* `expiry`
|
102
109
|
|
103
|
-
|
110
|
+
It is reccomended that you store this token set JSON in a datastore in relation to the user who has authenticated the Xero API connection. Each time you want to call the Xero API, you will need to access the previously generated token set, initialize it on the SDK `xero_client`, and refresh the `access_token` prior to making API calls.
|
111
|
+
|
112
|
+
### Token Set
|
113
|
+
| key | value | description |
|
114
|
+
| --- | --- | --- |
|
115
|
+
| id_token: | "xxx.yyy.zzz" | [OpenID Connect](https://openid.net/connect/) token returned if `openid profile email` scopes accepted |
|
116
|
+
| access_token: | "xxx.yyy.zzz" | [Bearer token](https://oauth.net/2/jwt/) with a 30 minute expiration required for all API calls |
|
117
|
+
| expires_in: | 1800 | Time in seconds till the token expires - 1800s is 30m |
|
118
|
+
| refresh_token: | "XXXXXXX" | Alphanumeric string used to obtain a new Token Set w/ a fresh access_token - 60 day expiry |
|
119
|
+
| scope: | "email profile openid accounting.transactions offline_access" | The Xero permissions that are embedded in the `access_token` |
|
104
120
|
|
105
|
-
Example Token
|
106
|
-
|
107
|
-
```json
|
121
|
+
Example Token Set JSON:
|
122
|
+
```
|
108
123
|
{
|
109
124
|
"id_token": "xxx.yyy.zz",
|
110
125
|
"access_token": "xxx.yyy.zzz",
|
111
126
|
"expires_in": 1800,
|
112
127
|
"token_type": "Bearer",
|
113
|
-
"refresh_token": "
|
128
|
+
"refresh_token": "xxxxxxxxx",
|
114
129
|
"scope": "email profile openid accounting.transactions offline_access"
|
115
130
|
}
|
116
131
|
```
|
132
|
+
---
|
133
|
+
## Custom Connections
|
134
|
+
|
135
|
+
Custom Connections are a Xero [premium option](https://developer.xero.com/documentation/oauth2/custom-connections) used for building M2M integrations to a single organisation. A custom connection uses OAuth2.0's [`client_credentials`](https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/) grant which eliminates the step of exchanging the temporary code for a token set.
|
117
136
|
|
118
|
-
|
119
|
-
Refresh/connection helpers
|
137
|
+
To use this SDK with a Custom Connections:
|
120
138
|
```ruby
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
"createdDateUtc" => "2019-11-01T20:08:03.0766400",
|
134
|
-
"updatedDateUtc" => "2020-04-15T22:37:10.4943410"
|
135
|
-
}]
|
136
|
-
|
137
|
-
# disconnect an org from a user's connections. Pass the connection ['id'] not ['tenantId'].
|
138
|
-
# Useful if you want to enforce only a single org connection per token.
|
139
|
-
remaining_connections = xero_client.disconnect(connections[0]['id'])
|
140
|
-
|
141
|
-
# set a refreshed token_set
|
142
|
-
token_set = xero_client.set_token_set(user.token_set)
|
143
|
-
|
144
|
-
# access token_set once it is set on the client
|
145
|
-
token_set = xero_client.token_set
|
139
|
+
CREDENTIALS = {
|
140
|
+
client_id: ENV['CLIENT_ID'],
|
141
|
+
client_secret: ENV['CLIENT_SECRET'],
|
142
|
+
grant_type: 'client_credentials'
|
143
|
+
}
|
144
|
+
|
145
|
+
xero_client = XeroRuby::ApiClient.new(credentials: CREDENTIALS)
|
146
|
+
|
147
|
+
@token_set = xero_client.get_client_credentials_token
|
148
|
+
# save @token_set
|
149
|
+
|
150
|
+
@invoices = xero_client.accounting_api.get_invoices('').invoices
|
146
151
|
```
|
147
152
|
|
148
|
-
|
153
|
+
Because Custom Connections are only valid for a single organisation you don't need to pass the `xero-tenant-id` as the first parameter to every method.
|
154
|
+
|
155
|
+
However - due to the nature of how our SDK's are generated from our OpenAPI spec, the parameter remains which requires you to pass an empty string for now to use the SDK with a Custom Connection.
|
156
|
+
|
157
|
+
---
|
158
|
+
## API Clients
|
159
|
+
You can access the different API sets and their available methods through the following:
|
160
|
+
|
149
161
|
```ruby
|
150
|
-
|
162
|
+
xero_client = XeroRuby::ApiClient.new(credentials: creds)
|
163
|
+
|
164
|
+
xero_client.accounting_api
|
165
|
+
xero_client.asset_api
|
166
|
+
xero_client.project_api
|
167
|
+
xero_client.files_api
|
168
|
+
xero_client.payroll_au_api
|
169
|
+
xero_client.payroll_nz_api
|
170
|
+
xero_client.payroll_uk_api
|
171
|
+
```
|
172
|
+
---
|
173
|
+
## Helper Methods
|
151
174
|
|
152
|
-
|
153
|
-
token_expiry = Time.at(decoded_access_token['exp'])
|
154
|
-
token_expiry < Time.now
|
155
|
-
end
|
175
|
+
Once you have a valid Token Set in your datastore, the next time you want to call the Xero API simply initialize a new `xero_client` and refresh the token set.
|
156
176
|
|
157
|
-
|
158
|
-
|
177
|
+
```ruby
|
178
|
+
xero_client = XeroRuby::ApiClient.new(credentials: creds)
|
179
|
+
|
180
|
+
if xero_client.token_expired?
|
181
|
+
@token_set = xero_client.refresh_token_set(user.token_set)
|
182
|
+
else
|
183
|
+
@token_set = xero_client.set_token_set(user.token_set)
|
159
184
|
end
|
160
|
-
```
|
161
185
|
|
162
|
-
|
186
|
+
# example strategy
|
187
|
+
user.token_set = @token_set if !@token_set["error"]
|
188
|
+
user.xero_connections = xero_client.connections
|
189
|
+
user.active_tenant_id = xero_client.last_connection
|
190
|
+
user.save!
|
191
|
+
|
192
|
+
xero_client.accounting_api.get_invoices(xero_client.last_connection['tenantId']).invoices
|
193
|
+
```
|
163
194
|
|
195
|
+
This will set the access_token on the client and return the refreshed `token_set` that you need to save in your datastore to keep the connection alive until you or the user disconnect.
|
196
|
+
|
197
|
+
A full list of the SDK client's methods:
|
198
|
+
|
199
|
+
| method | description |
|
200
|
+
| --- | --- |
|
201
|
+
| xero_client.`authorization_url` | returns the authorize URL string to send a new user to for API authorization |
|
202
|
+
| xero_client.`get_token_set_from_callback`(params) | returns and generates a `token_set` from a temporary code for an `authorization_code` configured client only. Params are the url params. |
|
203
|
+
| xero_client.`get_client_credentials_token` | returns and generates a `token_set` for a `client_credentials` configured client only |
|
204
|
+
| xero_client.`refresh_token_set`(token_set) | returns a refreshed token_set |
|
205
|
+
| xero_client.`revoke_token`(token_set) | removes all a user's org connections and revokes the refresh_token |
|
206
|
+
| xero_client.`disconnect`(connection_id) | disconnects an org connection from a user's token permissions |
|
207
|
+
| xero_client.`connections` | returns an array of the user's currently connected Xero orgs |
|
208
|
+
| xero_client.`last_connection` | returns the `xero-tenant-id` of the most recently connected Xero org |
|
209
|
+
| xero_client.`set_token_set`(token_set) | returns a boolean and sets a token on the client - `token_set` containing an access_token & refresh_token |
|
210
|
+
| xero_client.`set_access_token`(access_token) | How you can set an `access_token` by itself |
|
211
|
+
| xero_client.`set_id_token`(id_token) | How you can set an `id_token` by itself |
|
212
|
+
| xero_client.`token_expired?` | returns a boolean if token_set['access_token'] is expired |
|
213
|
+
| xero_client.`token_set` | returns the token set if one is set on the client |
|
214
|
+
| xero_client.`access_token` | returns the `access_token` if one is set on the client |
|
215
|
+
| xero_client.`id_token` | returns the `id_token` if one is set on the client |
|
216
|
+
| xero_client.`decoded_access_token` | Decoded JWT exposing OAuth2.`0` meta details about the token |
|
217
|
+
| xero_client.`decoded_id_token` | Decoded JWT containing the user meta details that can be used to implement SSO or SSU to Lead |
|
218
|
+
---
|
219
|
+
## Usage Examples
|
164
220
|
### Accounting API
|
165
221
|
```ruby
|
166
222
|
require 'xero-ruby'
|
167
223
|
|
168
|
-
xero_client.refresh_token_set(
|
169
|
-
|
170
|
-
tenant_id = user.active_tenant_id
|
171
|
-
# example of how to store the `tenantId` of the specific tenant (aka organisation)
|
172
|
-
|
173
|
-
# https://github.com/XeroAPI/xero-ruby/blob/master/accounting/lib/xero-ruby/api/accounting_api.rb
|
224
|
+
xero_client.refresh_token_set(user_token_set)
|
225
|
+
tenant_id = xero_client.last_connection
|
174
226
|
|
175
227
|
# Get Accounts
|
176
228
|
accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts
|
@@ -179,6 +231,13 @@ accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts
|
|
179
231
|
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 }]}
|
180
232
|
invoice = xero_client.accounting_api.create_invoices(tenant_id, invoices).invoices.first
|
181
233
|
|
234
|
+
# return data as a snake_case hash
|
235
|
+
puts invoices.to_attributes
|
236
|
+
=> {type: 'ACCREC', line_items: [...]}
|
237
|
+
|
238
|
+
puts invoices.to_hash(downcase: false)
|
239
|
+
=> {'Type': 'ACCREC', 'LineItems': [...]}
|
240
|
+
|
182
241
|
# Create History
|
183
242
|
payment = xero_client.accounting_api.get_payments(tenant_id).payments.first
|
184
243
|
history_records = { history_records: [{ details: "This payment now has some History!" }]}
|
@@ -194,59 +253,9 @@ file = File.read(Rails.root.join('app/assets/images/xero-api.png'))
|
|
194
253
|
attachment = xero_client.accounting_api.create_account_attachment_by_file_name(tenant_id, @account.account_id, file_name, file, opts)
|
195
254
|
```
|
196
255
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
# Create Asset
|
202
|
-
asset = {
|
203
|
-
"assetName": "AssetName: #{rand(10000)}",
|
204
|
-
"assetNumber": "Asset: #{rand(10000)}",
|
205
|
-
"assetStatus": "DRAFT"
|
206
|
-
}
|
207
|
-
asset = xero_client.asset_api.create_asset(tenant_id, asset)
|
208
|
-
```
|
209
|
-
|
210
|
-
### Project API
|
211
|
-
```ruby
|
212
|
-
# https://github.com/XeroAPI/xero-ruby/blob/master/docs/projects/ProjectApi.md
|
213
|
-
|
214
|
-
# Get Projects
|
215
|
-
projects = xero_client.project_api.get_projects(tenant_id).items
|
216
|
-
```
|
217
|
-
|
218
|
-
### Files API
|
219
|
-
```ruby
|
220
|
-
# https://github.com/XeroAPI/xero-ruby/blob/master/docs/files/FileApi.md
|
221
|
-
|
222
|
-
# Get Files
|
223
|
-
opts = {
|
224
|
-
pagesize: 50, # Integer | pass an optional page size value
|
225
|
-
page: 2, # Integer | number of records to skip for pagination
|
226
|
-
sort: 'CreatedDateUTC DESC' # String | values to sort by
|
227
|
-
}
|
228
|
-
|
229
|
-
files = xero_client.files_api.get_files(tenant_id, opts).files
|
230
|
-
```
|
231
|
-
|
232
|
-
### Payroll API(s)
|
233
|
-
```ruby
|
234
|
-
# https://github.com/XeroAPI/xero-ruby/blob/master/docs/payroll_au/PayrollAuApi.md
|
235
|
-
employee_id = 'employee_uuid'
|
236
|
-
employee = xero_client.payroll_au_api.get_employee(tenant_id, employee_id).employee
|
237
|
-
|
238
|
-
|
239
|
-
# https://github.com/XeroAPI/xero-ruby/blob/master/docs/payroll_nz/PayrollNzApi.md
|
240
|
-
timesheet_id = 'timesheeet_uuid'
|
241
|
-
timesheet = xero_client.payroll_nz_api.approve_timesheet(tenant_id, timesheet_id).timesheets
|
242
|
-
|
243
|
-
|
244
|
-
# https://github.com/XeroAPI/xero-ruby/blob/master/docs/payroll_uk/PayrollUkApi.md
|
245
|
-
employee_id = 'employee_uuid'
|
246
|
-
wages = xero_client.payroll_uk_api.get_employee_salary_and_wages(tenant_id, employee_id, opts).salary_and_wages
|
247
|
-
```
|
248
|
-
|
249
|
-
## BigDecimal
|
256
|
+
---
|
257
|
+
## SDK conventions
|
258
|
+
### BigDecimal
|
250
259
|
All monetary and fields and a couple quantity fields utilize BigDecimal
|
251
260
|
```ruby
|
252
261
|
puts invoice.unit_amount
|
@@ -262,8 +271,8 @@ All monetary and fields and a couple quantity fields utilize BigDecimal
|
|
262
271
|
number_to_currency(invoice.unit_amount, :unit => "$")
|
263
272
|
```
|
264
273
|
|
265
|
-
|
266
|
-
Examples for
|
274
|
+
### Querying & Filtering
|
275
|
+
Examples for `opts` (aka _options_) parameters that most endpoints support. If you have a complex filering/sorting/where usage that is not supported please [open an issue](https://github.com/XeroAPI/xero-ruby/issues).
|
267
276
|
```ruby
|
268
277
|
# Invoices
|
269
278
|
opts = {
|
@@ -276,7 +285,7 @@ Examples for the `opts` (_options_) parameters most endpoints support. This is a
|
|
276
285
|
invoice_number: ['=', "INV-0001"],
|
277
286
|
contact_id: ['=', 'contact-uuid-xxxx-xxx-xxxxxxx'],
|
278
287
|
contact_number: ['=', "the-contact-number"],
|
279
|
-
|
288
|
+
date: (DateTime.now - 2.year)..DateTime.now
|
280
289
|
# ▲ you can pass a range ▼ or a date & operator
|
281
290
|
date: ['>=', DateTime.now - 2.year],
|
282
291
|
status: ['=', XeroRuby::Accounting::Invoice::PAID]
|
@@ -291,11 +300,20 @@ opts = {
|
|
291
300
|
order: 'UpdatedDateUtc DESC',
|
292
301
|
where: {
|
293
302
|
is_customer: ['==', true],
|
294
|
-
is_supplier: ['==', true]
|
303
|
+
is_supplier: ['==', true],
|
304
|
+
name: ['StartsWith', 'Rick']
|
295
305
|
}
|
296
306
|
}
|
297
307
|
xero_client.accounting_api.get_contacts(tenant_id, opts).contacts
|
298
308
|
|
309
|
+
# for more complex chained filtering that requires a null check pass those in as a string
|
310
|
+
# see https://developer.xero.com/documentation/api/requests-and-responses for more
|
311
|
+
opts = {
|
312
|
+
where: {
|
313
|
+
email_address: '!=null&&EmailAddress.StartsWith("chris.knight@")'
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
299
317
|
# Bank Transactions
|
300
318
|
opts = {
|
301
319
|
if_modified_since: (DateTime.now - 1.year).to_s,
|
@@ -316,15 +334,48 @@ opts = {
|
|
316
334
|
}
|
317
335
|
xero_client.accounting_api.get_bank_transfers(tenant_id, opts).bank_transfers
|
318
336
|
```
|
319
|
-
### NOTE
|
320
|
-
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.
|
321
337
|
|
322
|
-
|
323
|
-
|
338
|
+
- Not all `opts` parameter combinations are available for all endpoints
|
339
|
+
|
340
|
+
- Some opts string values may need PascalCasing to match casing defined in our [core API docs](https://developer.xero.com/documentation/api/api-overview) like `opts = { order: 'UpdatedDateUtc DESC'}`
|
341
|
+
|
342
|
+
---
|
343
|
+
## Contributing
|
344
|
+
PRs, issues, and discussion are highly appreciated and encouraged. Note that the majority of this project is generated code based on [Xero's OpenAPI specs](https://github.com/XeroAPI/Xero-OpenAPI) - PR's will be evaluated and pre-merge will be incorporated into the root generation templates.
|
345
|
+
|
346
|
+
Please add tests for net new functionality and make existing test suite succeeds.
|
347
|
+
|
348
|
+
`$ rspec spec/`
|
349
|
+
### Versioning
|
350
|
+
We do our best to keep OS industry `semver` standards, but we can make mistakes! If something is not accurately reflected in a version's release notes please let the team know.
|
351
|
+
### Developing locally
|
352
|
+
To develop or test this gem locally against your project we find the following development pattern easiest
|
353
|
+
|
354
|
+
```bash
|
355
|
+
cd xero-ruby
|
356
|
+
gem build
|
357
|
+
mv xero-ruby-<vsn>.gem xero-ruby.gem
|
358
|
+
pwd
|
359
|
+
=> /Users/your.user/code/sdks/xero-ruby/
|
360
|
+
|
361
|
+
cd ..
|
362
|
+
cd xero-ruby-oauth2-app/
|
363
|
+
|
364
|
+
# xero-ruby-oauth2-app/Gemfile
|
365
|
+
gem 'xero-ruby', path: '/Users/your.user/code/sdks/xero-ruby/'
|
366
|
+
bundle install
|
367
|
+
```
|
368
|
+
|
369
|
+
## Participating in Xero’s developer community
|
370
|
+
|
371
|
+
This SDK is one of a number of SDK’s that the Xero Developer team builds and maintains. We are grateful for all the contributions that the community makes.
|
324
372
|
|
325
|
-
|
373
|
+
Here are a few things you should be aware of as a contributor:
|
374
|
+
* Xero has adopted the Contributor Covenant [Code of Conduct](https://github.com/XeroAPI/xero-ruby/blob/master/CODE_OF_CONDUCT.md), we expect all contributors in our community to adhere to it
|
375
|
+
* If you raise an issue then please make sure to fill out the github issue template, doing so helps us help you
|
376
|
+
* You’re welcome to raise PRs. As our SDKs are generated we may use your code in the core SDK build instead of merging your code
|
377
|
+
* We have a [contribution guide](https://github.com/XeroAPI/xero-ruby/blob/master/CONTRIBUTING.md) for you to follow when contributing to this SDK
|
378
|
+
* Curious about how we generate our SDK’s? Have a [read of our process](https://devblog.xero.com/building-sdks-for-the-future-b79ff726dfd6) and have a look at our [OpenAPISpec](https://github.com/XeroAPI/Xero-OpenAPI)
|
379
|
+
* This software is published under the [MIT License](https://github.com/XeroAPI/xero-ruby/blob/master/LICENSE)
|
326
380
|
|
327
|
-
|
328
|
-
The best resource to understanding how to best leverage this SDK is the sample applications showing all the features of the gem.
|
329
|
-
> https://github.com/XeroAPI/xero-ruby-oauth2-starter (Sinatra - simple getting started)
|
330
|
-
> https://github.com/XeroAPI/xero-ruby-oauth2-app (Rails - full featured examples)
|
381
|
+
For questions that aren’t related to SDKs please refer to our [developer support page](https://developer.xero.com/support/).
|