From bbfc3b0b252d5bccc847d7d8a91d903d1f27958a Mon Sep 17 00:00:00 2001 From: serknight Date: Thu, 6 May 2021 14:20:16 -0600 Subject: [PATCH 1/7] wip --- README.md | 6 +-- docs/accounting/Prepayment.md | 2 + docs/accounting/index.html | 7 +++ lib/xero-ruby/models/accounting/account.rb | 27 ++++++++-- lib/xero-ruby/models/accounting/accounts.rb | 25 +++++++-- .../models/accounting/accounts_payable.rb | 25 +++++++-- .../models/accounting/accounts_receivable.rb | 25 +++++++-- lib/xero-ruby/models/accounting/action.rb | 25 +++++++-- lib/xero-ruby/models/accounting/actions.rb | 25 +++++++-- lib/xero-ruby/models/accounting/address.rb | 25 +++++++-- .../accounting/address_for_organisation.rb | 25 +++++++-- lib/xero-ruby/models/accounting/allocation.rb | 25 +++++++-- .../models/accounting/allocations.rb | 25 +++++++-- lib/xero-ruby/models/accounting/attachment.rb | 25 +++++++-- .../models/accounting/attachments.rb | 25 +++++++-- .../models/accounting/balance_details.rb | 25 +++++++-- lib/xero-ruby/models/accounting/balances.rb | 25 +++++++-- .../models/accounting/bank_transaction.rb | 25 +++++++-- .../models/accounting/bank_transactions.rb | 25 +++++++-- .../models/accounting/bank_transfer.rb | 25 +++++++-- .../models/accounting/bank_transfers.rb | 25 +++++++-- .../models/accounting/batch_payment.rb | 25 +++++++-- .../accounting/batch_payment_details.rb | 25 +++++++-- .../models/accounting/batch_payments.rb | 25 +++++++-- lib/xero-ruby/models/accounting/bill.rb | 25 +++++++-- .../models/accounting/branding_theme.rb | 25 +++++++-- .../models/accounting/branding_themes.rb | 25 +++++++-- .../models/accounting/cis_org_setting.rb | 25 +++++++-- .../models/accounting/cis_org_settings.rb | 25 +++++++-- .../models/accounting/cis_setting.rb | 25 +++++++-- .../models/accounting/cis_settings.rb | 25 +++++++-- lib/xero-ruby/models/accounting/contact.rb | 25 +++++++-- .../models/accounting/contact_group.rb | 25 +++++++-- .../models/accounting/contact_groups.rb | 25 +++++++-- .../models/accounting/contact_person.rb | 25 +++++++-- lib/xero-ruby/models/accounting/contacts.rb | 25 +++++++-- .../models/accounting/conversion_balances.rb | 25 +++++++-- .../models/accounting/conversion_date.rb | 25 +++++++-- .../models/accounting/credit_note.rb | 25 +++++++-- .../models/accounting/credit_notes.rb | 25 +++++++-- lib/xero-ruby/models/accounting/currencies.rb | 25 +++++++-- lib/xero-ruby/models/accounting/currency.rb | 25 +++++++-- lib/xero-ruby/models/accounting/element.rb | 25 +++++++-- lib/xero-ruby/models/accounting/employee.rb | 25 +++++++-- lib/xero-ruby/models/accounting/employees.rb | 25 +++++++-- lib/xero-ruby/models/accounting/error.rb | 25 +++++++-- .../models/accounting/expense_claim.rb | 25 +++++++-- .../models/accounting/expense_claims.rb | 25 +++++++-- .../models/accounting/external_link.rb | 25 +++++++-- .../models/accounting/history_record.rb | 25 +++++++-- .../models/accounting/history_records.rb | 25 +++++++-- .../models/accounting/import_summary.rb | 25 +++++++-- .../accounting/import_summary_accounts.rb | 25 +++++++-- .../accounting/import_summary_object.rb | 25 +++++++-- .../accounting/import_summary_organisation.rb | 25 +++++++-- lib/xero-ruby/models/accounting/invoice.rb | 25 +++++++-- .../models/accounting/invoice_reminder.rb | 25 +++++++-- .../models/accounting/invoice_reminders.rb | 25 +++++++-- lib/xero-ruby/models/accounting/invoices.rb | 25 +++++++-- lib/xero-ruby/models/accounting/item.rb | 25 +++++++-- lib/xero-ruby/models/accounting/items.rb | 25 +++++++-- lib/xero-ruby/models/accounting/journal.rb | 25 +++++++-- .../models/accounting/journal_line.rb | 25 +++++++-- lib/xero-ruby/models/accounting/journals.rb | 25 +++++++-- lib/xero-ruby/models/accounting/line_item.rb | 25 +++++++-- .../models/accounting/line_item_tracking.rb | 25 +++++++-- .../models/accounting/linked_transaction.rb | 25 +++++++-- .../models/accounting/linked_transactions.rb | 25 +++++++-- .../models/accounting/manual_journal.rb | 25 +++++++-- .../models/accounting/manual_journal_line.rb | 25 +++++++-- .../models/accounting/manual_journals.rb | 25 +++++++-- .../models/accounting/online_invoice.rb | 25 +++++++-- .../models/accounting/online_invoices.rb | 25 +++++++-- .../models/accounting/organisation.rb | 51 +++++++++++++------ .../models/accounting/organisations.rb | 25 +++++++-- .../models/accounting/overpayment.rb | 25 +++++++-- .../models/accounting/overpayments.rb | 25 +++++++-- lib/xero-ruby/models/accounting/payment.rb | 25 +++++++-- .../models/accounting/payment_delete.rb | 25 +++++++-- .../models/accounting/payment_service.rb | 25 +++++++-- .../models/accounting/payment_services.rb | 25 +++++++-- .../models/accounting/payment_term.rb | 25 +++++++-- lib/xero-ruby/models/accounting/payments.rb | 25 +++++++-- lib/xero-ruby/models/accounting/phone.rb | 25 +++++++-- lib/xero-ruby/models/accounting/prepayment.rb | 39 ++++++++++++-- .../models/accounting/prepayments.rb | 25 +++++++-- lib/xero-ruby/models/accounting/purchase.rb | 25 +++++++-- .../models/accounting/purchase_order.rb | 25 +++++++-- .../models/accounting/purchase_orders.rb | 25 +++++++-- lib/xero-ruby/models/accounting/quote.rb | 25 +++++++-- lib/xero-ruby/models/accounting/quotes.rb | 25 +++++++-- lib/xero-ruby/models/accounting/receipt.rb | 25 +++++++-- lib/xero-ruby/models/accounting/receipts.rb | 25 +++++++-- .../models/accounting/repeating_invoice.rb | 25 +++++++-- .../models/accounting/repeating_invoices.rb | 25 +++++++-- lib/xero-ruby/models/accounting/report.rb | 25 +++++++-- .../models/accounting/report_attribute.rb | 25 +++++++-- .../models/accounting/report_cell.rb | 25 +++++++-- .../models/accounting/report_fields.rb | 25 +++++++-- lib/xero-ruby/models/accounting/report_row.rb | 25 +++++++-- .../models/accounting/report_rows.rb | 25 +++++++-- .../models/accounting/report_with_row.rb | 25 +++++++-- .../models/accounting/report_with_rows.rb | 25 +++++++-- lib/xero-ruby/models/accounting/reports.rb | 25 +++++++-- .../models/accounting/request_empty.rb | 25 +++++++-- .../accounting/sales_tracking_category.rb | 25 +++++++-- lib/xero-ruby/models/accounting/schedule.rb | 25 +++++++-- lib/xero-ruby/models/accounting/setup.rb | 25 +++++++-- .../models/accounting/tax_component.rb | 25 +++++++-- lib/xero-ruby/models/accounting/tax_rate.rb | 25 +++++++-- lib/xero-ruby/models/accounting/tax_rates.rb | 25 +++++++-- .../accounting/ten_ninety_nine_contact.rb | 25 +++++++-- .../models/accounting/tracking_categories.rb | 25 +++++++-- .../models/accounting/tracking_category.rb | 25 +++++++-- .../models/accounting/tracking_option.rb | 25 +++++++-- .../models/accounting/tracking_options.rb | 25 +++++++-- lib/xero-ruby/models/accounting/user.rb | 25 +++++++-- lib/xero-ruby/models/accounting/users.rb | 25 +++++++-- .../models/accounting/validation_error.rb | 25 +++++++-- lib/xero-ruby/models/assets/asset.rb | 25 +++++++-- lib/xero-ruby/models/assets/asset_type.rb | 25 +++++++-- lib/xero-ruby/models/assets/assets.rb | 25 +++++++-- .../models/assets/book_depreciation_detail.rb | 25 +++++++-- .../assets/book_depreciation_setting.rb | 25 +++++++-- lib/xero-ruby/models/assets/error.rb | 25 +++++++-- .../assets/field_validation_errors_element.rb | 25 +++++++-- lib/xero-ruby/models/assets/pagination.rb | 25 +++++++-- .../resource_validation_errors_element.rb | 25 +++++++-- lib/xero-ruby/models/assets/setting.rb | 25 +++++++-- lib/xero-ruby/models/files/association.rb | 25 +++++++-- lib/xero-ruby/models/files/file_object.rb | 25 +++++++-- lib/xero-ruby/models/files/files.rb | 25 +++++++-- lib/xero-ruby/models/files/folder.rb | 25 +++++++-- lib/xero-ruby/models/files/folders.rb | 25 +++++++-- lib/xero-ruby/models/files/upload_object.rb | 25 +++++++-- lib/xero-ruby/models/files/user.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/account.rb | 25 +++++++-- .../models/payroll_au/api_exception.rb | 25 +++++++-- .../models/payroll_au/bank_account.rb | 25 +++++++-- .../models/payroll_au/deduction_line.rb | 25 +++++++-- .../models/payroll_au/deduction_type.rb | 25 +++++++-- .../models/payroll_au/earnings_line.rb | 25 +++++++-- .../models/payroll_au/earnings_rate.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/employee.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/employees.rb | 25 +++++++-- .../models/payroll_au/home_address.rb | 25 +++++++-- .../models/payroll_au/leave_accrual_line.rb | 25 +++++++-- .../models/payroll_au/leave_application.rb | 25 +++++++-- .../models/payroll_au/leave_applications.rb | 25 +++++++-- .../models/payroll_au/leave_balance.rb | 25 +++++++-- .../models/payroll_au/leave_earnings_line.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/leave_line.rb | 25 +++++++-- .../models/payroll_au/leave_lines.rb | 25 +++++++-- .../models/payroll_au/leave_period.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/leave_type.rb | 25 +++++++-- .../models/payroll_au/opening_balances.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/pay_item.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/pay_items.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/pay_run.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/pay_runs.rb | 25 +++++++-- .../models/payroll_au/pay_template.rb | 25 +++++++-- .../models/payroll_au/payroll_calendar.rb | 25 +++++++-- .../models/payroll_au/payroll_calendars.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/payslip.rb | 25 +++++++-- .../models/payroll_au/payslip_lines.rb | 25 +++++++-- .../models/payroll_au/payslip_object.rb | 25 +++++++-- .../models/payroll_au/payslip_summary.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/payslips.rb | 25 +++++++-- .../models/payroll_au/reimbursement_line.rb | 25 +++++++-- .../models/payroll_au/reimbursement_lines.rb | 25 +++++++-- .../models/payroll_au/reimbursement_type.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/settings.rb | 25 +++++++-- .../models/payroll_au/settings_object.rb | 25 +++++++-- .../settings_tracking_categories.rb | 25 +++++++-- ...ngs_tracking_categories_employee_groups.rb | 25 +++++++-- ...racking_categories_timesheet_categories.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/super_fund.rb | 25 +++++++-- .../models/payroll_au/super_fund_product.rb | 25 +++++++-- .../models/payroll_au/super_fund_products.rb | 25 +++++++-- .../models/payroll_au/super_funds.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/super_line.rb | 25 +++++++-- .../models/payroll_au/super_membership.rb | 25 +++++++-- .../models/payroll_au/superannuation_line.rb | 25 +++++++-- .../models/payroll_au/tax_declaration.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/tax_line.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/timesheet.rb | 25 +++++++-- .../models/payroll_au/timesheet_line.rb | 25 +++++++-- .../models/payroll_au/timesheet_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_au/timesheets.rb | 25 +++++++-- .../models/payroll_au/validation_error.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/account.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/accounts.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/address.rb | 25 +++++++-- .../models/payroll_nz/bank_account.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/benefit.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/deduction.rb | 25 +++++++-- .../models/payroll_nz/deduction_line.rb | 25 +++++++-- .../models/payroll_nz/deduction_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/deductions.rb | 25 +++++++-- .../models/payroll_nz/earnings_line.rb | 25 +++++++-- .../models/payroll_nz/earnings_order.rb | 25 +++++++-- .../payroll_nz/earnings_order_object.rb | 25 +++++++-- .../models/payroll_nz/earnings_orders.rb | 25 +++++++-- .../models/payroll_nz/earnings_rate.rb | 25 +++++++-- .../models/payroll_nz/earnings_rate_object.rb | 25 +++++++-- .../models/payroll_nz/earnings_rates.rb | 25 +++++++-- .../models/payroll_nz/earnings_template.rb | 25 +++++++-- .../payroll_nz/earnings_template_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/employee.rb | 25 +++++++-- .../payroll_nz/employee_earnings_templates.rb | 25 +++++++-- .../models/payroll_nz/employee_leave.rb | 25 +++++++-- .../payroll_nz/employee_leave_balance.rb | 25 +++++++-- .../payroll_nz/employee_leave_balances.rb | 25 +++++++-- .../payroll_nz/employee_leave_object.rb | 25 +++++++-- .../models/payroll_nz/employee_leave_setup.rb | 25 +++++++-- .../payroll_nz/employee_leave_setup_object.rb | 25 +++++++-- .../models/payroll_nz/employee_leave_type.rb | 25 +++++++-- .../payroll_nz/employee_leave_type_object.rb | 25 +++++++-- .../models/payroll_nz/employee_leave_types.rb | 25 +++++++-- .../models/payroll_nz/employee_leaves.rb | 25 +++++++-- .../models/payroll_nz/employee_object.rb | 25 +++++++-- .../payroll_nz/employee_opening_balance.rb | 25 +++++++-- .../employee_opening_balances_object.rb | 25 +++++++-- .../payroll_nz/employee_pay_template.rb | 25 +++++++-- .../employee_pay_template_object.rb | 25 +++++++-- .../payroll_nz/employee_pay_templates.rb | 25 +++++++-- .../employee_statutory_leave_balance.rb | 25 +++++++-- ...employee_statutory_leave_balance_object.rb | 25 +++++++-- .../employee_statutory_leave_summary.rb | 25 +++++++-- .../employee_statutory_leaves_summaries.rb | 25 +++++++-- .../employee_statutory_sick_leave.rb | 25 +++++++-- .../employee_statutory_sick_leave_object.rb | 25 +++++++-- .../employee_statutory_sick_leaves.rb | 25 +++++++-- .../models/payroll_nz/employee_tax.rb | 25 +++++++-- .../models/payroll_nz/employee_tax_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/employees.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/employment.rb | 25 +++++++-- .../models/payroll_nz/employment_object.rb | 25 +++++++-- .../payroll_nz/gross_earnings_history.rb | 25 +++++++-- .../models/payroll_nz/invalid_field.rb | 25 +++++++-- .../models/payroll_nz/leave_accrual_line.rb | 25 +++++++-- .../models/payroll_nz/leave_earnings_line.rb | 25 +++++++-- .../models/payroll_nz/leave_period.rb | 25 +++++++-- .../models/payroll_nz/leave_periods.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/leave_type.rb | 25 +++++++-- .../models/payroll_nz/leave_type_object.rb | 25 +++++++-- .../models/payroll_nz/leave_types.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/pagination.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/pay_run.rb | 25 +++++++-- .../models/payroll_nz/pay_run_calendar.rb | 25 +++++++-- .../payroll_nz/pay_run_calendar_object.rb | 25 +++++++-- .../models/payroll_nz/pay_run_calendars.rb | 25 +++++++-- .../models/payroll_nz/pay_run_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/pay_runs.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/pay_slip.rb | 25 +++++++-- .../models/payroll_nz/pay_slip_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/pay_slips.rb | 25 +++++++-- .../models/payroll_nz/payment_line.rb | 25 +++++++-- .../models/payroll_nz/payment_method.rb | 25 +++++++-- .../payroll_nz/payment_method_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/problem.rb | 25 +++++++-- .../models/payroll_nz/reimbursement.rb | 25 +++++++-- .../models/payroll_nz/reimbursement_line.rb | 25 +++++++-- .../models/payroll_nz/reimbursement_object.rb | 25 +++++++-- .../models/payroll_nz/reimbursements.rb | 25 +++++++-- .../models/payroll_nz/salary_and_wage.rb | 25 +++++++-- .../payroll_nz/salary_and_wage_object.rb | 25 +++++++-- .../models/payroll_nz/salary_and_wages.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/settings.rb | 25 +++++++-- .../models/payroll_nz/statutory_deduction.rb | 25 +++++++-- .../payroll_nz/statutory_deduction_line.rb | 25 +++++++-- .../payroll_nz/statutory_deduction_object.rb | 25 +++++++-- .../models/payroll_nz/statutory_deductions.rb | 25 +++++++-- .../models/payroll_nz/superannuation_line.rb | 25 +++++++-- .../payroll_nz/superannuation_object.rb | 25 +++++++-- .../models/payroll_nz/superannuations.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/tax_line.rb | 25 +++++++-- .../models/payroll_nz/tax_settings.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/timesheet.rb | 25 +++++++-- .../payroll_nz/timesheet_earnings_line.rb | 25 +++++++-- .../models/payroll_nz/timesheet_line.rb | 25 +++++++-- .../payroll_nz/timesheet_line_object.rb | 25 +++++++-- .../models/payroll_nz/timesheet_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_nz/timesheets.rb | 25 +++++++-- .../models/payroll_nz/tracking_categories.rb | 25 +++++++-- .../models/payroll_nz/tracking_category.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/account.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/accounts.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/address.rb | 25 +++++++-- .../models/payroll_uk/bank_account.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/benefit.rb | 25 +++++++-- .../models/payroll_uk/benefit_line.rb | 25 +++++++-- .../models/payroll_uk/benefit_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/benefits.rb | 25 +++++++-- .../models/payroll_uk/court_order_line.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/deduction.rb | 25 +++++++-- .../models/payroll_uk/deduction_line.rb | 25 +++++++-- .../models/payroll_uk/deduction_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/deductions.rb | 25 +++++++-- .../models/payroll_uk/earnings_line.rb | 25 +++++++-- .../models/payroll_uk/earnings_order.rb | 25 +++++++-- .../payroll_uk/earnings_order_object.rb | 25 +++++++-- .../models/payroll_uk/earnings_orders.rb | 25 +++++++-- .../models/payroll_uk/earnings_rate.rb | 25 +++++++-- .../models/payroll_uk/earnings_rate_object.rb | 25 +++++++-- .../models/payroll_uk/earnings_rates.rb | 25 +++++++-- .../models/payroll_uk/earnings_template.rb | 25 +++++++-- .../payroll_uk/earnings_template_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/employee.rb | 25 +++++++-- .../models/payroll_uk/employee_leave.rb | 25 +++++++-- .../payroll_uk/employee_leave_balance.rb | 25 +++++++-- .../payroll_uk/employee_leave_balances.rb | 25 +++++++-- .../payroll_uk/employee_leave_object.rb | 25 +++++++-- .../models/payroll_uk/employee_leave_type.rb | 25 +++++++-- .../payroll_uk/employee_leave_type_object.rb | 25 +++++++-- .../models/payroll_uk/employee_leave_types.rb | 25 +++++++-- .../models/payroll_uk/employee_leaves.rb | 25 +++++++-- .../models/payroll_uk/employee_object.rb | 25 +++++++-- .../payroll_uk/employee_opening_balances.rb | 25 +++++++-- .../employee_opening_balances_object.rb | 25 +++++++-- .../payroll_uk/employee_pay_template.rb | 25 +++++++-- .../employee_pay_template_object.rb | 25 +++++++-- .../payroll_uk/employee_pay_templates.rb | 25 +++++++-- .../employee_statutory_leave_balance.rb | 25 +++++++-- ...employee_statutory_leave_balance_object.rb | 25 +++++++-- .../employee_statutory_leave_summary.rb | 25 +++++++-- .../employee_statutory_leaves_summaries.rb | 25 +++++++-- .../employee_statutory_sick_leave.rb | 25 +++++++-- .../employee_statutory_sick_leave_object.rb | 25 +++++++-- .../employee_statutory_sick_leaves.rb | 25 +++++++-- .../models/payroll_uk/employee_tax.rb | 25 +++++++-- .../models/payroll_uk/employee_tax_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/employees.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/employment.rb | 25 +++++++-- .../models/payroll_uk/employment_object.rb | 25 +++++++-- .../models/payroll_uk/invalid_field.rb | 25 +++++++-- .../models/payroll_uk/leave_accrual_line.rb | 25 +++++++-- .../models/payroll_uk/leave_earnings_line.rb | 25 +++++++-- .../models/payroll_uk/leave_period.rb | 25 +++++++-- .../models/payroll_uk/leave_periods.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/leave_type.rb | 25 +++++++-- .../models/payroll_uk/leave_type_object.rb | 25 +++++++-- .../models/payroll_uk/leave_types.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/pagination.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/pay_run.rb | 25 +++++++-- .../models/payroll_uk/pay_run_calendar.rb | 25 +++++++-- .../payroll_uk/pay_run_calendar_object.rb | 25 +++++++-- .../models/payroll_uk/pay_run_calendars.rb | 25 +++++++-- .../models/payroll_uk/pay_run_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/pay_runs.rb | 25 +++++++-- .../models/payroll_uk/payment_line.rb | 25 +++++++-- .../models/payroll_uk/payment_method.rb | 25 +++++++-- .../payroll_uk/payment_method_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/payslip.rb | 25 +++++++-- .../models/payroll_uk/payslip_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/payslips.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/problem.rb | 25 +++++++-- .../models/payroll_uk/reimbursement.rb | 25 +++++++-- .../models/payroll_uk/reimbursement_line.rb | 25 +++++++-- .../models/payroll_uk/reimbursement_object.rb | 25 +++++++-- .../models/payroll_uk/reimbursements.rb | 25 +++++++-- .../models/payroll_uk/salary_and_wage.rb | 25 +++++++-- .../payroll_uk/salary_and_wage_object.rb | 25 +++++++-- .../models/payroll_uk/salary_and_wages.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/settings.rb | 25 +++++++-- .../models/payroll_uk/statutory_deduction.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/tax_line.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/timesheet.rb | 25 +++++++-- .../payroll_uk/timesheet_earnings_line.rb | 25 +++++++-- .../models/payroll_uk/timesheet_line.rb | 25 +++++++-- .../payroll_uk/timesheet_line_object.rb | 25 +++++++-- .../models/payroll_uk/timesheet_object.rb | 25 +++++++-- lib/xero-ruby/models/payroll_uk/timesheets.rb | 25 +++++++-- .../models/payroll_uk/tracking_categories.rb | 25 +++++++-- .../models/payroll_uk/tracking_category.rb | 25 +++++++-- lib/xero-ruby/models/projects/amount.rb | 25 +++++++-- lib/xero-ruby/models/projects/error.rb | 25 +++++++-- lib/xero-ruby/models/projects/pagination.rb | 25 +++++++-- lib/xero-ruby/models/projects/project.rb | 25 +++++++-- .../projects/project_create_or_update.rb | 25 +++++++-- .../models/projects/project_patch.rb | 25 +++++++-- lib/xero-ruby/models/projects/project_user.rb | 25 +++++++-- .../models/projects/project_users.rb | 25 +++++++-- lib/xero-ruby/models/projects/projects.rb | 25 +++++++-- lib/xero-ruby/models/projects/task.rb | 25 +++++++-- .../models/projects/task_create_or_update.rb | 25 +++++++-- lib/xero-ruby/models/projects/tasks.rb | 25 +++++++-- lib/xero-ruby/models/projects/time_entries.rb | 25 +++++++-- lib/xero-ruby/models/projects/time_entry.rb | 25 +++++++-- .../projects/time_entry_create_or_update.rb | 25 +++++++-- lib/xero-ruby/version.rb | 2 +- spec/helper_methods_spec.rb | 28 ++++++++++ 392 files changed, 8582 insertions(+), 1180 deletions(-) diff --git a/README.md b/README.md index 0c7e258b..65719af7 100644 --- a/README.md +++ b/README.md @@ -110,15 +110,15 @@ A `token_set` is what we call the XeroAPI response that contains data about your 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. -Both the `id_token` & `access_token` are JWT's, and can be decoded to see additional metadata described in the Token Helpers section: +Both the `id_token` & `access_token` are JWT's, and can be decoded for to see additional metadata described in the Token Helpers section: ## Making API calls with a valid token_set After the initial user interaction you can simply setup a xero_client by passing the whole token_set to the client. ```ruby xero_client.set_token_set(user.token_set) -# or set it and refresh in same go + xero_client.refresh_token_set(user.token_set) ``` -This sets the access_token on the client returns either the existing, or newly refreshed `token_set`. You should save in your database for the next time you need to connect to Xero's AP and repeat the process. Assuming you keep your connection live at least once per 60 days, you can persist infinite API connection assuming the user does not revoke your API access. +This sets the access_token on the client, and returns a refreshed `token_set` you should save in your database for the next time you need to connect to Xero's API. ## Token Helpers ```ruby xero_client.token_set diff --git a/docs/accounting/Prepayment.md b/docs/accounting/Prepayment.md index 76ee08be..e6bf1c69 100644 --- a/docs/accounting/Prepayment.md +++ b/docs/accounting/Prepayment.md @@ -20,6 +20,7 @@ Name | Type | Description | Notes **currency_rate** | **BigDecimal** | The currency rate for a multicurrency prepayment. If no rate is specified, the XE.com day rate is used | [optional] **remaining_credit** | **BigDecimal** | The remaining credit balance on the prepayment | [optional] **allocations** | [**Array<Allocation>**](Allocation.md) | See Allocations | [optional] +**payments** | [**Array<Payment>**](Payment.md) | See Payments | [optional] **applied_amount** | **Float** | The amount of applied to an invoice | [optional] **has_attachments** | **Boolean** | boolean to indicate if a prepayment has an attachment | [optional] [default to false] **attachments** | [**Array<Attachment>**](Attachment.md) | See Attachments | [optional] @@ -45,6 +46,7 @@ instance = XeroRuby::Accounting::Prepayment.new(type: null, currency_rate: null, remaining_credit: null, allocations: null, + payments: null, applied_amount: 2.0, has_attachments: false, attachments: null) diff --git a/docs/accounting/index.html b/docs/accounting/index.html index 5398fda8..83604201 100644 --- a/docs/accounting/index.html +++ b/docs/accounting/index.html @@ -4372,6 +4372,13 @@ "$ref" : "#/components/schemas/Allocation" } }, + "Payments" : { + "type" : "array", + "description" : "See Payments", + "items" : { + "$ref" : "#/components/schemas/Payment" + } + }, "AppliedAmount" : { "type" : "number", "description" : "The amount of applied to an invoice", diff --git a/lib/xero-ruby/models/accounting/account.rb b/lib/xero-ruby/models/accounting/account.rb index 36925d2a..94870c30 100644 --- a/lib/xero-ruby/models/accounting/account.rb +++ b/lib/xero-ruby/models/accounting/account.rb @@ -90,7 +90,7 @@ class Account CISLABOURINCOME = "CISLABOURINCOME".freeze CISLIABILITY = "CISLIABILITY".freeze CISMATERIALS = "CISMATERIALS".freeze - # EMPTY = "".freeze + EMPTY = "".freeze # Shown if set attr_accessor :reporting_code @@ -486,10 +486,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -503,16 +506,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/accounts.rb b/lib/xero-ruby/models/accounting/accounts.rb index 2246c705..cc6ccbe8 100644 --- a/lib/xero-ruby/models/accounting/accounts.rb +++ b/lib/xero-ruby/models/accounting/accounts.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/accounts_payable.rb b/lib/xero-ruby/models/accounting/accounts_payable.rb index 3163cf46..7446fa78 100644 --- a/lib/xero-ruby/models/accounting/accounts_payable.rb +++ b/lib/xero-ruby/models/accounting/accounts_payable.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/accounts_receivable.rb b/lib/xero-ruby/models/accounting/accounts_receivable.rb index b770d8bf..cd98484b 100644 --- a/lib/xero-ruby/models/accounting/accounts_receivable.rb +++ b/lib/xero-ruby/models/accounting/accounts_receivable.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/action.rb b/lib/xero-ruby/models/accounting/action.rb index a75d70c1..0e05816f 100644 --- a/lib/xero-ruby/models/accounting/action.rb +++ b/lib/xero-ruby/models/accounting/action.rb @@ -219,10 +219,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -236,16 +239,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/actions.rb b/lib/xero-ruby/models/accounting/actions.rb index 6da8daa2..6989ece1 100644 --- a/lib/xero-ruby/models/accounting/actions.rb +++ b/lib/xero-ruby/models/accounting/actions.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/address.rb b/lib/xero-ruby/models/accounting/address.rb index fe77e538..d2898fd7 100644 --- a/lib/xero-ruby/models/accounting/address.rb +++ b/lib/xero-ruby/models/accounting/address.rb @@ -434,10 +434,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -451,16 +454,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/address_for_organisation.rb b/lib/xero-ruby/models/accounting/address_for_organisation.rb index a06455f6..24cb290b 100644 --- a/lib/xero-ruby/models/accounting/address_for_organisation.rb +++ b/lib/xero-ruby/models/accounting/address_for_organisation.rb @@ -435,10 +435,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -452,16 +455,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/allocation.rb b/lib/xero-ruby/models/accounting/allocation.rb index 4a3f5f8b..aef79db3 100644 --- a/lib/xero-ruby/models/accounting/allocation.rb +++ b/lib/xero-ruby/models/accounting/allocation.rb @@ -260,10 +260,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -277,16 +280,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/allocations.rb b/lib/xero-ruby/models/accounting/allocations.rb index 87aa0135..7c7a987c 100644 --- a/lib/xero-ruby/models/accounting/allocations.rb +++ b/lib/xero-ruby/models/accounting/allocations.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/attachment.rb b/lib/xero-ruby/models/accounting/attachment.rb index 67e85cba..cdd5aa83 100644 --- a/lib/xero-ruby/models/accounting/attachment.rb +++ b/lib/xero-ruby/models/accounting/attachment.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/attachments.rb b/lib/xero-ruby/models/accounting/attachments.rb index ff6f051b..b53bff59 100644 --- a/lib/xero-ruby/models/accounting/attachments.rb +++ b/lib/xero-ruby/models/accounting/attachments.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/balance_details.rb b/lib/xero-ruby/models/accounting/balance_details.rb index 6a4a86a1..7f798838 100644 --- a/lib/xero-ruby/models/accounting/balance_details.rb +++ b/lib/xero-ruby/models/accounting/balance_details.rb @@ -194,10 +194,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -211,16 +214,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/balances.rb b/lib/xero-ruby/models/accounting/balances.rb index cb69582c..a03d18fe 100644 --- a/lib/xero-ruby/models/accounting/balances.rb +++ b/lib/xero-ruby/models/accounting/balances.rb @@ -184,10 +184,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -201,16 +204,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/bank_transaction.rb b/lib/xero-ruby/models/accounting/bank_transaction.rb index bcd696a3..40d735d6 100644 --- a/lib/xero-ruby/models/accounting/bank_transaction.rb +++ b/lib/xero-ruby/models/accounting/bank_transaction.rb @@ -461,10 +461,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -478,16 +481,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/bank_transactions.rb b/lib/xero-ruby/models/accounting/bank_transactions.rb index 36eacd93..17115164 100644 --- a/lib/xero-ruby/models/accounting/bank_transactions.rb +++ b/lib/xero-ruby/models/accounting/bank_transactions.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/bank_transfer.rb b/lib/xero-ruby/models/accounting/bank_transfer.rb index ed72c82b..f21c8673 100644 --- a/lib/xero-ruby/models/accounting/bank_transfer.rb +++ b/lib/xero-ruby/models/accounting/bank_transfer.rb @@ -292,10 +292,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -309,16 +312,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/bank_transfers.rb b/lib/xero-ruby/models/accounting/bank_transfers.rb index 4533e579..9aac21b6 100644 --- a/lib/xero-ruby/models/accounting/bank_transfers.rb +++ b/lib/xero-ruby/models/accounting/bank_transfers.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/batch_payment.rb b/lib/xero-ruby/models/accounting/batch_payment.rb index fee514ac..b66b5335 100644 --- a/lib/xero-ruby/models/accounting/batch_payment.rb +++ b/lib/xero-ruby/models/accounting/batch_payment.rb @@ -447,10 +447,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -464,16 +467,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/batch_payment_details.rb b/lib/xero-ruby/models/accounting/batch_payment_details.rb index 7ecd568c..1f183a6d 100644 --- a/lib/xero-ruby/models/accounting/batch_payment_details.rb +++ b/lib/xero-ruby/models/accounting/batch_payment_details.rb @@ -244,10 +244,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -261,16 +264,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/batch_payments.rb b/lib/xero-ruby/models/accounting/batch_payments.rb index 15fdbca3..e2a791af 100644 --- a/lib/xero-ruby/models/accounting/batch_payments.rb +++ b/lib/xero-ruby/models/accounting/batch_payments.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/bill.rb b/lib/xero-ruby/models/accounting/bill.rb index 04e7bf25..031de03c 100644 --- a/lib/xero-ruby/models/accounting/bill.rb +++ b/lib/xero-ruby/models/accounting/bill.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/branding_theme.rb b/lib/xero-ruby/models/accounting/branding_theme.rb index c5e42695..205abaad 100644 --- a/lib/xero-ruby/models/accounting/branding_theme.rb +++ b/lib/xero-ruby/models/accounting/branding_theme.rb @@ -258,10 +258,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -275,16 +278,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/branding_themes.rb b/lib/xero-ruby/models/accounting/branding_themes.rb index 427a8629..931c6639 100644 --- a/lib/xero-ruby/models/accounting/branding_themes.rb +++ b/lib/xero-ruby/models/accounting/branding_themes.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/cis_org_setting.rb b/lib/xero-ruby/models/accounting/cis_org_setting.rb index bb9404aa..2805dc8a 100644 --- a/lib/xero-ruby/models/accounting/cis_org_setting.rb +++ b/lib/xero-ruby/models/accounting/cis_org_setting.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/cis_org_settings.rb b/lib/xero-ruby/models/accounting/cis_org_settings.rb index e7a7900b..46fea91d 100644 --- a/lib/xero-ruby/models/accounting/cis_org_settings.rb +++ b/lib/xero-ruby/models/accounting/cis_org_settings.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/cis_setting.rb b/lib/xero-ruby/models/accounting/cis_setting.rb index eee32604..b4943a50 100644 --- a/lib/xero-ruby/models/accounting/cis_setting.rb +++ b/lib/xero-ruby/models/accounting/cis_setting.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/cis_settings.rb b/lib/xero-ruby/models/accounting/cis_settings.rb index 80f2406e..64bee938 100644 --- a/lib/xero-ruby/models/accounting/cis_settings.rb +++ b/lib/xero-ruby/models/accounting/cis_settings.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/contact.rb b/lib/xero-ruby/models/accounting/contact.rb index a3900b05..d09722b2 100644 --- a/lib/xero-ruby/models/accounting/contact.rb +++ b/lib/xero-ruby/models/accounting/contact.rb @@ -715,10 +715,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -732,16 +735,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/contact_group.rb b/lib/xero-ruby/models/accounting/contact_group.rb index 84d46d59..675c4b1e 100644 --- a/lib/xero-ruby/models/accounting/contact_group.rb +++ b/lib/xero-ruby/models/accounting/contact_group.rb @@ -241,10 +241,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -258,16 +261,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/contact_groups.rb b/lib/xero-ruby/models/accounting/contact_groups.rb index ae4651b5..1387449a 100644 --- a/lib/xero-ruby/models/accounting/contact_groups.rb +++ b/lib/xero-ruby/models/accounting/contact_groups.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/contact_person.rb b/lib/xero-ruby/models/accounting/contact_person.rb index b2df2129..792a3d78 100644 --- a/lib/xero-ruby/models/accounting/contact_person.rb +++ b/lib/xero-ruby/models/accounting/contact_person.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/contacts.rb b/lib/xero-ruby/models/accounting/contacts.rb index 41ab32af..186d0edb 100644 --- a/lib/xero-ruby/models/accounting/contacts.rb +++ b/lib/xero-ruby/models/accounting/contacts.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/conversion_balances.rb b/lib/xero-ruby/models/accounting/conversion_balances.rb index 2a7ed138..350b9a9d 100644 --- a/lib/xero-ruby/models/accounting/conversion_balances.rb +++ b/lib/xero-ruby/models/accounting/conversion_balances.rb @@ -196,10 +196,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -213,16 +216,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/conversion_date.rb b/lib/xero-ruby/models/accounting/conversion_date.rb index c0502e32..1ab33c61 100644 --- a/lib/xero-ruby/models/accounting/conversion_date.rb +++ b/lib/xero-ruby/models/accounting/conversion_date.rb @@ -184,10 +184,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -201,16 +204,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/credit_note.rb b/lib/xero-ruby/models/accounting/credit_note.rb index 7a54fb73..a548af35 100644 --- a/lib/xero-ruby/models/accounting/credit_note.rb +++ b/lib/xero-ruby/models/accounting/credit_note.rb @@ -531,10 +531,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -548,16 +551,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/credit_notes.rb b/lib/xero-ruby/models/accounting/credit_notes.rb index 40d3d457..d19d5d52 100644 --- a/lib/xero-ruby/models/accounting/credit_notes.rb +++ b/lib/xero-ruby/models/accounting/credit_notes.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/currencies.rb b/lib/xero-ruby/models/accounting/currencies.rb index 3c99e180..fae22dd4 100644 --- a/lib/xero-ruby/models/accounting/currencies.rb +++ b/lib/xero-ruby/models/accounting/currencies.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/currency.rb b/lib/xero-ruby/models/accounting/currency.rb index 50fc9552..d9184b23 100644 --- a/lib/xero-ruby/models/accounting/currency.rb +++ b/lib/xero-ruby/models/accounting/currency.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/element.rb b/lib/xero-ruby/models/accounting/element.rb index 36a49dc7..3e16fd60 100644 --- a/lib/xero-ruby/models/accounting/element.rb +++ b/lib/xero-ruby/models/accounting/element.rb @@ -245,10 +245,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -262,16 +265,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/employee.rb b/lib/xero-ruby/models/accounting/employee.rb index 8ea4d3b3..416e2fbc 100644 --- a/lib/xero-ruby/models/accounting/employee.rb +++ b/lib/xero-ruby/models/accounting/employee.rb @@ -313,10 +313,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -330,16 +333,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/employees.rb b/lib/xero-ruby/models/accounting/employees.rb index 153cf6cc..58f551a8 100644 --- a/lib/xero-ruby/models/accounting/employees.rb +++ b/lib/xero-ruby/models/accounting/employees.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/error.rb b/lib/xero-ruby/models/accounting/error.rb index 6906a2f3..2b3652f7 100644 --- a/lib/xero-ruby/models/accounting/error.rb +++ b/lib/xero-ruby/models/accounting/error.rb @@ -205,10 +205,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -222,16 +225,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/expense_claim.rb b/lib/xero-ruby/models/accounting/expense_claim.rb index 9ec895c7..ec8c34a0 100644 --- a/lib/xero-ruby/models/accounting/expense_claim.rb +++ b/lib/xero-ruby/models/accounting/expense_claim.rb @@ -326,10 +326,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -343,16 +346,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/expense_claims.rb b/lib/xero-ruby/models/accounting/expense_claims.rb index 25a67d18..fb31cbf9 100644 --- a/lib/xero-ruby/models/accounting/expense_claims.rb +++ b/lib/xero-ruby/models/accounting/expense_claims.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/external_link.rb b/lib/xero-ruby/models/accounting/external_link.rb index c0759f35..1953c19b 100644 --- a/lib/xero-ruby/models/accounting/external_link.rb +++ b/lib/xero-ruby/models/accounting/external_link.rb @@ -232,10 +232,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -249,16 +252,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/history_record.rb b/lib/xero-ruby/models/accounting/history_record.rb index 052e9bb8..8c210d6d 100644 --- a/lib/xero-ruby/models/accounting/history_record.rb +++ b/lib/xero-ruby/models/accounting/history_record.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/history_records.rb b/lib/xero-ruby/models/accounting/history_records.rb index 2b941a9a..92d0cb27 100644 --- a/lib/xero-ruby/models/accounting/history_records.rb +++ b/lib/xero-ruby/models/accounting/history_records.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/import_summary.rb b/lib/xero-ruby/models/accounting/import_summary.rb index 9f1854ca..22eef7d6 100644 --- a/lib/xero-ruby/models/accounting/import_summary.rb +++ b/lib/xero-ruby/models/accounting/import_summary.rb @@ -184,10 +184,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -201,16 +204,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/import_summary_accounts.rb b/lib/xero-ruby/models/accounting/import_summary_accounts.rb index 9fde513b..d29eb944 100644 --- a/lib/xero-ruby/models/accounting/import_summary_accounts.rb +++ b/lib/xero-ruby/models/accounting/import_summary_accounts.rb @@ -254,10 +254,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -271,16 +274,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/import_summary_object.rb b/lib/xero-ruby/models/accounting/import_summary_object.rb index a8a1bba6..e61291f9 100644 --- a/lib/xero-ruby/models/accounting/import_summary_object.rb +++ b/lib/xero-ruby/models/accounting/import_summary_object.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/import_summary_organisation.rb b/lib/xero-ruby/models/accounting/import_summary_organisation.rb index ec2d5ecd..63e4c34c 100644 --- a/lib/xero-ruby/models/accounting/import_summary_organisation.rb +++ b/lib/xero-ruby/models/accounting/import_summary_organisation.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/invoice.rb b/lib/xero-ruby/models/accounting/invoice.rb index cdfc4d47..ec72c90d 100644 --- a/lib/xero-ruby/models/accounting/invoice.rb +++ b/lib/xero-ruby/models/accounting/invoice.rb @@ -658,10 +658,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -675,16 +678,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/invoice_reminder.rb b/lib/xero-ruby/models/accounting/invoice_reminder.rb index 44cdef69..ed5cd7fa 100644 --- a/lib/xero-ruby/models/accounting/invoice_reminder.rb +++ b/lib/xero-ruby/models/accounting/invoice_reminder.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/invoice_reminders.rb b/lib/xero-ruby/models/accounting/invoice_reminders.rb index 90c74bcf..33e66715 100644 --- a/lib/xero-ruby/models/accounting/invoice_reminders.rb +++ b/lib/xero-ruby/models/accounting/invoice_reminders.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/invoices.rb b/lib/xero-ruby/models/accounting/invoices.rb index 4257ab74..a933c7dc 100644 --- a/lib/xero-ruby/models/accounting/invoices.rb +++ b/lib/xero-ruby/models/accounting/invoices.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/item.rb b/lib/xero-ruby/models/accounting/item.rb index 93713508..0427e697 100644 --- a/lib/xero-ruby/models/accounting/item.rb +++ b/lib/xero-ruby/models/accounting/item.rb @@ -394,10 +394,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -411,16 +414,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/items.rb b/lib/xero-ruby/models/accounting/items.rb index 4de73420..3e2e0811 100644 --- a/lib/xero-ruby/models/accounting/items.rb +++ b/lib/xero-ruby/models/accounting/items.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/journal.rb b/lib/xero-ruby/models/accounting/journal.rb index 016da091..10e17c73 100644 --- a/lib/xero-ruby/models/accounting/journal.rb +++ b/lib/xero-ruby/models/accounting/journal.rb @@ -304,10 +304,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -321,16 +324,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/journal_line.rb b/lib/xero-ruby/models/accounting/journal_line.rb index 584d324a..918c3247 100644 --- a/lib/xero-ruby/models/accounting/journal_line.rb +++ b/lib/xero-ruby/models/accounting/journal_line.rb @@ -285,10 +285,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -302,16 +305,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/journals.rb b/lib/xero-ruby/models/accounting/journals.rb index f54d6fc5..1c13d2c4 100644 --- a/lib/xero-ruby/models/accounting/journals.rb +++ b/lib/xero-ruby/models/accounting/journals.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/line_item.rb b/lib/xero-ruby/models/accounting/line_item.rb index b7f70c16..d442cde2 100644 --- a/lib/xero-ruby/models/accounting/line_item.rb +++ b/lib/xero-ruby/models/accounting/line_item.rb @@ -295,10 +295,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -312,16 +315,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/line_item_tracking.rb b/lib/xero-ruby/models/accounting/line_item_tracking.rb index 84c12f6e..788638a4 100644 --- a/lib/xero-ruby/models/accounting/line_item_tracking.rb +++ b/lib/xero-ruby/models/accounting/line_item_tracking.rb @@ -218,10 +218,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -235,16 +238,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/linked_transaction.rb b/lib/xero-ruby/models/accounting/linked_transaction.rb index c9354637..e338e546 100644 --- a/lib/xero-ruby/models/accounting/linked_transaction.rb +++ b/lib/xero-ruby/models/accounting/linked_transaction.rb @@ -341,10 +341,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -358,16 +361,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/linked_transactions.rb b/lib/xero-ruby/models/accounting/linked_transactions.rb index b024c97e..a9c29705 100644 --- a/lib/xero-ruby/models/accounting/linked_transactions.rb +++ b/lib/xero-ruby/models/accounting/linked_transactions.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/manual_journal.rb b/lib/xero-ruby/models/accounting/manual_journal.rb index 58cdd5b7..8df0bba2 100644 --- a/lib/xero-ruby/models/accounting/manual_journal.rb +++ b/lib/xero-ruby/models/accounting/manual_journal.rb @@ -357,10 +357,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -374,16 +377,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/manual_journal_line.rb b/lib/xero-ruby/models/accounting/manual_journal_line.rb index 74c30841..8d32a09e 100644 --- a/lib/xero-ruby/models/accounting/manual_journal_line.rb +++ b/lib/xero-ruby/models/accounting/manual_journal_line.rb @@ -245,10 +245,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -262,16 +265,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/manual_journals.rb b/lib/xero-ruby/models/accounting/manual_journals.rb index 7881488e..92feb20c 100644 --- a/lib/xero-ruby/models/accounting/manual_journals.rb +++ b/lib/xero-ruby/models/accounting/manual_journals.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/online_invoice.rb b/lib/xero-ruby/models/accounting/online_invoice.rb index 8c3db98d..4c73619f 100644 --- a/lib/xero-ruby/models/accounting/online_invoice.rb +++ b/lib/xero-ruby/models/accounting/online_invoice.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/online_invoices.rb b/lib/xero-ruby/models/accounting/online_invoices.rb index 72abda38..1dfbc69c 100644 --- a/lib/xero-ruby/models/accounting/online_invoices.rb +++ b/lib/xero-ruby/models/accounting/online_invoices.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/organisation.rb b/lib/xero-ruby/models/accounting/organisation.rb index 400aa97e..9d8ac5b1 100644 --- a/lib/xero-ruby/models/accounting/organisation.rb +++ b/lib/xero-ruby/models/accounting/organisation.rb @@ -113,7 +113,7 @@ class Organisation N6_MONTHLY = "6MONTHLY".freeze QUARTERLY = "QUARTERLY".freeze YEARLY = "YEARLY".freeze - # NONE = "NONE".freeze + NONE = "NONE".freeze # The default for LineAmountTypes on sales transactions attr_accessor :default_sales_tax @@ -135,18 +135,18 @@ class Organisation # Organisation Entity Type attr_accessor :organisation_entity_type - # ACCOUNTING_PRACTICE = "ACCOUNTING_PRACTICE".freeze - # COMPANY = "COMPANY".freeze - # CHARITY = "CHARITY".freeze - # CLUB_OR_SOCIETY = "CLUB_OR_SOCIETY".freeze - # LOOK_THROUGH_COMPANY = "LOOK_THROUGH_COMPANY".freeze - # NOT_FOR_PROFIT = "NOT_FOR_PROFIT".freeze - # PARTNERSHIP = "PARTNERSHIP".freeze - # S_CORPORATION = "S_CORPORATION".freeze - # SELF_MANAGED_SUPERANNUATION_FUND = "SELF_MANAGED_SUPERANNUATION_FUND".freeze - # SOLE_TRADER = "SOLE_TRADER".freeze - # SUPERANNUATION_FUND = "SUPERANNUATION_FUND".freeze - # TRUST = "TRUST".freeze + ACCOUNTING_PRACTICE = "ACCOUNTING_PRACTICE".freeze + COMPANY = "COMPANY".freeze + CHARITY = "CHARITY".freeze + CLUB_OR_SOCIETY = "CLUB_OR_SOCIETY".freeze + LOOK_THROUGH_COMPANY = "LOOK_THROUGH_COMPANY".freeze + NOT_FOR_PROFIT = "NOT_FOR_PROFIT".freeze + PARTNERSHIP = "PARTNERSHIP".freeze + S_CORPORATION = "S_CORPORATION".freeze + SELF_MANAGED_SUPERANNUATION_FUND = "SELF_MANAGED_SUPERANNUATION_FUND".freeze + SOLE_TRADER = "SOLE_TRADER".freeze + SUPERANNUATION_FUND = "SUPERANNUATION_FUND".freeze + TRUST = "TRUST".freeze # A unique identifier for the organisation. Potential uses. attr_accessor :short_code @@ -675,10 +675,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -692,16 +695,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/organisations.rb b/lib/xero-ruby/models/accounting/organisations.rb index d7a3c025..09509265 100644 --- a/lib/xero-ruby/models/accounting/organisations.rb +++ b/lib/xero-ruby/models/accounting/organisations.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/overpayment.rb b/lib/xero-ruby/models/accounting/overpayment.rb index 527146b6..baed90ef 100644 --- a/lib/xero-ruby/models/accounting/overpayment.rb +++ b/lib/xero-ruby/models/accounting/overpayment.rb @@ -415,10 +415,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -432,16 +435,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/overpayments.rb b/lib/xero-ruby/models/accounting/overpayments.rb index 1ac54a6d..f742b70d 100644 --- a/lib/xero-ruby/models/accounting/overpayments.rb +++ b/lib/xero-ruby/models/accounting/overpayments.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/payment.rb b/lib/xero-ruby/models/accounting/payment.rb index e42e6626..65f7cf07 100644 --- a/lib/xero-ruby/models/accounting/payment.rb +++ b/lib/xero-ruby/models/accounting/payment.rb @@ -475,10 +475,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -492,16 +495,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/payment_delete.rb b/lib/xero-ruby/models/accounting/payment_delete.rb index 37be29ee..78232500 100644 --- a/lib/xero-ruby/models/accounting/payment_delete.rb +++ b/lib/xero-ruby/models/accounting/payment_delete.rb @@ -180,10 +180,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -197,16 +200,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/payment_service.rb b/lib/xero-ruby/models/accounting/payment_service.rb index 0a681d7b..0e128caf 100644 --- a/lib/xero-ruby/models/accounting/payment_service.rb +++ b/lib/xero-ruby/models/accounting/payment_service.rb @@ -225,10 +225,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -242,16 +245,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/payment_services.rb b/lib/xero-ruby/models/accounting/payment_services.rb index 6d4be0c5..3fb227b1 100644 --- a/lib/xero-ruby/models/accounting/payment_services.rb +++ b/lib/xero-ruby/models/accounting/payment_services.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/payment_term.rb b/lib/xero-ruby/models/accounting/payment_term.rb index bebc7be8..0f0d8ceb 100644 --- a/lib/xero-ruby/models/accounting/payment_term.rb +++ b/lib/xero-ruby/models/accounting/payment_term.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/payments.rb b/lib/xero-ruby/models/accounting/payments.rb index 8f861d4c..5119adf8 100644 --- a/lib/xero-ruby/models/accounting/payments.rb +++ b/lib/xero-ruby/models/accounting/payments.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/phone.rb b/lib/xero-ruby/models/accounting/phone.rb index ebf42784..334efc68 100644 --- a/lib/xero-ruby/models/accounting/phone.rb +++ b/lib/xero-ruby/models/accounting/phone.rb @@ -287,10 +287,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -304,16 +307,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/prepayment.rb b/lib/xero-ruby/models/accounting/prepayment.rb index 0ceeedf5..9a12adea 100644 --- a/lib/xero-ruby/models/accounting/prepayment.rb +++ b/lib/xero-ruby/models/accounting/prepayment.rb @@ -71,6 +71,9 @@ class Prepayment # See Allocations attr_accessor :allocations + # See Payments + attr_accessor :payments + # The amount of applied to an invoice attr_accessor :applied_amount @@ -121,6 +124,7 @@ def self.attribute_map :'currency_rate' => :'CurrencyRate', :'remaining_credit' => :'RemainingCredit', :'allocations' => :'Allocations', + :'payments' => :'Payments', :'applied_amount' => :'AppliedAmount', :'has_attachments' => :'HasAttachments', :'attachments' => :'Attachments' @@ -146,6 +150,7 @@ def self.openapi_types :'currency_rate' => :'BigDecimal', :'remaining_credit' => :'BigDecimal', :'allocations' => :'Array', + :'payments' => :'Array', :'applied_amount' => :'Float', :'has_attachments' => :'Boolean', :'attachments' => :'Array' @@ -235,6 +240,12 @@ def initialize(attributes = {}) end end + if attributes.key?(:'payments') + if (value = attributes[:'payments']).is_a?(Array) + self.payments = value + end + end + if attributes.key?(:'applied_amount') self.applied_amount = attributes[:'applied_amount'] end @@ -310,6 +321,7 @@ def ==(o) currency_rate == o.currency_rate && remaining_credit == o.remaining_credit && allocations == o.allocations && + payments == o.payments && applied_amount == o.applied_amount && has_attachments == o.has_attachments && attachments == o.attachments @@ -324,7 +336,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [type, contact, date, status, line_amount_types, line_items, sub_total, total_tax, total, reference, updated_date_utc, currency_code, prepayment_id, currency_rate, remaining_credit, allocations, applied_amount, has_attachments, attachments].hash + [type, contact, date, status, line_amount_types, line_items, sub_total, total_tax, total, reference, updated_date_utc, currency_code, prepayment_id, currency_rate, remaining_credit, allocations, payments, applied_amount, has_attachments, attachments].hash end # Builds the object from hash @@ -414,10 +426,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -431,16 +446,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/prepayments.rb b/lib/xero-ruby/models/accounting/prepayments.rb index badcc6e4..ae49e1ee 100644 --- a/lib/xero-ruby/models/accounting/prepayments.rb +++ b/lib/xero-ruby/models/accounting/prepayments.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/purchase.rb b/lib/xero-ruby/models/accounting/purchase.rb index 931b6688..00184199 100644 --- a/lib/xero-ruby/models/accounting/purchase.rb +++ b/lib/xero-ruby/models/accounting/purchase.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/purchase_order.rb b/lib/xero-ruby/models/accounting/purchase_order.rb index 035e912a..509ed805 100644 --- a/lib/xero-ruby/models/accounting/purchase_order.rb +++ b/lib/xero-ruby/models/accounting/purchase_order.rb @@ -492,10 +492,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -509,16 +512,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/purchase_orders.rb b/lib/xero-ruby/models/accounting/purchase_orders.rb index bff3f822..eed42358 100644 --- a/lib/xero-ruby/models/accounting/purchase_orders.rb +++ b/lib/xero-ruby/models/accounting/purchase_orders.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/quote.rb b/lib/xero-ruby/models/accounting/quote.rb index cca0716d..536817c5 100644 --- a/lib/xero-ruby/models/accounting/quote.rb +++ b/lib/xero-ruby/models/accounting/quote.rb @@ -482,10 +482,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -499,16 +502,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/quotes.rb b/lib/xero-ruby/models/accounting/quotes.rb index b2a6ad42..13110276 100644 --- a/lib/xero-ruby/models/accounting/quotes.rb +++ b/lib/xero-ruby/models/accounting/quotes.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/receipt.rb b/lib/xero-ruby/models/accounting/receipt.rb index 624f6c26..92709a2f 100644 --- a/lib/xero-ruby/models/accounting/receipt.rb +++ b/lib/xero-ruby/models/accounting/receipt.rb @@ -392,10 +392,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -409,16 +412,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/receipts.rb b/lib/xero-ruby/models/accounting/receipts.rb index 7f832dc9..ebbe41aa 100644 --- a/lib/xero-ruby/models/accounting/receipts.rb +++ b/lib/xero-ruby/models/accounting/receipts.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/repeating_invoice.rb b/lib/xero-ruby/models/accounting/repeating_invoice.rb index e9c12f20..a3cfdf88 100644 --- a/lib/xero-ruby/models/accounting/repeating_invoice.rb +++ b/lib/xero-ruby/models/accounting/repeating_invoice.rb @@ -380,10 +380,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -397,16 +400,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/repeating_invoices.rb b/lib/xero-ruby/models/accounting/repeating_invoices.rb index 0809883d..91bff4a2 100644 --- a/lib/xero-ruby/models/accounting/repeating_invoices.rb +++ b/lib/xero-ruby/models/accounting/repeating_invoices.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report.rb b/lib/xero-ruby/models/accounting/report.rb index 49627032..23a4e250 100644 --- a/lib/xero-ruby/models/accounting/report.rb +++ b/lib/xero-ruby/models/accounting/report.rb @@ -270,10 +270,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -287,16 +290,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report_attribute.rb b/lib/xero-ruby/models/accounting/report_attribute.rb index 80db7aa6..cccdcecf 100644 --- a/lib/xero-ruby/models/accounting/report_attribute.rb +++ b/lib/xero-ruby/models/accounting/report_attribute.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report_cell.rb b/lib/xero-ruby/models/accounting/report_cell.rb index e70a75c0..68096849 100644 --- a/lib/xero-ruby/models/accounting/report_cell.rb +++ b/lib/xero-ruby/models/accounting/report_cell.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report_fields.rb b/lib/xero-ruby/models/accounting/report_fields.rb index 08602e6b..64699ae0 100644 --- a/lib/xero-ruby/models/accounting/report_fields.rb +++ b/lib/xero-ruby/models/accounting/report_fields.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report_row.rb b/lib/xero-ruby/models/accounting/report_row.rb index b11c3731..54ea965a 100644 --- a/lib/xero-ruby/models/accounting/report_row.rb +++ b/lib/xero-ruby/models/accounting/report_row.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report_rows.rb b/lib/xero-ruby/models/accounting/report_rows.rb index f029668a..dc94e6d6 100644 --- a/lib/xero-ruby/models/accounting/report_rows.rb +++ b/lib/xero-ruby/models/accounting/report_rows.rb @@ -207,10 +207,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -224,16 +227,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report_with_row.rb b/lib/xero-ruby/models/accounting/report_with_row.rb index c07a1b13..beabd389 100644 --- a/lib/xero-ruby/models/accounting/report_with_row.rb +++ b/lib/xero-ruby/models/accounting/report_with_row.rb @@ -259,10 +259,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -276,16 +279,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/report_with_rows.rb b/lib/xero-ruby/models/accounting/report_with_rows.rb index 6249b452..8419bdac 100644 --- a/lib/xero-ruby/models/accounting/report_with_rows.rb +++ b/lib/xero-ruby/models/accounting/report_with_rows.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/reports.rb b/lib/xero-ruby/models/accounting/reports.rb index 5943a6d8..b3f47c34 100644 --- a/lib/xero-ruby/models/accounting/reports.rb +++ b/lib/xero-ruby/models/accounting/reports.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/request_empty.rb b/lib/xero-ruby/models/accounting/request_empty.rb index 0e34e86a..c07bbcfc 100644 --- a/lib/xero-ruby/models/accounting/request_empty.rb +++ b/lib/xero-ruby/models/accounting/request_empty.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/sales_tracking_category.rb b/lib/xero-ruby/models/accounting/sales_tracking_category.rb index 7717cad3..2acc0bdd 100644 --- a/lib/xero-ruby/models/accounting/sales_tracking_category.rb +++ b/lib/xero-ruby/models/accounting/sales_tracking_category.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/schedule.rb b/lib/xero-ruby/models/accounting/schedule.rb index d0cca239..0cdf5491 100644 --- a/lib/xero-ruby/models/accounting/schedule.rb +++ b/lib/xero-ruby/models/accounting/schedule.rb @@ -287,10 +287,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -304,16 +307,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/setup.rb b/lib/xero-ruby/models/accounting/setup.rb index 6afba808..3f28d1f6 100644 --- a/lib/xero-ruby/models/accounting/setup.rb +++ b/lib/xero-ruby/models/accounting/setup.rb @@ -197,10 +197,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -214,16 +217,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/tax_component.rb b/lib/xero-ruby/models/accounting/tax_component.rb index ff133048..0feef1f5 100644 --- a/lib/xero-ruby/models/accounting/tax_component.rb +++ b/lib/xero-ruby/models/accounting/tax_component.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/tax_rate.rb b/lib/xero-ruby/models/accounting/tax_rate.rb index d864c1bb..d5f8a94c 100644 --- a/lib/xero-ruby/models/accounting/tax_rate.rb +++ b/lib/xero-ruby/models/accounting/tax_rate.rb @@ -409,10 +409,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -426,16 +429,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/tax_rates.rb b/lib/xero-ruby/models/accounting/tax_rates.rb index 9c0558bd..bb3f7a2a 100644 --- a/lib/xero-ruby/models/accounting/tax_rates.rb +++ b/lib/xero-ruby/models/accounting/tax_rates.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb b/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb index 1dcf542d..ab25683f 100644 --- a/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +++ b/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb @@ -383,10 +383,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -400,16 +403,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/tracking_categories.rb b/lib/xero-ruby/models/accounting/tracking_categories.rb index 0d6df319..cd96ad7a 100644 --- a/lib/xero-ruby/models/accounting/tracking_categories.rb +++ b/lib/xero-ruby/models/accounting/tracking_categories.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/tracking_category.rb b/lib/xero-ruby/models/accounting/tracking_category.rb index f5854a22..3fcc5a32 100644 --- a/lib/xero-ruby/models/accounting/tracking_category.rb +++ b/lib/xero-ruby/models/accounting/tracking_category.rb @@ -292,10 +292,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -309,16 +312,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/tracking_option.rb b/lib/xero-ruby/models/accounting/tracking_option.rb index 69ffd470..5605f012 100644 --- a/lib/xero-ruby/models/accounting/tracking_option.rb +++ b/lib/xero-ruby/models/accounting/tracking_option.rb @@ -255,10 +255,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -272,16 +275,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/tracking_options.rb b/lib/xero-ruby/models/accounting/tracking_options.rb index ece4260f..fce6f42b 100644 --- a/lib/xero-ruby/models/accounting/tracking_options.rb +++ b/lib/xero-ruby/models/accounting/tracking_options.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/user.rb b/lib/xero-ruby/models/accounting/user.rb index 8125dc3a..13682a5c 100644 --- a/lib/xero-ruby/models/accounting/user.rb +++ b/lib/xero-ruby/models/accounting/user.rb @@ -274,10 +274,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -291,16 +294,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/users.rb b/lib/xero-ruby/models/accounting/users.rb index da27cc30..c900f0d6 100644 --- a/lib/xero-ruby/models/accounting/users.rb +++ b/lib/xero-ruby/models/accounting/users.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/accounting/validation_error.rb b/lib/xero-ruby/models/accounting/validation_error.rb index 022fa96d..8aae51c2 100644 --- a/lib/xero-ruby/models/accounting/validation_error.rb +++ b/lib/xero-ruby/models/accounting/validation_error.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/asset.rb b/lib/xero-ruby/models/assets/asset.rb index ba70f256..0c36bddb 100644 --- a/lib/xero-ruby/models/assets/asset.rb +++ b/lib/xero-ruby/models/assets/asset.rb @@ -328,10 +328,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -345,16 +348,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/asset_type.rb b/lib/xero-ruby/models/assets/asset_type.rb index 81e6f0c5..f113f5e5 100644 --- a/lib/xero-ruby/models/assets/asset_type.rb +++ b/lib/xero-ruby/models/assets/asset_type.rb @@ -243,10 +243,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -260,16 +263,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/assets.rb b/lib/xero-ruby/models/assets/assets.rb index db6b1e6f..2fe1f935 100644 --- a/lib/xero-ruby/models/assets/assets.rb +++ b/lib/xero-ruby/models/assets/assets.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/book_depreciation_detail.rb b/lib/xero-ruby/models/assets/book_depreciation_detail.rb index dbe961fb..824f8405 100644 --- a/lib/xero-ruby/models/assets/book_depreciation_detail.rb +++ b/lib/xero-ruby/models/assets/book_depreciation_detail.rb @@ -233,10 +233,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -250,16 +253,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/book_depreciation_setting.rb b/lib/xero-ruby/models/assets/book_depreciation_setting.rb index 721c19de..a031ce49 100644 --- a/lib/xero-ruby/models/assets/book_depreciation_setting.rb +++ b/lib/xero-ruby/models/assets/book_depreciation_setting.rb @@ -312,10 +312,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -329,16 +332,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/error.rb b/lib/xero-ruby/models/assets/error.rb index f044f30f..27671a24 100644 --- a/lib/xero-ruby/models/assets/error.rb +++ b/lib/xero-ruby/models/assets/error.rb @@ -217,10 +217,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -234,16 +237,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/field_validation_errors_element.rb b/lib/xero-ruby/models/assets/field_validation_errors_element.rb index d3d7ac45..61e3902c 100644 --- a/lib/xero-ruby/models/assets/field_validation_errors_element.rb +++ b/lib/xero-ruby/models/assets/field_validation_errors_element.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/pagination.rb b/lib/xero-ruby/models/assets/pagination.rb index c3d328e6..608c6186 100644 --- a/lib/xero-ruby/models/assets/pagination.rb +++ b/lib/xero-ruby/models/assets/pagination.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/resource_validation_errors_element.rb b/lib/xero-ruby/models/assets/resource_validation_errors_element.rb index 658d5bad..373644ad 100644 --- a/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +++ b/lib/xero-ruby/models/assets/resource_validation_errors_element.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/assets/setting.rb b/lib/xero-ruby/models/assets/setting.rb index 0b25c4da..d7e0ce69 100644 --- a/lib/xero-ruby/models/assets/setting.rb +++ b/lib/xero-ruby/models/assets/setting.rb @@ -243,10 +243,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -260,16 +263,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/files/association.rb b/lib/xero-ruby/models/files/association.rb index 12941692..adcac9f2 100644 --- a/lib/xero-ruby/models/files/association.rb +++ b/lib/xero-ruby/models/files/association.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/files/file_object.rb b/lib/xero-ruby/models/files/file_object.rb index ece49151..81b6d8e7 100644 --- a/lib/xero-ruby/models/files/file_object.rb +++ b/lib/xero-ruby/models/files/file_object.rb @@ -243,10 +243,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -260,16 +263,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/files/files.rb b/lib/xero-ruby/models/files/files.rb index dc83c7f3..a08a4dde 100644 --- a/lib/xero-ruby/models/files/files.rb +++ b/lib/xero-ruby/models/files/files.rb @@ -205,10 +205,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -222,16 +225,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/files/folder.rb b/lib/xero-ruby/models/files/folder.rb index 26786e96..3c4b3e2b 100644 --- a/lib/xero-ruby/models/files/folder.rb +++ b/lib/xero-ruby/models/files/folder.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/files/folders.rb b/lib/xero-ruby/models/files/folders.rb index f429ebcf..049e2687 100644 --- a/lib/xero-ruby/models/files/folders.rb +++ b/lib/xero-ruby/models/files/folders.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/files/upload_object.rb b/lib/xero-ruby/models/files/upload_object.rb index 2a9611f4..a2871fde 100644 --- a/lib/xero-ruby/models/files/upload_object.rb +++ b/lib/xero-ruby/models/files/upload_object.rb @@ -218,10 +218,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -235,16 +238,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/files/user.rb b/lib/xero-ruby/models/files/user.rb index 2bcdfaca..f4a25f1c 100644 --- a/lib/xero-ruby/models/files/user.rb +++ b/lib/xero-ruby/models/files/user.rb @@ -218,10 +218,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -235,16 +238,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/account.rb b/lib/xero-ruby/models/payroll_au/account.rb index 12ceef4c..618cb4ef 100644 --- a/lib/xero-ruby/models/payroll_au/account.rb +++ b/lib/xero-ruby/models/payroll_au/account.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/api_exception.rb b/lib/xero-ruby/models/payroll_au/api_exception.rb index 283bc35c..ab99aff1 100644 --- a/lib/xero-ruby/models/payroll_au/api_exception.rb +++ b/lib/xero-ruby/models/payroll_au/api_exception.rb @@ -194,10 +194,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -211,16 +214,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/bank_account.rb b/lib/xero-ruby/models/payroll_au/bank_account.rb index 3338f476..e2ce6dcc 100644 --- a/lib/xero-ruby/models/payroll_au/bank_account.rb +++ b/lib/xero-ruby/models/payroll_au/bank_account.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/deduction_line.rb b/lib/xero-ruby/models/payroll_au/deduction_line.rb index 11f77d5d..d23eb297 100644 --- a/lib/xero-ruby/models/payroll_au/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_au/deduction_line.rb @@ -218,10 +218,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -235,16 +238,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/deduction_type.rb b/lib/xero-ruby/models/payroll_au/deduction_type.rb index 04a9c9b1..ea7f830a 100644 --- a/lib/xero-ruby/models/payroll_au/deduction_type.rb +++ b/lib/xero-ruby/models/payroll_au/deduction_type.rb @@ -305,10 +305,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -322,16 +325,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/earnings_line.rb b/lib/xero-ruby/models/payroll_au/earnings_line.rb index 6c7689de..0cbf72cb 100644 --- a/lib/xero-ruby/models/payroll_au/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_au/earnings_line.rb @@ -258,10 +258,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -275,16 +278,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/earnings_rate.rb b/lib/xero-ruby/models/payroll_au/earnings_rate.rb index 12544b44..9f2eea38 100644 --- a/lib/xero-ruby/models/payroll_au/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_au/earnings_rate.rb @@ -363,10 +363,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -380,16 +383,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/employee.rb b/lib/xero-ruby/models/payroll_au/employee.rb index 77ef944d..11513b32 100644 --- a/lib/xero-ruby/models/payroll_au/employee.rb +++ b/lib/xero-ruby/models/payroll_au/employee.rb @@ -536,10 +536,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -553,16 +556,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/employees.rb b/lib/xero-ruby/models/payroll_au/employees.rb index df63a24c..888ed824 100644 --- a/lib/xero-ruby/models/payroll_au/employees.rb +++ b/lib/xero-ruby/models/payroll_au/employees.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/home_address.rb b/lib/xero-ruby/models/payroll_au/home_address.rb index 670fecb5..6ac56f5e 100644 --- a/lib/xero-ruby/models/payroll_au/home_address.rb +++ b/lib/xero-ruby/models/payroll_au/home_address.rb @@ -228,10 +228,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -245,16 +248,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb index 1ece0cd0..65dc3615 100644 --- a/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_application.rb b/lib/xero-ruby/models/payroll_au/leave_application.rb index 1ec41e42..4ca8a4d6 100644 --- a/lib/xero-ruby/models/payroll_au/leave_application.rb +++ b/lib/xero-ruby/models/payroll_au/leave_application.rb @@ -267,10 +267,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -284,16 +287,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_applications.rb b/lib/xero-ruby/models/payroll_au/leave_applications.rb index 65e067c0..29fbb2ee 100644 --- a/lib/xero-ruby/models/payroll_au/leave_applications.rb +++ b/lib/xero-ruby/models/payroll_au/leave_applications.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_balance.rb b/lib/xero-ruby/models/payroll_au/leave_balance.rb index 9f9be4f0..e7ba61a2 100644 --- a/lib/xero-ruby/models/payroll_au/leave_balance.rb +++ b/lib/xero-ruby/models/payroll_au/leave_balance.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb index 4b4cf423..6e814683 100644 --- a/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_line.rb b/lib/xero-ruby/models/payroll_au/leave_line.rb index 91a55849..0b9cab93 100644 --- a/lib/xero-ruby/models/payroll_au/leave_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_line.rb @@ -243,10 +243,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -260,16 +263,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_lines.rb b/lib/xero-ruby/models/payroll_au/leave_lines.rb index 755ed326..0d6566d7 100644 --- a/lib/xero-ruby/models/payroll_au/leave_lines.rb +++ b/lib/xero-ruby/models/payroll_au/leave_lines.rb @@ -176,10 +176,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -193,16 +196,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_period.rb b/lib/xero-ruby/models/payroll_au/leave_period.rb index 16bc9756..37557079 100644 --- a/lib/xero-ruby/models/payroll_au/leave_period.rb +++ b/lib/xero-ruby/models/payroll_au/leave_period.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/leave_type.rb b/lib/xero-ruby/models/payroll_au/leave_type.rb index 83e00c08..95267904 100644 --- a/lib/xero-ruby/models/payroll_au/leave_type.rb +++ b/lib/xero-ruby/models/payroll_au/leave_type.rb @@ -268,10 +268,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -285,16 +288,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/opening_balances.rb b/lib/xero-ruby/models/payroll_au/opening_balances.rb index d91d56db..7143f4e2 100644 --- a/lib/xero-ruby/models/payroll_au/opening_balances.rb +++ b/lib/xero-ruby/models/payroll_au/opening_balances.rb @@ -243,10 +243,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -260,16 +263,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/pay_item.rb b/lib/xero-ruby/models/payroll_au/pay_item.rb index 4a113825..c2627344 100644 --- a/lib/xero-ruby/models/payroll_au/pay_item.rb +++ b/lib/xero-ruby/models/payroll_au/pay_item.rb @@ -211,10 +211,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -228,16 +231,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/pay_items.rb b/lib/xero-ruby/models/payroll_au/pay_items.rb index 6ca1cb92..218ee6a6 100644 --- a/lib/xero-ruby/models/payroll_au/pay_items.rb +++ b/lib/xero-ruby/models/payroll_au/pay_items.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/pay_run.rb b/lib/xero-ruby/models/payroll_au/pay_run.rb index e3ef31d3..b25e348b 100644 --- a/lib/xero-ruby/models/payroll_au/pay_run.rb +++ b/lib/xero-ruby/models/payroll_au/pay_run.rb @@ -332,10 +332,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -349,16 +352,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/pay_runs.rb b/lib/xero-ruby/models/payroll_au/pay_runs.rb index 2029ba62..608381fa 100644 --- a/lib/xero-ruby/models/payroll_au/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_au/pay_runs.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/pay_template.rb b/lib/xero-ruby/models/payroll_au/pay_template.rb index 293ab798..2e49e279 100644 --- a/lib/xero-ruby/models/payroll_au/pay_template.rb +++ b/lib/xero-ruby/models/payroll_au/pay_template.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/payroll_calendar.rb b/lib/xero-ruby/models/payroll_au/payroll_calendar.rb index e9a11392..a9dbc24c 100644 --- a/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +++ b/lib/xero-ruby/models/payroll_au/payroll_calendar.rb @@ -235,10 +235,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -252,16 +255,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/payroll_calendars.rb b/lib/xero-ruby/models/payroll_au/payroll_calendars.rb index 150a6041..ecc0612e 100644 --- a/lib/xero-ruby/models/payroll_au/payroll_calendars.rb +++ b/lib/xero-ruby/models/payroll_au/payroll_calendars.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/payslip.rb b/lib/xero-ruby/models/payroll_au/payslip.rb index b4ae6f8d..60557570 100644 --- a/lib/xero-ruby/models/payroll_au/payslip.rb +++ b/lib/xero-ruby/models/payroll_au/payslip.rb @@ -369,10 +369,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -386,16 +389,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/payslip_lines.rb b/lib/xero-ruby/models/payroll_au/payslip_lines.rb index bf3752f2..f25f702f 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_lines.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_lines.rb @@ -259,10 +259,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -276,16 +279,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/payslip_object.rb b/lib/xero-ruby/models/payroll_au/payslip_object.rb index f373b36d..54494cfb 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_object.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_object.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/payslip_summary.rb b/lib/xero-ruby/models/payroll_au/payslip_summary.rb index 5ba3b3da..eb2963c8 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_summary.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_summary.rb @@ -283,10 +283,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -300,16 +303,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/payslips.rb b/lib/xero-ruby/models/payroll_au/payslips.rb index 6611665a..1bfd932b 100644 --- a/lib/xero-ruby/models/payroll_au/payslips.rb +++ b/lib/xero-ruby/models/payroll_au/payslips.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_line.rb b/lib/xero-ruby/models/payroll_au/reimbursement_line.rb index a75c7b05..665f599e 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_line.rb @@ -218,10 +218,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -235,16 +238,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb b/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb index f5512889..aae30e88 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb @@ -176,10 +176,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -193,16 +196,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_type.rb b/lib/xero-ruby/models/payroll_au/reimbursement_type.rb index 176394fb..1885092d 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_type.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_type.rb @@ -228,10 +228,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -245,16 +248,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/settings.rb b/lib/xero-ruby/models/payroll_au/settings.rb index 04b0a325..46cc3f63 100644 --- a/lib/xero-ruby/models/payroll_au/settings.rb +++ b/lib/xero-ruby/models/payroll_au/settings.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/settings_object.rb b/lib/xero-ruby/models/payroll_au/settings_object.rb index 1fecb691..b93cab34 100644 --- a/lib/xero-ruby/models/payroll_au/settings_object.rb +++ b/lib/xero-ruby/models/payroll_au/settings_object.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb index b8b14fa6..dbb5d33b 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb @@ -184,10 +184,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -201,16 +204,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb index df323652..42a97072 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb @@ -184,10 +184,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -201,16 +204,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb index 15c575b0..0bcbc29a 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb @@ -184,10 +184,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -201,16 +204,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/super_fund.rb b/lib/xero-ruby/models/payroll_au/super_fund.rb index ca566738..dcba8a28 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund.rb @@ -300,10 +300,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -317,16 +320,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/super_fund_product.rb b/lib/xero-ruby/models/payroll_au/super_fund_product.rb index 9525f14e..bece1e46 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund_product.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund_product.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/super_fund_products.rb b/lib/xero-ruby/models/payroll_au/super_fund_products.rb index c69e7c3f..5db66840 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund_products.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund_products.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/super_funds.rb b/lib/xero-ruby/models/payroll_au/super_funds.rb index 44419613..9105881f 100644 --- a/lib/xero-ruby/models/payroll_au/super_funds.rb +++ b/lib/xero-ruby/models/payroll_au/super_funds.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/super_line.rb b/lib/xero-ruby/models/payroll_au/super_line.rb index cfa20baf..dcf00378 100644 --- a/lib/xero-ruby/models/payroll_au/super_line.rb +++ b/lib/xero-ruby/models/payroll_au/super_line.rb @@ -243,10 +243,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -260,16 +263,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/super_membership.rb b/lib/xero-ruby/models/payroll_au/super_membership.rb index 9dc56f37..52dd05c9 100644 --- a/lib/xero-ruby/models/payroll_au/super_membership.rb +++ b/lib/xero-ruby/models/payroll_au/super_membership.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/superannuation_line.rb b/lib/xero-ruby/models/payroll_au/superannuation_line.rb index 42901e88..027626c9 100644 --- a/lib/xero-ruby/models/payroll_au/superannuation_line.rb +++ b/lib/xero-ruby/models/payroll_au/superannuation_line.rb @@ -253,10 +253,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -270,16 +273,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/tax_declaration.rb b/lib/xero-ruby/models/payroll_au/tax_declaration.rb index a75b2a20..55f764ce 100644 --- a/lib/xero-ruby/models/payroll_au/tax_declaration.rb +++ b/lib/xero-ruby/models/payroll_au/tax_declaration.rb @@ -323,10 +323,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -340,16 +343,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/tax_line.rb b/lib/xero-ruby/models/payroll_au/tax_line.rb index 15df9ace..0f3b58c8 100644 --- a/lib/xero-ruby/models/payroll_au/tax_line.rb +++ b/lib/xero-ruby/models/payroll_au/tax_line.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/timesheet.rb b/lib/xero-ruby/models/payroll_au/timesheet.rb index 01560745..f591fe7d 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet.rb @@ -272,10 +272,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -289,16 +292,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/timesheet_line.rb b/lib/xero-ruby/models/payroll_au/timesheet_line.rb index bd908f95..61cefa5d 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet_line.rb @@ -205,10 +205,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -222,16 +225,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/timesheet_object.rb b/lib/xero-ruby/models/payroll_au/timesheet_object.rb index 54ccf676..650d71be 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet_object.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/timesheets.rb b/lib/xero-ruby/models/payroll_au/timesheets.rb index 59266a08..bd8943a0 100644 --- a/lib/xero-ruby/models/payroll_au/timesheets.rb +++ b/lib/xero-ruby/models/payroll_au/timesheets.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_au/validation_error.rb b/lib/xero-ruby/models/payroll_au/validation_error.rb index 57a13379..79380159 100644 --- a/lib/xero-ruby/models/payroll_au/validation_error.rb +++ b/lib/xero-ruby/models/payroll_au/validation_error.rb @@ -173,10 +173,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -190,16 +193,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/account.rb b/lib/xero-ruby/models/payroll_nz/account.rb index 9094c157..ba72c38d 100644 --- a/lib/xero-ruby/models/payroll_nz/account.rb +++ b/lib/xero-ruby/models/payroll_nz/account.rb @@ -241,10 +241,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -258,16 +261,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/accounts.rb b/lib/xero-ruby/models/payroll_nz/accounts.rb index eeacb5a3..71bfda64 100644 --- a/lib/xero-ruby/models/payroll_nz/accounts.rb +++ b/lib/xero-ruby/models/payroll_nz/accounts.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/address.rb b/lib/xero-ruby/models/payroll_nz/address.rb index 5fc9c452..eeabfc80 100644 --- a/lib/xero-ruby/models/payroll_nz/address.rb +++ b/lib/xero-ruby/models/payroll_nz/address.rb @@ -238,10 +238,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -255,16 +258,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/bank_account.rb b/lib/xero-ruby/models/payroll_nz/bank_account.rb index 00dc59df..3d2a5aca 100644 --- a/lib/xero-ruby/models/payroll_nz/bank_account.rb +++ b/lib/xero-ruby/models/payroll_nz/bank_account.rb @@ -294,10 +294,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -311,16 +314,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/benefit.rb b/lib/xero-ruby/models/payroll_nz/benefit.rb index a013e545..b6b3470e 100644 --- a/lib/xero-ruby/models/payroll_nz/benefit.rb +++ b/lib/xero-ruby/models/payroll_nz/benefit.rb @@ -334,10 +334,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -351,16 +354,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/deduction.rb b/lib/xero-ruby/models/payroll_nz/deduction.rb index 8b178a55..89d09790 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction.rb @@ -276,10 +276,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -293,16 +296,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/deduction_line.rb b/lib/xero-ruby/models/payroll_nz/deduction_line.rb index 076af370..e1ca6e4d 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction_line.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/deduction_object.rb b/lib/xero-ruby/models/payroll_nz/deduction_object.rb index b5930085..d21096d8 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction_object.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/deductions.rb b/lib/xero-ruby/models/payroll_nz/deductions.rb index 4d5adcdb..faf4b684 100644 --- a/lib/xero-ruby/models/payroll_nz/deductions.rb +++ b/lib/xero-ruby/models/payroll_nz/deductions.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_line.rb b/lib/xero-ruby/models/payroll_nz/earnings_line.rb index 49150b23..cd7b0f4e 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_line.rb @@ -263,10 +263,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -280,16 +283,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_order.rb b/lib/xero-ruby/models/payroll_nz/earnings_order.rb index 53e68e97..3a2fb9cf 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_order.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_order.rb @@ -220,10 +220,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -237,16 +240,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb index c50eb4e2..bad4e204 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_orders.rb b/lib/xero-ruby/models/payroll_nz/earnings_orders.rb index 62d0d51c..e4a9187f 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_orders.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_orders.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rate.rb b/lib/xero-ruby/models/payroll_nz/earnings_rate.rb index 8c492013..2bd1d0aa 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rate.rb @@ -352,10 +352,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -369,16 +372,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb index 55b41b1e..692b1981 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rates.rb b/lib/xero-ruby/models/payroll_nz/earnings_rates.rb index 75c50624..2a8b5ecf 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rates.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rates.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_template.rb b/lib/xero-ruby/models/payroll_nz/earnings_template.rb index 7c7e87d7..e85044da 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_template.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_template.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb index c0033d29..c452ad6b 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee.rb b/lib/xero-ruby/models/payroll_nz/employee.rb index 06cecb70..1e475944 100644 --- a/lib/xero-ruby/models/payroll_nz/employee.rb +++ b/lib/xero-ruby/models/payroll_nz/employee.rb @@ -339,10 +339,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -356,16 +359,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb b/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb index 14c81e9b..789e1c07 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave.rb b/lib/xero-ruby/models/payroll_nz/employee_leave.rb index 2d13066a..39ee6786 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave.rb @@ -255,10 +255,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -272,16 +275,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb index 6e29e25b..94ca6d5a 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb index c9e266d3..4e5a2de8 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb index 8588b420..b576c6ff 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb index b20c23d0..cc290afd 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb @@ -233,10 +233,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -250,16 +253,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb index b01e76a7..18fb5e00 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb index 1b254645..1eda7d00 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb @@ -301,10 +301,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -318,16 +321,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb index 018438a7..c4002d76 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb index 6823569a..428da280 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leaves.rb b/lib/xero-ruby/models/payroll_nz/employee_leaves.rb index 1fd36d1d..27bbe94b 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leaves.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leaves.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_object.rb b/lib/xero-ruby/models/payroll_nz/employee_object.rb index 742ff58a..35ea774d 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb index f42349df..f41f23fd 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb b/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb index 6feb58a7..2436b235 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb index 88c842c7..3bd2a54b 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb index a698f14f..a3cb6314 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb index 993c03ab..b7244b9b 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb index 5a2b103e..07054914 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb @@ -245,10 +245,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -262,16 +265,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb index 19ea103e..f54475d1 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb index 5846529e..75df15b6 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb @@ -287,10 +287,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -304,16 +307,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb index c53c683e..c3d50f22 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb index 70b8c4eb..e41876c1 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb @@ -384,10 +384,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -401,16 +404,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb index 65bd2e18..4e7aabf5 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb index a2382235..1e74adbc 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_tax.rb b/lib/xero-ruby/models/payroll_nz/employee_tax.rb index 75a6f36a..18bd3504 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_tax.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_tax.rb @@ -362,10 +362,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -379,16 +382,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb b/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb index d139fba2..86996ae0 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employees.rb b/lib/xero-ruby/models/payroll_nz/employees.rb index b6b2d7a4..a0f0209d 100644 --- a/lib/xero-ruby/models/payroll_nz/employees.rb +++ b/lib/xero-ruby/models/payroll_nz/employees.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employment.rb b/lib/xero-ruby/models/payroll_nz/employment.rb index 5cd345a4..bf29d550 100644 --- a/lib/xero-ruby/models/payroll_nz/employment.rb +++ b/lib/xero-ruby/models/payroll_nz/employment.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/employment_object.rb b/lib/xero-ruby/models/payroll_nz/employment_object.rb index 0f569e1a..36a454cb 100644 --- a/lib/xero-ruby/models/payroll_nz/employment_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employment_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb b/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb index f9b2815c..fde0c97d 100644 --- a/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb +++ b/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/invalid_field.rb b/lib/xero-ruby/models/payroll_nz/invalid_field.rb index 37ea9134..2c688c66 100644 --- a/lib/xero-ruby/models/payroll_nz/invalid_field.rb +++ b/lib/xero-ruby/models/payroll_nz/invalid_field.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb index 1eec3ed4..83916f07 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb index 2c90e570..5c7a909a 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb @@ -263,10 +263,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -280,16 +283,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/leave_period.rb b/lib/xero-ruby/models/payroll_nz/leave_period.rb index 433d9715..f25606b8 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_period.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_period.rb @@ -239,10 +239,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -256,16 +259,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/leave_periods.rb b/lib/xero-ruby/models/payroll_nz/leave_periods.rb index 5a5226be..8669fc5c 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_periods.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_periods.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/leave_type.rb b/lib/xero-ruby/models/payroll_nz/leave_type.rb index 34d62615..82a149ee 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_type.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_type.rb @@ -238,10 +238,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -255,16 +258,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/leave_type_object.rb b/lib/xero-ruby/models/payroll_nz/leave_type_object.rb index 4072a9c8..a74e12b5 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_type_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/leave_types.rb b/lib/xero-ruby/models/payroll_nz/leave_types.rb index f941f203..e1f81992 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_types.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_types.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pagination.rb b/lib/xero-ruby/models/payroll_nz/pagination.rb index 78449ce0..6d1e3660 100644 --- a/lib/xero-ruby/models/payroll_nz/pagination.rb +++ b/lib/xero-ruby/models/payroll_nz/pagination.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run.rb b/lib/xero-ruby/models/payroll_nz/pay_run.rb index f391a6d8..56d82c17 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run.rb @@ -336,10 +336,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -353,16 +356,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb index 6c310c91..68b52882 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb @@ -253,10 +253,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -270,16 +273,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb index bb710c68..653bd7e7 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb index 0cc25fa4..e7af0045 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_object.rb b/lib/xero-ruby/models/payroll_nz/pay_run_object.rb index fc52c6c4..74856d27 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_runs.rb b/lib/xero-ruby/models/payroll_nz/pay_runs.rb index 7748da27..a458743d 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_runs.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_slip.rb b/lib/xero-ruby/models/payroll_nz/pay_slip.rb index 89c41ea9..3c625f3b 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slip.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slip.rb @@ -522,10 +522,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -539,16 +542,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb b/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb index ccd7dc5a..c7d1619f 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/pay_slips.rb b/lib/xero-ruby/models/payroll_nz/pay_slips.rb index 5ac905bc..f53a654d 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slips.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slips.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/payment_line.rb b/lib/xero-ruby/models/payroll_nz/payment_line.rb index 489575a9..8bf121ac 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_line.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_line.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/payment_method.rb b/lib/xero-ruby/models/payroll_nz/payment_method.rb index 9317adeb..3929bd9c 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_method.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_method.rb @@ -222,10 +222,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -239,16 +242,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/payment_method_object.rb b/lib/xero-ruby/models/payroll_nz/payment_method_object.rb index 74c81b72..4c1c6166 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_method_object.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_method_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/problem.rb b/lib/xero-ruby/models/payroll_nz/problem.rb index c80528fb..7d69e6f0 100644 --- a/lib/xero-ruby/models/payroll_nz/problem.rb +++ b/lib/xero-ruby/models/payroll_nz/problem.rb @@ -226,10 +226,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -243,16 +246,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement.rb b/lib/xero-ruby/models/payroll_nz/reimbursement.rb index b9182972..7e4898c4 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement.rb @@ -329,10 +329,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -346,16 +349,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb b/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb index b951139b..5f0e2334 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb b/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb index f1477e0b..c115f94a 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursements.rb b/lib/xero-ruby/models/payroll_nz/reimbursements.rb index 97242da4..7a19129d 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursements.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursements.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb index 642fffc3..9267751d 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb @@ -349,10 +349,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -366,16 +369,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb index a2aab654..0d98af8d 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb index 6377983d..3e9b9cc5 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/settings.rb b/lib/xero-ruby/models/payroll_nz/settings.rb index c36fc916..b5b8a31e 100644 --- a/lib/xero-ruby/models/payroll_nz/settings.rb +++ b/lib/xero-ruby/models/payroll_nz/settings.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb index 57ffdf3f..c45f230b 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb index e667d9af..5ce3c33d 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb index fff06bf7..e1e8e306 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb b/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb index 2c7227d2..e1585650 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/superannuation_line.rb b/lib/xero-ruby/models/payroll_nz/superannuation_line.rb index 14e78bc0..f6f66494 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuation_line.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuation_line.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/superannuation_object.rb b/lib/xero-ruby/models/payroll_nz/superannuation_object.rb index 7e387707..31b18d25 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuation_object.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuation_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/superannuations.rb b/lib/xero-ruby/models/payroll_nz/superannuations.rb index b08e8bff..d034f7b4 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuations.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuations.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/tax_line.rb b/lib/xero-ruby/models/payroll_nz/tax_line.rb index 22bc43bf..b46dcaaa 100644 --- a/lib/xero-ruby/models/payroll_nz/tax_line.rb +++ b/lib/xero-ruby/models/payroll_nz/tax_line.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/tax_settings.rb b/lib/xero-ruby/models/payroll_nz/tax_settings.rb index 373ba7f7..17707255 100644 --- a/lib/xero-ruby/models/payroll_nz/tax_settings.rb +++ b/lib/xero-ruby/models/payroll_nz/tax_settings.rb @@ -259,10 +259,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -276,16 +279,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet.rb b/lib/xero-ruby/models/payroll_nz/timesheet.rb index df7ad5f4..4d45c7ee 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet.rb @@ -313,10 +313,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -330,16 +333,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb b/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb index fbecf1f3..d64eea2e 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb @@ -263,10 +263,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -280,16 +283,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_line.rb b/lib/xero-ruby/models/payroll_nz/timesheet_line.rb index fcfe5d2a..df744b48 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_line.rb @@ -228,10 +228,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -245,16 +248,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb b/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb index a08da881..5b98beb9 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_object.rb b/lib/xero-ruby/models/payroll_nz/timesheet_object.rb index e49e3dfa..09083cd6 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/timesheets.rb b/lib/xero-ruby/models/payroll_nz/timesheets.rb index d0d1f769..350e4f5c 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheets.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheets.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/tracking_categories.rb b/lib/xero-ruby/models/payroll_nz/tracking_categories.rb index e0acb995..77f67f1f 100644 --- a/lib/xero-ruby/models/payroll_nz/tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_nz/tracking_categories.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_nz/tracking_category.rb b/lib/xero-ruby/models/payroll_nz/tracking_category.rb index 320f5be8..0831995f 100644 --- a/lib/xero-ruby/models/payroll_nz/tracking_category.rb +++ b/lib/xero-ruby/models/payroll_nz/tracking_category.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/account.rb b/lib/xero-ruby/models/payroll_uk/account.rb index ded14d8c..dcbeea4f 100644 --- a/lib/xero-ruby/models/payroll_uk/account.rb +++ b/lib/xero-ruby/models/payroll_uk/account.rb @@ -244,10 +244,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -261,16 +264,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/accounts.rb b/lib/xero-ruby/models/payroll_uk/accounts.rb index 3852bc30..e80bc298 100644 --- a/lib/xero-ruby/models/payroll_uk/accounts.rb +++ b/lib/xero-ruby/models/payroll_uk/accounts.rb @@ -175,10 +175,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -192,16 +195,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/address.rb b/lib/xero-ruby/models/payroll_uk/address.rb index ed1e50aa..6ed7e923 100644 --- a/lib/xero-ruby/models/payroll_uk/address.rb +++ b/lib/xero-ruby/models/payroll_uk/address.rb @@ -228,10 +228,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -245,16 +248,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/bank_account.rb b/lib/xero-ruby/models/payroll_uk/bank_account.rb index 5619757a..b39c505b 100644 --- a/lib/xero-ruby/models/payroll_uk/bank_account.rb +++ b/lib/xero-ruby/models/payroll_uk/bank_account.rb @@ -208,10 +208,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -225,16 +228,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/benefit.rb b/lib/xero-ruby/models/payroll_uk/benefit.rb index 98421ab0..e876a865 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit.rb @@ -383,10 +383,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -400,16 +403,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/benefit_line.rb b/lib/xero-ruby/models/payroll_uk/benefit_line.rb index 8010805e..4eb62590 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit_line.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit_line.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/benefit_object.rb b/lib/xero-ruby/models/payroll_uk/benefit_object.rb index bffd5518..55a8cd5e 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit_object.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/benefits.rb b/lib/xero-ruby/models/payroll_uk/benefits.rb index db698d83..94744ea4 100644 --- a/lib/xero-ruby/models/payroll_uk/benefits.rb +++ b/lib/xero-ruby/models/payroll_uk/benefits.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/court_order_line.rb b/lib/xero-ruby/models/payroll_uk/court_order_line.rb index 0908752d..c68a367b 100644 --- a/lib/xero-ruby/models/payroll_uk/court_order_line.rb +++ b/lib/xero-ruby/models/payroll_uk/court_order_line.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/deduction.rb b/lib/xero-ruby/models/payroll_uk/deduction.rb index 74620a90..d413a507 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction.rb @@ -391,10 +391,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -408,16 +411,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/deduction_line.rb b/lib/xero-ruby/models/payroll_uk/deduction_line.rb index 60a93d6c..d5ce3c9f 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction_line.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/deduction_object.rb b/lib/xero-ruby/models/payroll_uk/deduction_object.rb index e0ca5de4..d7296f1c 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction_object.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/deductions.rb b/lib/xero-ruby/models/payroll_uk/deductions.rb index 3044686c..951f4e16 100644 --- a/lib/xero-ruby/models/payroll_uk/deductions.rb +++ b/lib/xero-ruby/models/payroll_uk/deductions.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_line.rb b/lib/xero-ruby/models/payroll_uk/earnings_line.rb index b04078f1..0cfe5386 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_line.rb @@ -253,10 +253,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -270,16 +273,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_order.rb b/lib/xero-ruby/models/payroll_uk/earnings_order.rb index 8ae5e1bc..1dc0573f 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_order.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_order.rb @@ -220,10 +220,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -237,16 +240,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb index e0475f97..d3058ab6 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_orders.rb b/lib/xero-ruby/models/payroll_uk/earnings_orders.rb index 902cc0ab..51940cde 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_orders.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_orders.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rate.rb b/lib/xero-ruby/models/payroll_uk/earnings_rate.rb index 8edde5c6..687d3700 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rate.rb @@ -359,10 +359,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -376,16 +379,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb index 676a747d..cb0c1515 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rates.rb b/lib/xero-ruby/models/payroll_uk/earnings_rates.rb index a81b977a..00df91d8 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rates.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rates.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_template.rb b/lib/xero-ruby/models/payroll_uk/earnings_template.rb index 6f5bc9b2..2471be78 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_template.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_template.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb index c42888c8..9c21d72b 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee.rb b/lib/xero-ruby/models/payroll_uk/employee.rb index dcc29f5a..7d2f3489 100644 --- a/lib/xero-ruby/models/payroll_uk/employee.rb +++ b/lib/xero-ruby/models/payroll_uk/employee.rb @@ -349,10 +349,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -366,16 +369,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave.rb b/lib/xero-ruby/models/payroll_uk/employee_leave.rb index 91783a2b..a6117591 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave.rb @@ -255,10 +255,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -272,16 +275,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb index dd372bef..5cb124cc 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb index f414f03a..22634fe2 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb index 8e506ec3..70cd81f2 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb index a25d5b8e..db190d7a 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb @@ -271,10 +271,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -288,16 +291,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb index 955c564c..2750574b 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb index 5c537416..c5798873 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leaves.rb b/lib/xero-ruby/models/payroll_uk/employee_leaves.rb index 8442b090..6e6fb287 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leaves.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leaves.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_object.rb b/lib/xero-ruby/models/payroll_uk/employee_object.rb index 69c8b8a9..c22559fc 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb b/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb index cc52c9e6..ab1c8c0a 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb b/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb index 0ea9d18d..01201105 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb index 19d3cb3e..304d2a10 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb index 56b14294..eaefabca 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb index 977981e8..bceb704b 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb index ffb43d0a..f65da3f1 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb @@ -245,10 +245,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -262,16 +265,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb index 3943ca41..b6438501 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb index 32ef59df..2691006a 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb @@ -287,10 +287,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -304,16 +307,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb index 6a33274d..f778f6cd 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb index ec798f6b..9eba4ebe 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb @@ -384,10 +384,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -401,16 +404,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb index 4b264d0f..b900b026 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb index 82564eda..e0847d27 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_tax.rb b/lib/xero-ruby/models/payroll_uk/employee_tax.rb index aa55c0f5..94a0cb76 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_tax.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_tax.rb @@ -273,10 +273,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -290,16 +293,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb b/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb index 84d29e36..a19311f5 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employees.rb b/lib/xero-ruby/models/payroll_uk/employees.rb index f6d4633d..8b68e4b1 100644 --- a/lib/xero-ruby/models/payroll_uk/employees.rb +++ b/lib/xero-ruby/models/payroll_uk/employees.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employment.rb b/lib/xero-ruby/models/payroll_uk/employment.rb index 834aad7f..556917f6 100644 --- a/lib/xero-ruby/models/payroll_uk/employment.rb +++ b/lib/xero-ruby/models/payroll_uk/employment.rb @@ -245,10 +245,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -262,16 +265,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/employment_object.rb b/lib/xero-ruby/models/payroll_uk/employment_object.rb index 0835b02a..06bfdb6e 100644 --- a/lib/xero-ruby/models/payroll_uk/employment_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employment_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/invalid_field.rb b/lib/xero-ruby/models/payroll_uk/invalid_field.rb index 7ff6632c..1e4ecee2 100644 --- a/lib/xero-ruby/models/payroll_uk/invalid_field.rb +++ b/lib/xero-ruby/models/payroll_uk/invalid_field.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb index 8778bfd7..79f2a900 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb index 250ebf6b..a910e0bb 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/leave_period.rb b/lib/xero-ruby/models/payroll_uk/leave_period.rb index 16d37c89..d442a17a 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_period.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_period.rb @@ -239,10 +239,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -256,16 +259,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/leave_periods.rb b/lib/xero-ruby/models/payroll_uk/leave_periods.rb index 0c8f7c12..6dc2bbed 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_periods.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_periods.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/leave_type.rb b/lib/xero-ruby/models/payroll_uk/leave_type.rb index b3df207f..64a69f91 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_type.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_type.rb @@ -258,10 +258,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -275,16 +278,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/leave_type_object.rb b/lib/xero-ruby/models/payroll_uk/leave_type_object.rb index 819a4cc0..2499a990 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_type_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/leave_types.rb b/lib/xero-ruby/models/payroll_uk/leave_types.rb index a29c9452..9f3787d7 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_types.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_types.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/pagination.rb b/lib/xero-ruby/models/payroll_uk/pagination.rb index 7d5fcbd9..5b9c2515 100644 --- a/lib/xero-ruby/models/payroll_uk/pagination.rb +++ b/lib/xero-ruby/models/payroll_uk/pagination.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run.rb b/lib/xero-ruby/models/payroll_uk/pay_run.rb index b6b7be9e..55931c43 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run.rb @@ -354,10 +354,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -371,16 +374,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb index a47dabcd..c171641f 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb @@ -293,10 +293,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -310,16 +313,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb index 2142c33f..ff4fdb90 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb index a9523a53..98066a9d 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_object.rb b/lib/xero-ruby/models/payroll_uk/pay_run_object.rb index 50e1b3bf..98b61a0a 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_object.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/pay_runs.rb b/lib/xero-ruby/models/payroll_uk/pay_runs.rb index 6307cc5e..4448bc79 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_runs.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/payment_line.rb b/lib/xero-ruby/models/payroll_uk/payment_line.rb index de53d0f1..ed43148e 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_line.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_line.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/payment_method.rb b/lib/xero-ruby/models/payroll_uk/payment_method.rb index 52da2ac7..88f67491 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_method.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_method.rb @@ -227,10 +227,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -244,16 +247,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/payment_method_object.rb b/lib/xero-ruby/models/payroll_uk/payment_method_object.rb index 7aa545e0..3f23b6d0 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_method_object.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_method_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/payslip.rb b/lib/xero-ruby/models/payroll_uk/payslip.rb index d9a8d6e1..6667314e 100644 --- a/lib/xero-ruby/models/payroll_uk/payslip.rb +++ b/lib/xero-ruby/models/payroll_uk/payslip.rb @@ -502,10 +502,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -519,16 +522,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/payslip_object.rb b/lib/xero-ruby/models/payroll_uk/payslip_object.rb index f0cf7fe8..a60d6272 100644 --- a/lib/xero-ruby/models/payroll_uk/payslip_object.rb +++ b/lib/xero-ruby/models/payroll_uk/payslip_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/payslips.rb b/lib/xero-ruby/models/payroll_uk/payslips.rb index f6c50bf4..69c6d346 100644 --- a/lib/xero-ruby/models/payroll_uk/payslips.rb +++ b/lib/xero-ruby/models/payroll_uk/payslips.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/problem.rb b/lib/xero-ruby/models/payroll_uk/problem.rb index 701356c3..99ae890a 100644 --- a/lib/xero-ruby/models/payroll_uk/problem.rb +++ b/lib/xero-ruby/models/payroll_uk/problem.rb @@ -226,10 +226,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -243,16 +246,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement.rb b/lib/xero-ruby/models/payroll_uk/reimbursement.rb index 6cdaf12b..c693d18d 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb b/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb index 77e2b78e..41d3ccee 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb b/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb index 05405f85..5272b89e 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursements.rb b/lib/xero-ruby/models/payroll_uk/reimbursements.rb index 84cb9ff0..c62433aa 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursements.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursements.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb index d7c44c76..7b55fa1c 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb @@ -334,10 +334,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -351,16 +354,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb index f0f8bed4..e11e1f0b 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb index f576bf8e..11816691 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/settings.rb b/lib/xero-ruby/models/payroll_uk/settings.rb index 856cfaa4..148a3c2b 100644 --- a/lib/xero-ruby/models/payroll_uk/settings.rb +++ b/lib/xero-ruby/models/payroll_uk/settings.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb b/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb index e192cfcb..5fafccbb 100644 --- a/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb +++ b/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb @@ -213,10 +213,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -230,16 +233,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/tax_line.rb b/lib/xero-ruby/models/payroll_uk/tax_line.rb index a342adab..7210c0ed 100644 --- a/lib/xero-ruby/models/payroll_uk/tax_line.rb +++ b/lib/xero-ruby/models/payroll_uk/tax_line.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet.rb b/lib/xero-ruby/models/payroll_uk/timesheet.rb index 5663d1fe..878a436e 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet.rb @@ -312,10 +312,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -329,16 +332,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb b/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb index e6166f1f..15e350c9 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb @@ -223,10 +223,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -240,16 +243,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_line.rb b/lib/xero-ruby/models/payroll_uk/timesheet_line.rb index f5853db5..713bd887 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_line.rb @@ -228,10 +228,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -245,16 +248,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb b/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb index 16de01fe..9b6dbe6c 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_object.rb b/lib/xero-ruby/models/payroll_uk/timesheet_object.rb index ab2750df..eaafe5f8 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_object.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/timesheets.rb b/lib/xero-ruby/models/payroll_uk/timesheets.rb index c78a1b10..9cc9bed4 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheets.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheets.rb @@ -195,10 +195,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -212,16 +215,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/tracking_categories.rb b/lib/xero-ruby/models/payroll_uk/tracking_categories.rb index 72e462b4..c5e16843 100644 --- a/lib/xero-ruby/models/payroll_uk/tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_uk/tracking_categories.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/payroll_uk/tracking_category.rb b/lib/xero-ruby/models/payroll_uk/tracking_category.rb index a6b9c09e..a238146e 100644 --- a/lib/xero-ruby/models/payroll_uk/tracking_category.rb +++ b/lib/xero-ruby/models/payroll_uk/tracking_category.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/amount.rb b/lib/xero-ruby/models/projects/amount.rb index e527d4ec..e98a85a4 100644 --- a/lib/xero-ruby/models/projects/amount.rb +++ b/lib/xero-ruby/models/projects/amount.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/error.rb b/lib/xero-ruby/models/projects/error.rb index 6324bcd6..83c69342 100644 --- a/lib/xero-ruby/models/projects/error.rb +++ b/lib/xero-ruby/models/projects/error.rb @@ -183,10 +183,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -200,16 +203,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/pagination.rb b/lib/xero-ruby/models/projects/pagination.rb index fa458c21..6a53b37b 100644 --- a/lib/xero-ruby/models/projects/pagination.rb +++ b/lib/xero-ruby/models/projects/pagination.rb @@ -203,10 +203,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -220,16 +223,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/project.rb b/lib/xero-ruby/models/projects/project.rb index f087071c..2534da12 100644 --- a/lib/xero-ruby/models/projects/project.rb +++ b/lib/xero-ruby/models/projects/project.rb @@ -388,10 +388,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -405,16 +408,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/project_create_or_update.rb b/lib/xero-ruby/models/projects/project_create_or_update.rb index 85341506..dfabfd71 100644 --- a/lib/xero-ruby/models/projects/project_create_or_update.rb +++ b/lib/xero-ruby/models/projects/project_create_or_update.rb @@ -208,10 +208,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -225,16 +228,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/project_patch.rb b/lib/xero-ruby/models/projects/project_patch.rb index 1ee76015..7388ab87 100644 --- a/lib/xero-ruby/models/projects/project_patch.rb +++ b/lib/xero-ruby/models/projects/project_patch.rb @@ -178,10 +178,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -195,16 +198,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/project_user.rb b/lib/xero-ruby/models/projects/project_user.rb index 58324e90..fb047060 100644 --- a/lib/xero-ruby/models/projects/project_user.rb +++ b/lib/xero-ruby/models/projects/project_user.rb @@ -193,10 +193,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -210,16 +213,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/project_users.rb b/lib/xero-ruby/models/projects/project_users.rb index f07b05a8..d56325cb 100644 --- a/lib/xero-ruby/models/projects/project_users.rb +++ b/lib/xero-ruby/models/projects/project_users.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/projects.rb b/lib/xero-ruby/models/projects/projects.rb index 5b2f6c64..d5ac20a2 100644 --- a/lib/xero-ruby/models/projects/projects.rb +++ b/lib/xero-ruby/models/projects/projects.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/task.rb b/lib/xero-ruby/models/projects/task.rb index d382e4f0..7740ecca 100644 --- a/lib/xero-ruby/models/projects/task.rb +++ b/lib/xero-ruby/models/projects/task.rb @@ -350,10 +350,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -367,16 +370,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/task_create_or_update.rb b/lib/xero-ruby/models/projects/task_create_or_update.rb index 01e0dcff..98549073 100644 --- a/lib/xero-ruby/models/projects/task_create_or_update.rb +++ b/lib/xero-ruby/models/projects/task_create_or_update.rb @@ -218,10 +218,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -235,16 +238,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/tasks.rb b/lib/xero-ruby/models/projects/tasks.rb index 2208a996..faab5d9a 100644 --- a/lib/xero-ruby/models/projects/tasks.rb +++ b/lib/xero-ruby/models/projects/tasks.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/time_entries.rb b/lib/xero-ruby/models/projects/time_entries.rb index 43e7a8eb..befa788e 100644 --- a/lib/xero-ruby/models/projects/time_entries.rb +++ b/lib/xero-ruby/models/projects/time_entries.rb @@ -185,10 +185,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -202,16 +205,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/time_entry.rb b/lib/xero-ruby/models/projects/time_entry.rb index 88a4b119..66747a61 100644 --- a/lib/xero-ruby/models/projects/time_entry.rb +++ b/lib/xero-ruby/models/projects/time_entry.rb @@ -290,10 +290,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -307,16 +310,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/models/projects/time_entry_create_or_update.rb b/lib/xero-ruby/models/projects/time_entry_create_or_update.rb index 19f4bd87..8862c503 100644 --- a/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +++ b/lib/xero-ruby/models/projects/time_entry_create_or_update.rb @@ -233,10 +233,13 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| + puts "1 ***********" + puts "attr: #{attr}" + puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value) + hash[key] = _to_hash(value, param, downcase: downcase) end hash end @@ -250,16 +253,32 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value) + def _to_hash(value, param, downcase: false) + puts "2 ***********" + puts "value: #{value}" if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } + puts "2.a ARRAY" + puts "this means its a nested model, right" + value.map do |v| + n = param.length + model_name_without_trailing_s = param[0..n-2] + to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) + puts "to_hash_value.class #{to_hash_value.class}" + puts "to_hash_value #{to_hash_value}" + sleep 1 + to_hash_value + end + # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) + puts "2.b HASH" {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash + puts "2.c respond to hash?" value.to_hash else + puts "2.d just value?" value end end diff --git a/lib/xero-ruby/version.rb b/lib/xero-ruby/version.rb index d81132bb..05a4aeac 100644 --- a/lib/xero-ruby/version.rb +++ b/lib/xero-ruby/version.rb @@ -7,7 +7,7 @@ Generated by: https://openapi-generator.tech OpenAPI Generator version: 4.3.1 -The version of the XeroOpenAPI document: 2.11.0 +The version of the XeroOpenAPI document: 2.11.1 =end module XeroRuby diff --git a/spec/helper_methods_spec.rb b/spec/helper_methods_spec.rb index f7e614eb..731da851 100644 --- a/spec/helper_methods_spec.rb +++ b/spec/helper_methods_spec.rb @@ -59,6 +59,20 @@ ) } + let(:contact_capitalized_with_nested_keys) { + XeroRuby::Accounting::Contact.new({ + has_attachments: false, + has_validation_errors: false, + phones: [ + { + PhoneType: "MOBILE", + PhoneNumber: "555-1212", + PhoneAreaCode: "415" + } + ] + }) + } + describe '#to_hash' do it 'can serialize invoice attributes into a PascalCase hash' do expect(invoice.to_hash).to eq(:CurrencyCode => "USD", :HasAttachments => false, :HasErrors => false, :InvoiceNumber => "abc-123", :TotalDiscount => 100, :Type => "ACCPAY") @@ -77,6 +91,20 @@ it 'can serialize contact attributes into a snake_case hash' do expect(contact.to_attributes).to eq({account_number: "abc-123", contact_status: "ACTIVE", email_address: "email@gmail.com", first_name: 'Contact', has_attachments: false, has_validation_errors: false, last_name: "Name", name: "Contact Name"}) end + + it 'can serialize nested attributes into a snake_case hash' do + expect(contact_capitalized_with_nested_keys.to_attributes).to eq({ + has_attachments: false, + has_validation_errors: false, + phones: [ + { + phone_type: "MOBILE", + phone_number: "555-1212", + phone_area_code: "415" + } + ] + }) + end end end end From 76ff8e2c7017faac776d518d86dc20f55fefbcf0 Mon Sep 17 00:00:00 2001 From: serknight Date: Fri, 7 May 2021 14:58:56 -0600 Subject: [PATCH 2/7] most cases handling for nested sanke serialization --- docs/accounting/AccountingApi.md | 7 ++-- docs/accounting/index.html | 25 +++++++++++-- lib/xero-ruby/api/accounting_api.rb | 7 ++-- lib/xero-ruby/models/accounting/account.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/accounts.rb | 36 ++++++++++--------- .../models/accounting/accounts_payable.rb | 36 ++++++++++--------- .../models/accounting/accounts_receivable.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/action.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/actions.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/address.rb | 36 ++++++++++--------- .../accounting/address_for_organisation.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/allocation.rb | 36 ++++++++++--------- .../models/accounting/allocations.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/attachment.rb | 36 ++++++++++--------- .../models/accounting/attachments.rb | 36 ++++++++++--------- .../models/accounting/balance_details.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/balances.rb | 36 ++++++++++--------- .../models/accounting/bank_transaction.rb | 36 ++++++++++--------- .../models/accounting/bank_transactions.rb | 36 ++++++++++--------- .../models/accounting/bank_transfer.rb | 36 ++++++++++--------- .../models/accounting/bank_transfers.rb | 36 ++++++++++--------- .../models/accounting/batch_payment.rb | 36 ++++++++++--------- .../accounting/batch_payment_details.rb | 36 ++++++++++--------- .../models/accounting/batch_payments.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/bill.rb | 36 ++++++++++--------- .../models/accounting/branding_theme.rb | 36 ++++++++++--------- .../models/accounting/branding_themes.rb | 36 ++++++++++--------- .../models/accounting/cis_org_setting.rb | 36 ++++++++++--------- .../models/accounting/cis_org_settings.rb | 36 ++++++++++--------- .../models/accounting/cis_setting.rb | 36 ++++++++++--------- .../models/accounting/cis_settings.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/contact.rb | 36 ++++++++++--------- .../models/accounting/contact_group.rb | 36 ++++++++++--------- .../models/accounting/contact_groups.rb | 36 ++++++++++--------- .../models/accounting/contact_person.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/contacts.rb | 36 ++++++++++--------- .../models/accounting/conversion_balances.rb | 36 ++++++++++--------- .../models/accounting/conversion_date.rb | 36 ++++++++++--------- .../models/accounting/credit_note.rb | 36 ++++++++++--------- .../models/accounting/credit_notes.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/currencies.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/currency.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/element.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/employee.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/employees.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/error.rb | 36 ++++++++++--------- .../models/accounting/expense_claim.rb | 36 ++++++++++--------- .../models/accounting/expense_claims.rb | 36 ++++++++++--------- .../models/accounting/external_link.rb | 36 ++++++++++--------- .../models/accounting/history_record.rb | 36 ++++++++++--------- .../models/accounting/history_records.rb | 36 ++++++++++--------- .../models/accounting/import_summary.rb | 36 ++++++++++--------- .../accounting/import_summary_accounts.rb | 36 ++++++++++--------- .../accounting/import_summary_object.rb | 36 ++++++++++--------- .../accounting/import_summary_organisation.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/invoice.rb | 36 ++++++++++--------- .../models/accounting/invoice_reminder.rb | 36 ++++++++++--------- .../models/accounting/invoice_reminders.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/invoices.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/item.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/items.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/journal.rb | 36 ++++++++++--------- .../models/accounting/journal_line.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/journals.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/line_item.rb | 36 ++++++++++--------- .../models/accounting/line_item_tracking.rb | 36 ++++++++++--------- .../models/accounting/linked_transaction.rb | 36 ++++++++++--------- .../models/accounting/linked_transactions.rb | 36 ++++++++++--------- .../models/accounting/manual_journal.rb | 36 ++++++++++--------- .../models/accounting/manual_journal_line.rb | 36 ++++++++++--------- .../models/accounting/manual_journals.rb | 36 ++++++++++--------- .../models/accounting/online_invoice.rb | 36 ++++++++++--------- .../models/accounting/online_invoices.rb | 36 ++++++++++--------- .../models/accounting/organisation.rb | 36 ++++++++++--------- .../models/accounting/organisations.rb | 36 ++++++++++--------- .../models/accounting/overpayment.rb | 36 ++++++++++--------- .../models/accounting/overpayments.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/payment.rb | 36 ++++++++++--------- .../models/accounting/payment_delete.rb | 36 ++++++++++--------- .../models/accounting/payment_service.rb | 36 ++++++++++--------- .../models/accounting/payment_services.rb | 36 ++++++++++--------- .../models/accounting/payment_term.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/payments.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/phone.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/prepayment.rb | 36 ++++++++++--------- .../models/accounting/prepayments.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/purchase.rb | 36 ++++++++++--------- .../models/accounting/purchase_order.rb | 36 ++++++++++--------- .../models/accounting/purchase_orders.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/quote.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/quotes.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/receipt.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/receipts.rb | 36 ++++++++++--------- .../models/accounting/repeating_invoice.rb | 36 ++++++++++--------- .../models/accounting/repeating_invoices.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/report.rb | 36 ++++++++++--------- .../models/accounting/report_attribute.rb | 36 ++++++++++--------- .../models/accounting/report_cell.rb | 36 ++++++++++--------- .../models/accounting/report_fields.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/report_row.rb | 36 ++++++++++--------- .../models/accounting/report_rows.rb | 36 ++++++++++--------- .../models/accounting/report_with_row.rb | 36 ++++++++++--------- .../models/accounting/report_with_rows.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/reports.rb | 36 ++++++++++--------- .../models/accounting/request_empty.rb | 36 ++++++++++--------- .../accounting/sales_tracking_category.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/schedule.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/setup.rb | 36 ++++++++++--------- .../models/accounting/tax_component.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/tax_rate.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/tax_rates.rb | 36 ++++++++++--------- .../accounting/ten_ninety_nine_contact.rb | 36 ++++++++++--------- .../models/accounting/tracking_categories.rb | 36 ++++++++++--------- .../models/accounting/tracking_category.rb | 36 ++++++++++--------- .../models/accounting/tracking_option.rb | 36 ++++++++++--------- .../models/accounting/tracking_options.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/user.rb | 36 ++++++++++--------- lib/xero-ruby/models/accounting/users.rb | 36 ++++++++++--------- .../models/accounting/validation_error.rb | 36 ++++++++++--------- lib/xero-ruby/models/assets/asset.rb | 36 ++++++++++--------- lib/xero-ruby/models/assets/asset_type.rb | 36 ++++++++++--------- lib/xero-ruby/models/assets/assets.rb | 36 ++++++++++--------- .../models/assets/book_depreciation_detail.rb | 36 ++++++++++--------- .../assets/book_depreciation_setting.rb | 36 ++++++++++--------- lib/xero-ruby/models/assets/error.rb | 36 ++++++++++--------- .../assets/field_validation_errors_element.rb | 36 ++++++++++--------- lib/xero-ruby/models/assets/pagination.rb | 36 ++++++++++--------- .../resource_validation_errors_element.rb | 36 ++++++++++--------- lib/xero-ruby/models/assets/setting.rb | 36 ++++++++++--------- lib/xero-ruby/models/files/association.rb | 36 ++++++++++--------- lib/xero-ruby/models/files/file_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/files/files.rb | 36 ++++++++++--------- lib/xero-ruby/models/files/folder.rb | 36 ++++++++++--------- lib/xero-ruby/models/files/folders.rb | 36 ++++++++++--------- lib/xero-ruby/models/files/upload_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/files/user.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/account.rb | 36 ++++++++++--------- .../models/payroll_au/api_exception.rb | 36 ++++++++++--------- .../models/payroll_au/bank_account.rb | 36 ++++++++++--------- .../models/payroll_au/deduction_line.rb | 36 ++++++++++--------- .../models/payroll_au/deduction_type.rb | 36 ++++++++++--------- .../models/payroll_au/earnings_line.rb | 36 ++++++++++--------- .../models/payroll_au/earnings_rate.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/employee.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/employees.rb | 36 ++++++++++--------- .../models/payroll_au/home_address.rb | 36 ++++++++++--------- .../models/payroll_au/leave_accrual_line.rb | 36 ++++++++++--------- .../models/payroll_au/leave_application.rb | 36 ++++++++++--------- .../models/payroll_au/leave_applications.rb | 36 ++++++++++--------- .../models/payroll_au/leave_balance.rb | 36 ++++++++++--------- .../models/payroll_au/leave_earnings_line.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/leave_line.rb | 36 ++++++++++--------- .../models/payroll_au/leave_lines.rb | 36 ++++++++++--------- .../models/payroll_au/leave_period.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/leave_type.rb | 36 ++++++++++--------- .../models/payroll_au/opening_balances.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/pay_item.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/pay_items.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/pay_run.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/pay_runs.rb | 36 ++++++++++--------- .../models/payroll_au/pay_template.rb | 36 ++++++++++--------- .../models/payroll_au/payroll_calendar.rb | 36 ++++++++++--------- .../models/payroll_au/payroll_calendars.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/payslip.rb | 36 ++++++++++--------- .../models/payroll_au/payslip_lines.rb | 36 ++++++++++--------- .../models/payroll_au/payslip_object.rb | 36 ++++++++++--------- .../models/payroll_au/payslip_summary.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/payslips.rb | 36 ++++++++++--------- .../models/payroll_au/reimbursement_line.rb | 36 ++++++++++--------- .../models/payroll_au/reimbursement_lines.rb | 36 ++++++++++--------- .../models/payroll_au/reimbursement_type.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/settings.rb | 36 ++++++++++--------- .../models/payroll_au/settings_object.rb | 36 ++++++++++--------- .../settings_tracking_categories.rb | 36 ++++++++++--------- ...ngs_tracking_categories_employee_groups.rb | 36 ++++++++++--------- ...racking_categories_timesheet_categories.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/super_fund.rb | 36 ++++++++++--------- .../models/payroll_au/super_fund_product.rb | 36 ++++++++++--------- .../models/payroll_au/super_fund_products.rb | 36 ++++++++++--------- .../models/payroll_au/super_funds.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/super_line.rb | 36 ++++++++++--------- .../models/payroll_au/super_membership.rb | 36 ++++++++++--------- .../models/payroll_au/superannuation_line.rb | 36 ++++++++++--------- .../models/payroll_au/tax_declaration.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/tax_line.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/timesheet.rb | 36 ++++++++++--------- .../models/payroll_au/timesheet_line.rb | 36 ++++++++++--------- .../models/payroll_au/timesheet_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_au/timesheets.rb | 36 ++++++++++--------- .../models/payroll_au/validation_error.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/account.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/accounts.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/address.rb | 36 ++++++++++--------- .../models/payroll_nz/bank_account.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/benefit.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/deduction.rb | 36 ++++++++++--------- .../models/payroll_nz/deduction_line.rb | 36 ++++++++++--------- .../models/payroll_nz/deduction_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/deductions.rb | 36 ++++++++++--------- .../models/payroll_nz/earnings_line.rb | 36 ++++++++++--------- .../models/payroll_nz/earnings_order.rb | 36 ++++++++++--------- .../payroll_nz/earnings_order_object.rb | 36 ++++++++++--------- .../models/payroll_nz/earnings_orders.rb | 36 ++++++++++--------- .../models/payroll_nz/earnings_rate.rb | 36 ++++++++++--------- .../models/payroll_nz/earnings_rate_object.rb | 36 ++++++++++--------- .../models/payroll_nz/earnings_rates.rb | 36 ++++++++++--------- .../models/payroll_nz/earnings_template.rb | 36 ++++++++++--------- .../payroll_nz/earnings_template_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/employee.rb | 36 ++++++++++--------- .../payroll_nz/employee_earnings_templates.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_leave.rb | 36 ++++++++++--------- .../payroll_nz/employee_leave_balance.rb | 36 ++++++++++--------- .../payroll_nz/employee_leave_balances.rb | 36 ++++++++++--------- .../payroll_nz/employee_leave_object.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_leave_setup.rb | 36 ++++++++++--------- .../payroll_nz/employee_leave_setup_object.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_leave_type.rb | 36 ++++++++++--------- .../payroll_nz/employee_leave_type_object.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_leave_types.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_leaves.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_object.rb | 36 ++++++++++--------- .../payroll_nz/employee_opening_balance.rb | 36 ++++++++++--------- .../employee_opening_balances_object.rb | 36 ++++++++++--------- .../payroll_nz/employee_pay_template.rb | 36 ++++++++++--------- .../employee_pay_template_object.rb | 36 ++++++++++--------- .../payroll_nz/employee_pay_templates.rb | 36 ++++++++++--------- .../employee_statutory_leave_balance.rb | 36 ++++++++++--------- ...employee_statutory_leave_balance_object.rb | 36 ++++++++++--------- .../employee_statutory_leave_summary.rb | 36 ++++++++++--------- .../employee_statutory_leaves_summaries.rb | 36 ++++++++++--------- .../employee_statutory_sick_leave.rb | 36 ++++++++++--------- .../employee_statutory_sick_leave_object.rb | 36 ++++++++++--------- .../employee_statutory_sick_leaves.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_tax.rb | 36 ++++++++++--------- .../models/payroll_nz/employee_tax_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/employees.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/employment.rb | 36 ++++++++++--------- .../models/payroll_nz/employment_object.rb | 36 ++++++++++--------- .../payroll_nz/gross_earnings_history.rb | 36 ++++++++++--------- .../models/payroll_nz/invalid_field.rb | 36 ++++++++++--------- .../models/payroll_nz/leave_accrual_line.rb | 36 ++++++++++--------- .../models/payroll_nz/leave_earnings_line.rb | 36 ++++++++++--------- .../models/payroll_nz/leave_period.rb | 36 ++++++++++--------- .../models/payroll_nz/leave_periods.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/leave_type.rb | 36 ++++++++++--------- .../models/payroll_nz/leave_type_object.rb | 36 ++++++++++--------- .../models/payroll_nz/leave_types.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/pagination.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/pay_run.rb | 36 ++++++++++--------- .../models/payroll_nz/pay_run_calendar.rb | 36 ++++++++++--------- .../payroll_nz/pay_run_calendar_object.rb | 36 ++++++++++--------- .../models/payroll_nz/pay_run_calendars.rb | 36 ++++++++++--------- .../models/payroll_nz/pay_run_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/pay_runs.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/pay_slip.rb | 36 ++++++++++--------- .../models/payroll_nz/pay_slip_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/pay_slips.rb | 36 ++++++++++--------- .../models/payroll_nz/payment_line.rb | 36 ++++++++++--------- .../models/payroll_nz/payment_method.rb | 36 ++++++++++--------- .../payroll_nz/payment_method_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/problem.rb | 36 ++++++++++--------- .../models/payroll_nz/reimbursement.rb | 36 ++++++++++--------- .../models/payroll_nz/reimbursement_line.rb | 36 ++++++++++--------- .../models/payroll_nz/reimbursement_object.rb | 36 ++++++++++--------- .../models/payroll_nz/reimbursements.rb | 36 ++++++++++--------- .../models/payroll_nz/salary_and_wage.rb | 36 ++++++++++--------- .../payroll_nz/salary_and_wage_object.rb | 36 ++++++++++--------- .../models/payroll_nz/salary_and_wages.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/settings.rb | 36 ++++++++++--------- .../models/payroll_nz/statutory_deduction.rb | 36 ++++++++++--------- .../payroll_nz/statutory_deduction_line.rb | 36 ++++++++++--------- .../payroll_nz/statutory_deduction_object.rb | 36 ++++++++++--------- .../models/payroll_nz/statutory_deductions.rb | 36 ++++++++++--------- .../models/payroll_nz/superannuation_line.rb | 36 ++++++++++--------- .../payroll_nz/superannuation_object.rb | 36 ++++++++++--------- .../models/payroll_nz/superannuations.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/tax_line.rb | 36 ++++++++++--------- .../models/payroll_nz/tax_settings.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/timesheet.rb | 36 ++++++++++--------- .../payroll_nz/timesheet_earnings_line.rb | 36 ++++++++++--------- .../models/payroll_nz/timesheet_line.rb | 36 ++++++++++--------- .../payroll_nz/timesheet_line_object.rb | 36 ++++++++++--------- .../models/payroll_nz/timesheet_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_nz/timesheets.rb | 36 ++++++++++--------- .../models/payroll_nz/tracking_categories.rb | 36 ++++++++++--------- .../models/payroll_nz/tracking_category.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/account.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/accounts.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/address.rb | 36 ++++++++++--------- .../models/payroll_uk/bank_account.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/benefit.rb | 36 ++++++++++--------- .../models/payroll_uk/benefit_line.rb | 36 ++++++++++--------- .../models/payroll_uk/benefit_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/benefits.rb | 36 ++++++++++--------- .../models/payroll_uk/court_order_line.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/deduction.rb | 36 ++++++++++--------- .../models/payroll_uk/deduction_line.rb | 36 ++++++++++--------- .../models/payroll_uk/deduction_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/deductions.rb | 36 ++++++++++--------- .../models/payroll_uk/earnings_line.rb | 36 ++++++++++--------- .../models/payroll_uk/earnings_order.rb | 36 ++++++++++--------- .../payroll_uk/earnings_order_object.rb | 36 ++++++++++--------- .../models/payroll_uk/earnings_orders.rb | 36 ++++++++++--------- .../models/payroll_uk/earnings_rate.rb | 36 ++++++++++--------- .../models/payroll_uk/earnings_rate_object.rb | 36 ++++++++++--------- .../models/payroll_uk/earnings_rates.rb | 36 ++++++++++--------- .../models/payroll_uk/earnings_template.rb | 36 ++++++++++--------- .../payroll_uk/earnings_template_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/employee.rb | 36 ++++++++++--------- .../models/payroll_uk/employee_leave.rb | 36 ++++++++++--------- .../payroll_uk/employee_leave_balance.rb | 36 ++++++++++--------- .../payroll_uk/employee_leave_balances.rb | 36 ++++++++++--------- .../payroll_uk/employee_leave_object.rb | 36 ++++++++++--------- .../models/payroll_uk/employee_leave_type.rb | 36 ++++++++++--------- .../payroll_uk/employee_leave_type_object.rb | 36 ++++++++++--------- .../models/payroll_uk/employee_leave_types.rb | 36 ++++++++++--------- .../models/payroll_uk/employee_leaves.rb | 36 ++++++++++--------- .../models/payroll_uk/employee_object.rb | 36 ++++++++++--------- .../payroll_uk/employee_opening_balances.rb | 36 ++++++++++--------- .../employee_opening_balances_object.rb | 36 ++++++++++--------- .../payroll_uk/employee_pay_template.rb | 36 ++++++++++--------- .../employee_pay_template_object.rb | 36 ++++++++++--------- .../payroll_uk/employee_pay_templates.rb | 36 ++++++++++--------- .../employee_statutory_leave_balance.rb | 36 ++++++++++--------- ...employee_statutory_leave_balance_object.rb | 36 ++++++++++--------- .../employee_statutory_leave_summary.rb | 36 ++++++++++--------- .../employee_statutory_leaves_summaries.rb | 36 ++++++++++--------- .../employee_statutory_sick_leave.rb | 36 ++++++++++--------- .../employee_statutory_sick_leave_object.rb | 36 ++++++++++--------- .../employee_statutory_sick_leaves.rb | 36 ++++++++++--------- .../models/payroll_uk/employee_tax.rb | 36 ++++++++++--------- .../models/payroll_uk/employee_tax_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/employees.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/employment.rb | 36 ++++++++++--------- .../models/payroll_uk/employment_object.rb | 36 ++++++++++--------- .../models/payroll_uk/invalid_field.rb | 36 ++++++++++--------- .../models/payroll_uk/leave_accrual_line.rb | 36 ++++++++++--------- .../models/payroll_uk/leave_earnings_line.rb | 36 ++++++++++--------- .../models/payroll_uk/leave_period.rb | 36 ++++++++++--------- .../models/payroll_uk/leave_periods.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/leave_type.rb | 36 ++++++++++--------- .../models/payroll_uk/leave_type_object.rb | 36 ++++++++++--------- .../models/payroll_uk/leave_types.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/pagination.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/pay_run.rb | 36 ++++++++++--------- .../models/payroll_uk/pay_run_calendar.rb | 36 ++++++++++--------- .../payroll_uk/pay_run_calendar_object.rb | 36 ++++++++++--------- .../models/payroll_uk/pay_run_calendars.rb | 36 ++++++++++--------- .../models/payroll_uk/pay_run_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/pay_runs.rb | 36 ++++++++++--------- .../models/payroll_uk/payment_line.rb | 36 ++++++++++--------- .../models/payroll_uk/payment_method.rb | 36 ++++++++++--------- .../payroll_uk/payment_method_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/payslip.rb | 36 ++++++++++--------- .../models/payroll_uk/payslip_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/payslips.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/problem.rb | 36 ++++++++++--------- .../models/payroll_uk/reimbursement.rb | 36 ++++++++++--------- .../models/payroll_uk/reimbursement_line.rb | 36 ++++++++++--------- .../models/payroll_uk/reimbursement_object.rb | 36 ++++++++++--------- .../models/payroll_uk/reimbursements.rb | 36 ++++++++++--------- .../models/payroll_uk/salary_and_wage.rb | 36 ++++++++++--------- .../payroll_uk/salary_and_wage_object.rb | 36 ++++++++++--------- .../models/payroll_uk/salary_and_wages.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/settings.rb | 36 ++++++++++--------- .../models/payroll_uk/statutory_deduction.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/tax_line.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/timesheet.rb | 36 ++++++++++--------- .../payroll_uk/timesheet_earnings_line.rb | 36 ++++++++++--------- .../models/payroll_uk/timesheet_line.rb | 36 ++++++++++--------- .../payroll_uk/timesheet_line_object.rb | 36 ++++++++++--------- .../models/payroll_uk/timesheet_object.rb | 36 ++++++++++--------- lib/xero-ruby/models/payroll_uk/timesheets.rb | 36 ++++++++++--------- .../models/payroll_uk/tracking_categories.rb | 36 ++++++++++--------- .../models/payroll_uk/tracking_category.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/amount.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/error.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/pagination.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/project.rb | 36 ++++++++++--------- .../projects/project_create_or_update.rb | 36 ++++++++++--------- .../models/projects/project_patch.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/project_user.rb | 36 ++++++++++--------- .../models/projects/project_users.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/projects.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/task.rb | 36 ++++++++++--------- .../models/projects/task_create_or_update.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/tasks.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/time_entries.rb | 36 ++++++++++--------- lib/xero-ruby/models/projects/time_entry.rb | 36 ++++++++++--------- .../projects/time_entry_create_or_update.rb | 36 ++++++++++--------- lib/xero-ruby/version.rb | 4 +-- 391 files changed, 7775 insertions(+), 6200 deletions(-) diff --git a/docs/accounting/AccountingApi.md b/docs/accounting/AccountingApi.md index fbcfa74b..e1ccf660 100644 --- a/docs/accounting/AccountingApi.md +++ b/docs/accounting/AccountingApi.md @@ -6625,7 +6625,7 @@ opts = { include_archived: true, # Boolean | e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response - summary_only: false # Boolean | Use summaryOnly=true in GET Contacts 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. + summary_only: false # Boolean | 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. } begin @@ -6649,7 +6649,7 @@ Name | Type | Description | Notes **i_ds** | [**Array<String>**](String.md)| Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. | [optional] **page** | **Integer**| e.g. page=1 - Up to 100 contacts will be returned in a single API call. | [optional] **include_archived** | **Boolean**| e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response | [optional] - **summary_only** | **Boolean**| Use summaryOnly=true in GET Contacts 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. | [optional] [default to false] + **summary_only** | **Boolean**| 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. | [optional] [default to false] ### Return type @@ -8061,6 +8061,8 @@ opts = { created_by_my_app: false, # Boolean | When set to true you'll only retrieve Invoices created by your app + summary_only: false, # Boolean | 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. + unitdp: 4 # Integer | e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts } @@ -8089,6 +8091,7 @@ Name | Type | Description | Notes **page** | **Integer**| e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items shown for each invoice | [optional] **include_archived** | **Boolean**| e.g. includeArchived=true - Invoices with a status of ARCHIVED will be included in the response | [optional] **created_by_my_app** | **Boolean**| When set to true you'll only retrieve Invoices created by your app | [optional] + **summary_only** | **Boolean**| 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. | [optional] [default to false] **unitdp** | **Integer**| e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts | [optional] ### Return type diff --git a/docs/accounting/index.html b/docs/accounting/index.html index 83604201..21377559 100644 --- a/docs/accounting/index.html +++ b/docs/accounting/index.html @@ -20916,7 +20916,7 @@

Parameters

-Use summaryOnly=true in GET Contacts 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. +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.
@@ -23618,10 +23618,11 @@

Usage and SDK Samples

page = 1 include_archived = true created_by_my_app = false +summary_only = true unitdp = 4 begin - response = xero_client.accounting_api.get_invoices(xero_tenant_id, if_modified_since, where, order, ids, invoice_numbers, contact_ids, statuses, page, include_archived, created_by_my_app, unitdp) + response = xero_client.accounting_api.get_invoices(xero_tenant_id, if_modified_since, where, order, ids, invoice_numbers, contact_ids, statuses, page, include_archived, created_by_my_app, summary_only, unitdp) return response rescue XeroRuby::ApiError => e puts "Exception when calling get_invoices: #{e}" @@ -23882,6 +23883,26 @@

Parameters

+ + + summaryOnly + + + +
+
+
+ + Boolean + + +
+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. +
+
+
+
+ unitdp diff --git a/lib/xero-ruby/api/accounting_api.rb b/lib/xero-ruby/api/accounting_api.rb index 10f1e394..9f01bf59 100644 --- a/lib/xero-ruby/api/accounting_api.rb +++ b/lib/xero-ruby/api/accounting_api.rb @@ -7728,7 +7728,7 @@ def get_contact_history_with_http_info(xero_tenant_id, contact_id, options = {}) # @option opts [Array] :i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. # @option opts [Integer] :page e.g. page=1 - Up to 100 contacts will be returned in a single API call. # @option opts [Boolean] :include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response - # @option opts [Boolean] :summary_only Use summaryOnly=true in GET Contacts 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) + # @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) # @return [Contacts] def get_contacts(xero_tenant_id, opts = {}) data, _status_code, _headers = get_contacts_with_http_info(xero_tenant_id, opts) @@ -7744,7 +7744,7 @@ def get_contacts(xero_tenant_id, opts = {}) # @option opts [Array] :i_ds Filter by a comma separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. # @option opts [Integer] :page e.g. page=1 - Up to 100 contacts will be returned in a single API call. # @option opts [Boolean] :include_archived e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response - # @option opts [Boolean] :summary_only Use summaryOnly=true in GET Contacts 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. + # @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. # @return [Array<(Contacts, Integer, Hash)>] Contacts data, response status code and response headers def get_contacts_with_http_info(xero_tenant_id, options = {}) opts = options.dup @@ -9389,6 +9389,7 @@ def get_invoice_reminders_with_http_info(xero_tenant_id, options = {}) # @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 # @option opts [Boolean] :include_archived e.g. includeArchived=true - Invoices with a status of ARCHIVED will be included in the response # @option opts [Boolean] :created_by_my_app When set to true you'll only retrieve Invoices created by your app + # @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) # @option opts [Integer] :unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts # @return [Invoices] def get_invoices(xero_tenant_id, opts = {}) @@ -9409,6 +9410,7 @@ def get_invoices(xero_tenant_id, opts = {}) # @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 # @option opts [Boolean] :include_archived e.g. includeArchived=true - Invoices with a status of ARCHIVED will be included in the response # @option opts [Boolean] :created_by_my_app When set to true you'll only retrieve Invoices created by your app + # @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. # @option opts [Integer] :unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts # @return [Array<(Invoices, Integer, Hash)>] Invoices data, response status code and response headers def get_invoices_with_http_info(xero_tenant_id, options = {}) @@ -9437,6 +9439,7 @@ def get_invoices_with_http_info(xero_tenant_id, options = {}) query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'includeArchived'] = opts[:'include_archived'] if !opts[:'include_archived'].nil? query_params[:'createdByMyApp'] = opts[:'created_by_my_app'] if !opts[:'created_by_my_app'].nil? + query_params[:'summaryOnly'] = opts[:'summary_only'] if !opts[:'summary_only'].nil? query_params[:'unitdp'] = opts[:'unitdp'] if !opts[:'unitdp'].nil? # XeroAPI's `IDs` convention openapi-generator does not snake_case properly.. manual over-riding `i_ds` malformations: diff --git a/lib/xero-ruby/models/accounting/account.rb b/lib/xero-ruby/models/accounting/account.rb index 94870c30..923a1bc7 100644 --- a/lib/xero-ruby/models/accounting/account.rb +++ b/lib/xero-ruby/models/accounting/account.rb @@ -492,7 +492,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -506,36 +506,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/accounts.rb b/lib/xero-ruby/models/accounting/accounts.rb index cc6ccbe8..cd869db9 100644 --- a/lib/xero-ruby/models/accounting/accounts.rb +++ b/lib/xero-ruby/models/accounting/accounts.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/accounts_payable.rb b/lib/xero-ruby/models/accounting/accounts_payable.rb index 7446fa78..ca253ba1 100644 --- a/lib/xero-ruby/models/accounting/accounts_payable.rb +++ b/lib/xero-ruby/models/accounting/accounts_payable.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/accounts_receivable.rb b/lib/xero-ruby/models/accounting/accounts_receivable.rb index cd98484b..d9040555 100644 --- a/lib/xero-ruby/models/accounting/accounts_receivable.rb +++ b/lib/xero-ruby/models/accounting/accounts_receivable.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/action.rb b/lib/xero-ruby/models/accounting/action.rb index 0e05816f..8b0f5d8f 100644 --- a/lib/xero-ruby/models/accounting/action.rb +++ b/lib/xero-ruby/models/accounting/action.rb @@ -225,7 +225,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -239,36 +239,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/actions.rb b/lib/xero-ruby/models/accounting/actions.rb index 6989ece1..4f4f6aca 100644 --- a/lib/xero-ruby/models/accounting/actions.rb +++ b/lib/xero-ruby/models/accounting/actions.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/address.rb b/lib/xero-ruby/models/accounting/address.rb index d2898fd7..0de123fb 100644 --- a/lib/xero-ruby/models/accounting/address.rb +++ b/lib/xero-ruby/models/accounting/address.rb @@ -440,7 +440,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -454,36 +454,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/address_for_organisation.rb b/lib/xero-ruby/models/accounting/address_for_organisation.rb index 24cb290b..2392eaeb 100644 --- a/lib/xero-ruby/models/accounting/address_for_organisation.rb +++ b/lib/xero-ruby/models/accounting/address_for_organisation.rb @@ -441,7 +441,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -455,36 +455,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/allocation.rb b/lib/xero-ruby/models/accounting/allocation.rb index aef79db3..c96b0ba5 100644 --- a/lib/xero-ruby/models/accounting/allocation.rb +++ b/lib/xero-ruby/models/accounting/allocation.rb @@ -266,7 +266,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -280,36 +280,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/allocations.rb b/lib/xero-ruby/models/accounting/allocations.rb index 7c7a987c..a2c934a5 100644 --- a/lib/xero-ruby/models/accounting/allocations.rb +++ b/lib/xero-ruby/models/accounting/allocations.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/attachment.rb b/lib/xero-ruby/models/accounting/attachment.rb index cdd5aa83..1f751ca4 100644 --- a/lib/xero-ruby/models/accounting/attachment.rb +++ b/lib/xero-ruby/models/accounting/attachment.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/attachments.rb b/lib/xero-ruby/models/accounting/attachments.rb index b53bff59..3f03ef75 100644 --- a/lib/xero-ruby/models/accounting/attachments.rb +++ b/lib/xero-ruby/models/accounting/attachments.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/balance_details.rb b/lib/xero-ruby/models/accounting/balance_details.rb index 7f798838..bc556ef2 100644 --- a/lib/xero-ruby/models/accounting/balance_details.rb +++ b/lib/xero-ruby/models/accounting/balance_details.rb @@ -200,7 +200,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -214,36 +214,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/balances.rb b/lib/xero-ruby/models/accounting/balances.rb index a03d18fe..b4beeae3 100644 --- a/lib/xero-ruby/models/accounting/balances.rb +++ b/lib/xero-ruby/models/accounting/balances.rb @@ -190,7 +190,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -204,36 +204,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/bank_transaction.rb b/lib/xero-ruby/models/accounting/bank_transaction.rb index 40d735d6..4cd75e1b 100644 --- a/lib/xero-ruby/models/accounting/bank_transaction.rb +++ b/lib/xero-ruby/models/accounting/bank_transaction.rb @@ -467,7 +467,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -481,36 +481,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/bank_transactions.rb b/lib/xero-ruby/models/accounting/bank_transactions.rb index 17115164..4c53dda5 100644 --- a/lib/xero-ruby/models/accounting/bank_transactions.rb +++ b/lib/xero-ruby/models/accounting/bank_transactions.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/bank_transfer.rb b/lib/xero-ruby/models/accounting/bank_transfer.rb index f21c8673..0122267d 100644 --- a/lib/xero-ruby/models/accounting/bank_transfer.rb +++ b/lib/xero-ruby/models/accounting/bank_transfer.rb @@ -298,7 +298,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -312,36 +312,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/bank_transfers.rb b/lib/xero-ruby/models/accounting/bank_transfers.rb index 9aac21b6..12e2bd6f 100644 --- a/lib/xero-ruby/models/accounting/bank_transfers.rb +++ b/lib/xero-ruby/models/accounting/bank_transfers.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/batch_payment.rb b/lib/xero-ruby/models/accounting/batch_payment.rb index b66b5335..3a2a9787 100644 --- a/lib/xero-ruby/models/accounting/batch_payment.rb +++ b/lib/xero-ruby/models/accounting/batch_payment.rb @@ -453,7 +453,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -467,36 +467,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/batch_payment_details.rb b/lib/xero-ruby/models/accounting/batch_payment_details.rb index 1f183a6d..1c252039 100644 --- a/lib/xero-ruby/models/accounting/batch_payment_details.rb +++ b/lib/xero-ruby/models/accounting/batch_payment_details.rb @@ -250,7 +250,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -264,36 +264,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/batch_payments.rb b/lib/xero-ruby/models/accounting/batch_payments.rb index e2a791af..40447a62 100644 --- a/lib/xero-ruby/models/accounting/batch_payments.rb +++ b/lib/xero-ruby/models/accounting/batch_payments.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/bill.rb b/lib/xero-ruby/models/accounting/bill.rb index 031de03c..dacd2af1 100644 --- a/lib/xero-ruby/models/accounting/bill.rb +++ b/lib/xero-ruby/models/accounting/bill.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/branding_theme.rb b/lib/xero-ruby/models/accounting/branding_theme.rb index 205abaad..c25341da 100644 --- a/lib/xero-ruby/models/accounting/branding_theme.rb +++ b/lib/xero-ruby/models/accounting/branding_theme.rb @@ -264,7 +264,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -278,36 +278,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/branding_themes.rb b/lib/xero-ruby/models/accounting/branding_themes.rb index 931c6639..bd500cc5 100644 --- a/lib/xero-ruby/models/accounting/branding_themes.rb +++ b/lib/xero-ruby/models/accounting/branding_themes.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/cis_org_setting.rb b/lib/xero-ruby/models/accounting/cis_org_setting.rb index 2805dc8a..7a421532 100644 --- a/lib/xero-ruby/models/accounting/cis_org_setting.rb +++ b/lib/xero-ruby/models/accounting/cis_org_setting.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/cis_org_settings.rb b/lib/xero-ruby/models/accounting/cis_org_settings.rb index 46fea91d..789d6a8c 100644 --- a/lib/xero-ruby/models/accounting/cis_org_settings.rb +++ b/lib/xero-ruby/models/accounting/cis_org_settings.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/cis_setting.rb b/lib/xero-ruby/models/accounting/cis_setting.rb index b4943a50..1e70097f 100644 --- a/lib/xero-ruby/models/accounting/cis_setting.rb +++ b/lib/xero-ruby/models/accounting/cis_setting.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/cis_settings.rb b/lib/xero-ruby/models/accounting/cis_settings.rb index 64bee938..92c7c0b3 100644 --- a/lib/xero-ruby/models/accounting/cis_settings.rb +++ b/lib/xero-ruby/models/accounting/cis_settings.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/contact.rb b/lib/xero-ruby/models/accounting/contact.rb index d09722b2..4acc3eed 100644 --- a/lib/xero-ruby/models/accounting/contact.rb +++ b/lib/xero-ruby/models/accounting/contact.rb @@ -721,7 +721,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -735,36 +735,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/contact_group.rb b/lib/xero-ruby/models/accounting/contact_group.rb index 675c4b1e..7cdee068 100644 --- a/lib/xero-ruby/models/accounting/contact_group.rb +++ b/lib/xero-ruby/models/accounting/contact_group.rb @@ -247,7 +247,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -261,36 +261,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/contact_groups.rb b/lib/xero-ruby/models/accounting/contact_groups.rb index 1387449a..c7b1c857 100644 --- a/lib/xero-ruby/models/accounting/contact_groups.rb +++ b/lib/xero-ruby/models/accounting/contact_groups.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/contact_person.rb b/lib/xero-ruby/models/accounting/contact_person.rb index 792a3d78..ae346d97 100644 --- a/lib/xero-ruby/models/accounting/contact_person.rb +++ b/lib/xero-ruby/models/accounting/contact_person.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/contacts.rb b/lib/xero-ruby/models/accounting/contacts.rb index 186d0edb..69ecbaae 100644 --- a/lib/xero-ruby/models/accounting/contacts.rb +++ b/lib/xero-ruby/models/accounting/contacts.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/conversion_balances.rb b/lib/xero-ruby/models/accounting/conversion_balances.rb index 350b9a9d..4f638799 100644 --- a/lib/xero-ruby/models/accounting/conversion_balances.rb +++ b/lib/xero-ruby/models/accounting/conversion_balances.rb @@ -202,7 +202,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -216,36 +216,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/conversion_date.rb b/lib/xero-ruby/models/accounting/conversion_date.rb index 1ab33c61..f1f71f3b 100644 --- a/lib/xero-ruby/models/accounting/conversion_date.rb +++ b/lib/xero-ruby/models/accounting/conversion_date.rb @@ -190,7 +190,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -204,36 +204,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/credit_note.rb b/lib/xero-ruby/models/accounting/credit_note.rb index a548af35..8f32f2fd 100644 --- a/lib/xero-ruby/models/accounting/credit_note.rb +++ b/lib/xero-ruby/models/accounting/credit_note.rb @@ -537,7 +537,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -551,36 +551,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/credit_notes.rb b/lib/xero-ruby/models/accounting/credit_notes.rb index d19d5d52..2fcf2743 100644 --- a/lib/xero-ruby/models/accounting/credit_notes.rb +++ b/lib/xero-ruby/models/accounting/credit_notes.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/currencies.rb b/lib/xero-ruby/models/accounting/currencies.rb index fae22dd4..65c0f291 100644 --- a/lib/xero-ruby/models/accounting/currencies.rb +++ b/lib/xero-ruby/models/accounting/currencies.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/currency.rb b/lib/xero-ruby/models/accounting/currency.rb index d9184b23..59d440af 100644 --- a/lib/xero-ruby/models/accounting/currency.rb +++ b/lib/xero-ruby/models/accounting/currency.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/element.rb b/lib/xero-ruby/models/accounting/element.rb index 3e16fd60..a40d1bb5 100644 --- a/lib/xero-ruby/models/accounting/element.rb +++ b/lib/xero-ruby/models/accounting/element.rb @@ -251,7 +251,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -265,36 +265,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/employee.rb b/lib/xero-ruby/models/accounting/employee.rb index 416e2fbc..8c891c64 100644 --- a/lib/xero-ruby/models/accounting/employee.rb +++ b/lib/xero-ruby/models/accounting/employee.rb @@ -319,7 +319,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -333,36 +333,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/employees.rb b/lib/xero-ruby/models/accounting/employees.rb index 58f551a8..8668f238 100644 --- a/lib/xero-ruby/models/accounting/employees.rb +++ b/lib/xero-ruby/models/accounting/employees.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/error.rb b/lib/xero-ruby/models/accounting/error.rb index 2b3652f7..ad08ae4c 100644 --- a/lib/xero-ruby/models/accounting/error.rb +++ b/lib/xero-ruby/models/accounting/error.rb @@ -211,7 +211,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -225,36 +225,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/expense_claim.rb b/lib/xero-ruby/models/accounting/expense_claim.rb index ec8c34a0..fe93acf5 100644 --- a/lib/xero-ruby/models/accounting/expense_claim.rb +++ b/lib/xero-ruby/models/accounting/expense_claim.rb @@ -332,7 +332,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -346,36 +346,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/expense_claims.rb b/lib/xero-ruby/models/accounting/expense_claims.rb index fb31cbf9..26d81029 100644 --- a/lib/xero-ruby/models/accounting/expense_claims.rb +++ b/lib/xero-ruby/models/accounting/expense_claims.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/external_link.rb b/lib/xero-ruby/models/accounting/external_link.rb index 1953c19b..49455b4d 100644 --- a/lib/xero-ruby/models/accounting/external_link.rb +++ b/lib/xero-ruby/models/accounting/external_link.rb @@ -238,7 +238,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -252,36 +252,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/history_record.rb b/lib/xero-ruby/models/accounting/history_record.rb index 8c210d6d..d9bc5f1e 100644 --- a/lib/xero-ruby/models/accounting/history_record.rb +++ b/lib/xero-ruby/models/accounting/history_record.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/history_records.rb b/lib/xero-ruby/models/accounting/history_records.rb index 92d0cb27..9cf0ae67 100644 --- a/lib/xero-ruby/models/accounting/history_records.rb +++ b/lib/xero-ruby/models/accounting/history_records.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/import_summary.rb b/lib/xero-ruby/models/accounting/import_summary.rb index 22eef7d6..9112eb93 100644 --- a/lib/xero-ruby/models/accounting/import_summary.rb +++ b/lib/xero-ruby/models/accounting/import_summary.rb @@ -190,7 +190,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -204,36 +204,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/import_summary_accounts.rb b/lib/xero-ruby/models/accounting/import_summary_accounts.rb index d29eb944..b14f37b9 100644 --- a/lib/xero-ruby/models/accounting/import_summary_accounts.rb +++ b/lib/xero-ruby/models/accounting/import_summary_accounts.rb @@ -260,7 +260,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -274,36 +274,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/import_summary_object.rb b/lib/xero-ruby/models/accounting/import_summary_object.rb index e61291f9..85a23253 100644 --- a/lib/xero-ruby/models/accounting/import_summary_object.rb +++ b/lib/xero-ruby/models/accounting/import_summary_object.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/import_summary_organisation.rb b/lib/xero-ruby/models/accounting/import_summary_organisation.rb index 63e4c34c..4dd6239d 100644 --- a/lib/xero-ruby/models/accounting/import_summary_organisation.rb +++ b/lib/xero-ruby/models/accounting/import_summary_organisation.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/invoice.rb b/lib/xero-ruby/models/accounting/invoice.rb index ec72c90d..b7178fb8 100644 --- a/lib/xero-ruby/models/accounting/invoice.rb +++ b/lib/xero-ruby/models/accounting/invoice.rb @@ -664,7 +664,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -678,36 +678,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/invoice_reminder.rb b/lib/xero-ruby/models/accounting/invoice_reminder.rb index ed5cd7fa..40007003 100644 --- a/lib/xero-ruby/models/accounting/invoice_reminder.rb +++ b/lib/xero-ruby/models/accounting/invoice_reminder.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/invoice_reminders.rb b/lib/xero-ruby/models/accounting/invoice_reminders.rb index 33e66715..7ac7367a 100644 --- a/lib/xero-ruby/models/accounting/invoice_reminders.rb +++ b/lib/xero-ruby/models/accounting/invoice_reminders.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/invoices.rb b/lib/xero-ruby/models/accounting/invoices.rb index a933c7dc..d6f6b66b 100644 --- a/lib/xero-ruby/models/accounting/invoices.rb +++ b/lib/xero-ruby/models/accounting/invoices.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/item.rb b/lib/xero-ruby/models/accounting/item.rb index 0427e697..95650f81 100644 --- a/lib/xero-ruby/models/accounting/item.rb +++ b/lib/xero-ruby/models/accounting/item.rb @@ -400,7 +400,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -414,36 +414,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/items.rb b/lib/xero-ruby/models/accounting/items.rb index 3e2e0811..3744124a 100644 --- a/lib/xero-ruby/models/accounting/items.rb +++ b/lib/xero-ruby/models/accounting/items.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/journal.rb b/lib/xero-ruby/models/accounting/journal.rb index 10e17c73..5107fa34 100644 --- a/lib/xero-ruby/models/accounting/journal.rb +++ b/lib/xero-ruby/models/accounting/journal.rb @@ -310,7 +310,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -324,36 +324,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/journal_line.rb b/lib/xero-ruby/models/accounting/journal_line.rb index 918c3247..54f7ba53 100644 --- a/lib/xero-ruby/models/accounting/journal_line.rb +++ b/lib/xero-ruby/models/accounting/journal_line.rb @@ -291,7 +291,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -305,36 +305,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/journals.rb b/lib/xero-ruby/models/accounting/journals.rb index 1c13d2c4..b6b06aeb 100644 --- a/lib/xero-ruby/models/accounting/journals.rb +++ b/lib/xero-ruby/models/accounting/journals.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/line_item.rb b/lib/xero-ruby/models/accounting/line_item.rb index d442cde2..b0298eb3 100644 --- a/lib/xero-ruby/models/accounting/line_item.rb +++ b/lib/xero-ruby/models/accounting/line_item.rb @@ -301,7 +301,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -315,36 +315,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/line_item_tracking.rb b/lib/xero-ruby/models/accounting/line_item_tracking.rb index 788638a4..ea102510 100644 --- a/lib/xero-ruby/models/accounting/line_item_tracking.rb +++ b/lib/xero-ruby/models/accounting/line_item_tracking.rb @@ -224,7 +224,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -238,36 +238,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/linked_transaction.rb b/lib/xero-ruby/models/accounting/linked_transaction.rb index e338e546..5be34408 100644 --- a/lib/xero-ruby/models/accounting/linked_transaction.rb +++ b/lib/xero-ruby/models/accounting/linked_transaction.rb @@ -347,7 +347,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -361,36 +361,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/linked_transactions.rb b/lib/xero-ruby/models/accounting/linked_transactions.rb index a9c29705..187ee391 100644 --- a/lib/xero-ruby/models/accounting/linked_transactions.rb +++ b/lib/xero-ruby/models/accounting/linked_transactions.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/manual_journal.rb b/lib/xero-ruby/models/accounting/manual_journal.rb index 8df0bba2..0071ddc9 100644 --- a/lib/xero-ruby/models/accounting/manual_journal.rb +++ b/lib/xero-ruby/models/accounting/manual_journal.rb @@ -363,7 +363,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -377,36 +377,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/manual_journal_line.rb b/lib/xero-ruby/models/accounting/manual_journal_line.rb index 8d32a09e..90a01d88 100644 --- a/lib/xero-ruby/models/accounting/manual_journal_line.rb +++ b/lib/xero-ruby/models/accounting/manual_journal_line.rb @@ -251,7 +251,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -265,36 +265,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/manual_journals.rb b/lib/xero-ruby/models/accounting/manual_journals.rb index 92feb20c..c2dc9073 100644 --- a/lib/xero-ruby/models/accounting/manual_journals.rb +++ b/lib/xero-ruby/models/accounting/manual_journals.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/online_invoice.rb b/lib/xero-ruby/models/accounting/online_invoice.rb index 4c73619f..9d280310 100644 --- a/lib/xero-ruby/models/accounting/online_invoice.rb +++ b/lib/xero-ruby/models/accounting/online_invoice.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/online_invoices.rb b/lib/xero-ruby/models/accounting/online_invoices.rb index 1dfbc69c..fbed496a 100644 --- a/lib/xero-ruby/models/accounting/online_invoices.rb +++ b/lib/xero-ruby/models/accounting/online_invoices.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/organisation.rb b/lib/xero-ruby/models/accounting/organisation.rb index 9d8ac5b1..b310fc05 100644 --- a/lib/xero-ruby/models/accounting/organisation.rb +++ b/lib/xero-ruby/models/accounting/organisation.rb @@ -681,7 +681,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -695,36 +695,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/organisations.rb b/lib/xero-ruby/models/accounting/organisations.rb index 09509265..16a8f173 100644 --- a/lib/xero-ruby/models/accounting/organisations.rb +++ b/lib/xero-ruby/models/accounting/organisations.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/overpayment.rb b/lib/xero-ruby/models/accounting/overpayment.rb index baed90ef..b8002960 100644 --- a/lib/xero-ruby/models/accounting/overpayment.rb +++ b/lib/xero-ruby/models/accounting/overpayment.rb @@ -421,7 +421,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -435,36 +435,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/overpayments.rb b/lib/xero-ruby/models/accounting/overpayments.rb index f742b70d..c1675934 100644 --- a/lib/xero-ruby/models/accounting/overpayments.rb +++ b/lib/xero-ruby/models/accounting/overpayments.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/payment.rb b/lib/xero-ruby/models/accounting/payment.rb index 65f7cf07..41eeae19 100644 --- a/lib/xero-ruby/models/accounting/payment.rb +++ b/lib/xero-ruby/models/accounting/payment.rb @@ -481,7 +481,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -495,36 +495,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/payment_delete.rb b/lib/xero-ruby/models/accounting/payment_delete.rb index 78232500..c118d38e 100644 --- a/lib/xero-ruby/models/accounting/payment_delete.rb +++ b/lib/xero-ruby/models/accounting/payment_delete.rb @@ -186,7 +186,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -200,36 +200,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/payment_service.rb b/lib/xero-ruby/models/accounting/payment_service.rb index 0e128caf..096e5e26 100644 --- a/lib/xero-ruby/models/accounting/payment_service.rb +++ b/lib/xero-ruby/models/accounting/payment_service.rb @@ -231,7 +231,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -245,36 +245,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/payment_services.rb b/lib/xero-ruby/models/accounting/payment_services.rb index 3fb227b1..9a7e1a70 100644 --- a/lib/xero-ruby/models/accounting/payment_services.rb +++ b/lib/xero-ruby/models/accounting/payment_services.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/payment_term.rb b/lib/xero-ruby/models/accounting/payment_term.rb index 0f0d8ceb..9ba78b3f 100644 --- a/lib/xero-ruby/models/accounting/payment_term.rb +++ b/lib/xero-ruby/models/accounting/payment_term.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/payments.rb b/lib/xero-ruby/models/accounting/payments.rb index 5119adf8..95f13516 100644 --- a/lib/xero-ruby/models/accounting/payments.rb +++ b/lib/xero-ruby/models/accounting/payments.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/phone.rb b/lib/xero-ruby/models/accounting/phone.rb index 334efc68..abb37c0c 100644 --- a/lib/xero-ruby/models/accounting/phone.rb +++ b/lib/xero-ruby/models/accounting/phone.rb @@ -293,7 +293,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -307,36 +307,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/prepayment.rb b/lib/xero-ruby/models/accounting/prepayment.rb index 9a12adea..6a813a8b 100644 --- a/lib/xero-ruby/models/accounting/prepayment.rb +++ b/lib/xero-ruby/models/accounting/prepayment.rb @@ -432,7 +432,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -446,36 +446,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/prepayments.rb b/lib/xero-ruby/models/accounting/prepayments.rb index ae49e1ee..c53a3a6d 100644 --- a/lib/xero-ruby/models/accounting/prepayments.rb +++ b/lib/xero-ruby/models/accounting/prepayments.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/purchase.rb b/lib/xero-ruby/models/accounting/purchase.rb index 00184199..c088f174 100644 --- a/lib/xero-ruby/models/accounting/purchase.rb +++ b/lib/xero-ruby/models/accounting/purchase.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/purchase_order.rb b/lib/xero-ruby/models/accounting/purchase_order.rb index 509ed805..f0becfce 100644 --- a/lib/xero-ruby/models/accounting/purchase_order.rb +++ b/lib/xero-ruby/models/accounting/purchase_order.rb @@ -498,7 +498,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -512,36 +512,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/purchase_orders.rb b/lib/xero-ruby/models/accounting/purchase_orders.rb index eed42358..5676aadb 100644 --- a/lib/xero-ruby/models/accounting/purchase_orders.rb +++ b/lib/xero-ruby/models/accounting/purchase_orders.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/quote.rb b/lib/xero-ruby/models/accounting/quote.rb index 536817c5..2a7bf5b9 100644 --- a/lib/xero-ruby/models/accounting/quote.rb +++ b/lib/xero-ruby/models/accounting/quote.rb @@ -488,7 +488,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -502,36 +502,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/quotes.rb b/lib/xero-ruby/models/accounting/quotes.rb index 13110276..bc2b279f 100644 --- a/lib/xero-ruby/models/accounting/quotes.rb +++ b/lib/xero-ruby/models/accounting/quotes.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/receipt.rb b/lib/xero-ruby/models/accounting/receipt.rb index 92709a2f..fc3a401b 100644 --- a/lib/xero-ruby/models/accounting/receipt.rb +++ b/lib/xero-ruby/models/accounting/receipt.rb @@ -398,7 +398,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -412,36 +412,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/receipts.rb b/lib/xero-ruby/models/accounting/receipts.rb index ebbe41aa..27803b3d 100644 --- a/lib/xero-ruby/models/accounting/receipts.rb +++ b/lib/xero-ruby/models/accounting/receipts.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/repeating_invoice.rb b/lib/xero-ruby/models/accounting/repeating_invoice.rb index a3cfdf88..0983689e 100644 --- a/lib/xero-ruby/models/accounting/repeating_invoice.rb +++ b/lib/xero-ruby/models/accounting/repeating_invoice.rb @@ -386,7 +386,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -400,36 +400,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/repeating_invoices.rb b/lib/xero-ruby/models/accounting/repeating_invoices.rb index 91bff4a2..73a855a7 100644 --- a/lib/xero-ruby/models/accounting/repeating_invoices.rb +++ b/lib/xero-ruby/models/accounting/repeating_invoices.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report.rb b/lib/xero-ruby/models/accounting/report.rb index 23a4e250..30bc82d0 100644 --- a/lib/xero-ruby/models/accounting/report.rb +++ b/lib/xero-ruby/models/accounting/report.rb @@ -276,7 +276,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -290,36 +290,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report_attribute.rb b/lib/xero-ruby/models/accounting/report_attribute.rb index cccdcecf..c849e7ac 100644 --- a/lib/xero-ruby/models/accounting/report_attribute.rb +++ b/lib/xero-ruby/models/accounting/report_attribute.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report_cell.rb b/lib/xero-ruby/models/accounting/report_cell.rb index 68096849..f2c5b2b1 100644 --- a/lib/xero-ruby/models/accounting/report_cell.rb +++ b/lib/xero-ruby/models/accounting/report_cell.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report_fields.rb b/lib/xero-ruby/models/accounting/report_fields.rb index 64699ae0..974fe9ca 100644 --- a/lib/xero-ruby/models/accounting/report_fields.rb +++ b/lib/xero-ruby/models/accounting/report_fields.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report_row.rb b/lib/xero-ruby/models/accounting/report_row.rb index 54ea965a..6287a567 100644 --- a/lib/xero-ruby/models/accounting/report_row.rb +++ b/lib/xero-ruby/models/accounting/report_row.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report_rows.rb b/lib/xero-ruby/models/accounting/report_rows.rb index dc94e6d6..a3091716 100644 --- a/lib/xero-ruby/models/accounting/report_rows.rb +++ b/lib/xero-ruby/models/accounting/report_rows.rb @@ -213,7 +213,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -227,36 +227,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report_with_row.rb b/lib/xero-ruby/models/accounting/report_with_row.rb index beabd389..ca376240 100644 --- a/lib/xero-ruby/models/accounting/report_with_row.rb +++ b/lib/xero-ruby/models/accounting/report_with_row.rb @@ -265,7 +265,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -279,36 +279,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/report_with_rows.rb b/lib/xero-ruby/models/accounting/report_with_rows.rb index 8419bdac..a5db7cd5 100644 --- a/lib/xero-ruby/models/accounting/report_with_rows.rb +++ b/lib/xero-ruby/models/accounting/report_with_rows.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/reports.rb b/lib/xero-ruby/models/accounting/reports.rb index b3f47c34..8e4ca5b8 100644 --- a/lib/xero-ruby/models/accounting/reports.rb +++ b/lib/xero-ruby/models/accounting/reports.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/request_empty.rb b/lib/xero-ruby/models/accounting/request_empty.rb index c07bbcfc..5a4e0556 100644 --- a/lib/xero-ruby/models/accounting/request_empty.rb +++ b/lib/xero-ruby/models/accounting/request_empty.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/sales_tracking_category.rb b/lib/xero-ruby/models/accounting/sales_tracking_category.rb index 2acc0bdd..fb71510a 100644 --- a/lib/xero-ruby/models/accounting/sales_tracking_category.rb +++ b/lib/xero-ruby/models/accounting/sales_tracking_category.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/schedule.rb b/lib/xero-ruby/models/accounting/schedule.rb index 0cdf5491..eb428883 100644 --- a/lib/xero-ruby/models/accounting/schedule.rb +++ b/lib/xero-ruby/models/accounting/schedule.rb @@ -293,7 +293,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -307,36 +307,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/setup.rb b/lib/xero-ruby/models/accounting/setup.rb index 3f28d1f6..878134a6 100644 --- a/lib/xero-ruby/models/accounting/setup.rb +++ b/lib/xero-ruby/models/accounting/setup.rb @@ -203,7 +203,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -217,36 +217,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/tax_component.rb b/lib/xero-ruby/models/accounting/tax_component.rb index 0feef1f5..ef074e88 100644 --- a/lib/xero-ruby/models/accounting/tax_component.rb +++ b/lib/xero-ruby/models/accounting/tax_component.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/tax_rate.rb b/lib/xero-ruby/models/accounting/tax_rate.rb index d5f8a94c..81c221b1 100644 --- a/lib/xero-ruby/models/accounting/tax_rate.rb +++ b/lib/xero-ruby/models/accounting/tax_rate.rb @@ -415,7 +415,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -429,36 +429,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/tax_rates.rb b/lib/xero-ruby/models/accounting/tax_rates.rb index bb3f7a2a..b4737316 100644 --- a/lib/xero-ruby/models/accounting/tax_rates.rb +++ b/lib/xero-ruby/models/accounting/tax_rates.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb b/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb index ab25683f..5a1140f9 100644 --- a/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +++ b/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb @@ -389,7 +389,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -403,36 +403,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/tracking_categories.rb b/lib/xero-ruby/models/accounting/tracking_categories.rb index cd96ad7a..daf98bcf 100644 --- a/lib/xero-ruby/models/accounting/tracking_categories.rb +++ b/lib/xero-ruby/models/accounting/tracking_categories.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/tracking_category.rb b/lib/xero-ruby/models/accounting/tracking_category.rb index 3fcc5a32..512fd174 100644 --- a/lib/xero-ruby/models/accounting/tracking_category.rb +++ b/lib/xero-ruby/models/accounting/tracking_category.rb @@ -298,7 +298,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -312,36 +312,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/tracking_option.rb b/lib/xero-ruby/models/accounting/tracking_option.rb index 5605f012..15f96878 100644 --- a/lib/xero-ruby/models/accounting/tracking_option.rb +++ b/lib/xero-ruby/models/accounting/tracking_option.rb @@ -261,7 +261,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -275,36 +275,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/tracking_options.rb b/lib/xero-ruby/models/accounting/tracking_options.rb index fce6f42b..d5416625 100644 --- a/lib/xero-ruby/models/accounting/tracking_options.rb +++ b/lib/xero-ruby/models/accounting/tracking_options.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/user.rb b/lib/xero-ruby/models/accounting/user.rb index 13682a5c..6819857e 100644 --- a/lib/xero-ruby/models/accounting/user.rb +++ b/lib/xero-ruby/models/accounting/user.rb @@ -280,7 +280,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -294,36 +294,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/users.rb b/lib/xero-ruby/models/accounting/users.rb index c900f0d6..9bf04801 100644 --- a/lib/xero-ruby/models/accounting/users.rb +++ b/lib/xero-ruby/models/accounting/users.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/accounting/validation_error.rb b/lib/xero-ruby/models/accounting/validation_error.rb index 8aae51c2..10400869 100644 --- a/lib/xero-ruby/models/accounting/validation_error.rb +++ b/lib/xero-ruby/models/accounting/validation_error.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/asset.rb b/lib/xero-ruby/models/assets/asset.rb index 0c36bddb..8dccbb6f 100644 --- a/lib/xero-ruby/models/assets/asset.rb +++ b/lib/xero-ruby/models/assets/asset.rb @@ -334,7 +334,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -348,36 +348,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/asset_type.rb b/lib/xero-ruby/models/assets/asset_type.rb index f113f5e5..ae778286 100644 --- a/lib/xero-ruby/models/assets/asset_type.rb +++ b/lib/xero-ruby/models/assets/asset_type.rb @@ -249,7 +249,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -263,36 +263,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/assets.rb b/lib/xero-ruby/models/assets/assets.rb index 2fe1f935..133e36db 100644 --- a/lib/xero-ruby/models/assets/assets.rb +++ b/lib/xero-ruby/models/assets/assets.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/book_depreciation_detail.rb b/lib/xero-ruby/models/assets/book_depreciation_detail.rb index 824f8405..1e3c4a42 100644 --- a/lib/xero-ruby/models/assets/book_depreciation_detail.rb +++ b/lib/xero-ruby/models/assets/book_depreciation_detail.rb @@ -239,7 +239,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -253,36 +253,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/book_depreciation_setting.rb b/lib/xero-ruby/models/assets/book_depreciation_setting.rb index a031ce49..2b537524 100644 --- a/lib/xero-ruby/models/assets/book_depreciation_setting.rb +++ b/lib/xero-ruby/models/assets/book_depreciation_setting.rb @@ -318,7 +318,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -332,36 +332,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/error.rb b/lib/xero-ruby/models/assets/error.rb index 27671a24..3a35a57f 100644 --- a/lib/xero-ruby/models/assets/error.rb +++ b/lib/xero-ruby/models/assets/error.rb @@ -223,7 +223,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -237,36 +237,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/field_validation_errors_element.rb b/lib/xero-ruby/models/assets/field_validation_errors_element.rb index 61e3902c..3bda35e3 100644 --- a/lib/xero-ruby/models/assets/field_validation_errors_element.rb +++ b/lib/xero-ruby/models/assets/field_validation_errors_element.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/pagination.rb b/lib/xero-ruby/models/assets/pagination.rb index 608c6186..1c642a85 100644 --- a/lib/xero-ruby/models/assets/pagination.rb +++ b/lib/xero-ruby/models/assets/pagination.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/resource_validation_errors_element.rb b/lib/xero-ruby/models/assets/resource_validation_errors_element.rb index 373644ad..7c1f5626 100644 --- a/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +++ b/lib/xero-ruby/models/assets/resource_validation_errors_element.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/assets/setting.rb b/lib/xero-ruby/models/assets/setting.rb index d7e0ce69..a3731e4d 100644 --- a/lib/xero-ruby/models/assets/setting.rb +++ b/lib/xero-ruby/models/assets/setting.rb @@ -249,7 +249,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -263,36 +263,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/files/association.rb b/lib/xero-ruby/models/files/association.rb index adcac9f2..32400113 100644 --- a/lib/xero-ruby/models/files/association.rb +++ b/lib/xero-ruby/models/files/association.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/files/file_object.rb b/lib/xero-ruby/models/files/file_object.rb index 81b6d8e7..8b082911 100644 --- a/lib/xero-ruby/models/files/file_object.rb +++ b/lib/xero-ruby/models/files/file_object.rb @@ -249,7 +249,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -263,36 +263,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/files/files.rb b/lib/xero-ruby/models/files/files.rb index a08a4dde..73d1c5ce 100644 --- a/lib/xero-ruby/models/files/files.rb +++ b/lib/xero-ruby/models/files/files.rb @@ -211,7 +211,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -225,36 +225,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/files/folder.rb b/lib/xero-ruby/models/files/folder.rb index 3c4b3e2b..c419e241 100644 --- a/lib/xero-ruby/models/files/folder.rb +++ b/lib/xero-ruby/models/files/folder.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/files/folders.rb b/lib/xero-ruby/models/files/folders.rb index 049e2687..f4c07ae1 100644 --- a/lib/xero-ruby/models/files/folders.rb +++ b/lib/xero-ruby/models/files/folders.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/files/upload_object.rb b/lib/xero-ruby/models/files/upload_object.rb index a2871fde..ac93a929 100644 --- a/lib/xero-ruby/models/files/upload_object.rb +++ b/lib/xero-ruby/models/files/upload_object.rb @@ -224,7 +224,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -238,36 +238,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/files/user.rb b/lib/xero-ruby/models/files/user.rb index f4a25f1c..e7c72eb5 100644 --- a/lib/xero-ruby/models/files/user.rb +++ b/lib/xero-ruby/models/files/user.rb @@ -224,7 +224,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -238,36 +238,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/account.rb b/lib/xero-ruby/models/payroll_au/account.rb index 618cb4ef..9b4aa9ee 100644 --- a/lib/xero-ruby/models/payroll_au/account.rb +++ b/lib/xero-ruby/models/payroll_au/account.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/api_exception.rb b/lib/xero-ruby/models/payroll_au/api_exception.rb index ab99aff1..fe8eee8f 100644 --- a/lib/xero-ruby/models/payroll_au/api_exception.rb +++ b/lib/xero-ruby/models/payroll_au/api_exception.rb @@ -200,7 +200,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -214,36 +214,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/bank_account.rb b/lib/xero-ruby/models/payroll_au/bank_account.rb index e2ce6dcc..0de45342 100644 --- a/lib/xero-ruby/models/payroll_au/bank_account.rb +++ b/lib/xero-ruby/models/payroll_au/bank_account.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/deduction_line.rb b/lib/xero-ruby/models/payroll_au/deduction_line.rb index d23eb297..8051991d 100644 --- a/lib/xero-ruby/models/payroll_au/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_au/deduction_line.rb @@ -224,7 +224,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -238,36 +238,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/deduction_type.rb b/lib/xero-ruby/models/payroll_au/deduction_type.rb index ea7f830a..8388a752 100644 --- a/lib/xero-ruby/models/payroll_au/deduction_type.rb +++ b/lib/xero-ruby/models/payroll_au/deduction_type.rb @@ -311,7 +311,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -325,36 +325,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/earnings_line.rb b/lib/xero-ruby/models/payroll_au/earnings_line.rb index 0cbf72cb..a4700163 100644 --- a/lib/xero-ruby/models/payroll_au/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_au/earnings_line.rb @@ -264,7 +264,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -278,36 +278,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/earnings_rate.rb b/lib/xero-ruby/models/payroll_au/earnings_rate.rb index 9f2eea38..0bbf00fa 100644 --- a/lib/xero-ruby/models/payroll_au/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_au/earnings_rate.rb @@ -369,7 +369,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -383,36 +383,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/employee.rb b/lib/xero-ruby/models/payroll_au/employee.rb index 11513b32..33d3040a 100644 --- a/lib/xero-ruby/models/payroll_au/employee.rb +++ b/lib/xero-ruby/models/payroll_au/employee.rb @@ -542,7 +542,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -556,36 +556,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/employees.rb b/lib/xero-ruby/models/payroll_au/employees.rb index 888ed824..31238be7 100644 --- a/lib/xero-ruby/models/payroll_au/employees.rb +++ b/lib/xero-ruby/models/payroll_au/employees.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/home_address.rb b/lib/xero-ruby/models/payroll_au/home_address.rb index 6ac56f5e..959721c1 100644 --- a/lib/xero-ruby/models/payroll_au/home_address.rb +++ b/lib/xero-ruby/models/payroll_au/home_address.rb @@ -234,7 +234,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -248,36 +248,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb index 65dc3615..89a7e981 100644 --- a/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_application.rb b/lib/xero-ruby/models/payroll_au/leave_application.rb index 4ca8a4d6..2274b4a6 100644 --- a/lib/xero-ruby/models/payroll_au/leave_application.rb +++ b/lib/xero-ruby/models/payroll_au/leave_application.rb @@ -273,7 +273,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -287,36 +287,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_applications.rb b/lib/xero-ruby/models/payroll_au/leave_applications.rb index 29fbb2ee..5c9da8b6 100644 --- a/lib/xero-ruby/models/payroll_au/leave_applications.rb +++ b/lib/xero-ruby/models/payroll_au/leave_applications.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_balance.rb b/lib/xero-ruby/models/payroll_au/leave_balance.rb index e7ba61a2..0b82076f 100644 --- a/lib/xero-ruby/models/payroll_au/leave_balance.rb +++ b/lib/xero-ruby/models/payroll_au/leave_balance.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb index 6e814683..3d1e5c02 100644 --- a/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_line.rb b/lib/xero-ruby/models/payroll_au/leave_line.rb index 0b9cab93..d80e0c5d 100644 --- a/lib/xero-ruby/models/payroll_au/leave_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_line.rb @@ -249,7 +249,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -263,36 +263,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_lines.rb b/lib/xero-ruby/models/payroll_au/leave_lines.rb index 0d6566d7..de3de052 100644 --- a/lib/xero-ruby/models/payroll_au/leave_lines.rb +++ b/lib/xero-ruby/models/payroll_au/leave_lines.rb @@ -182,7 +182,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -196,36 +196,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_period.rb b/lib/xero-ruby/models/payroll_au/leave_period.rb index 37557079..aafbfe3c 100644 --- a/lib/xero-ruby/models/payroll_au/leave_period.rb +++ b/lib/xero-ruby/models/payroll_au/leave_period.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/leave_type.rb b/lib/xero-ruby/models/payroll_au/leave_type.rb index 95267904..a30a41c4 100644 --- a/lib/xero-ruby/models/payroll_au/leave_type.rb +++ b/lib/xero-ruby/models/payroll_au/leave_type.rb @@ -274,7 +274,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -288,36 +288,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/opening_balances.rb b/lib/xero-ruby/models/payroll_au/opening_balances.rb index 7143f4e2..e5d62686 100644 --- a/lib/xero-ruby/models/payroll_au/opening_balances.rb +++ b/lib/xero-ruby/models/payroll_au/opening_balances.rb @@ -249,7 +249,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -263,36 +263,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/pay_item.rb b/lib/xero-ruby/models/payroll_au/pay_item.rb index c2627344..1a79367d 100644 --- a/lib/xero-ruby/models/payroll_au/pay_item.rb +++ b/lib/xero-ruby/models/payroll_au/pay_item.rb @@ -217,7 +217,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -231,36 +231,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/pay_items.rb b/lib/xero-ruby/models/payroll_au/pay_items.rb index 218ee6a6..c88862e9 100644 --- a/lib/xero-ruby/models/payroll_au/pay_items.rb +++ b/lib/xero-ruby/models/payroll_au/pay_items.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/pay_run.rb b/lib/xero-ruby/models/payroll_au/pay_run.rb index b25e348b..7f03204b 100644 --- a/lib/xero-ruby/models/payroll_au/pay_run.rb +++ b/lib/xero-ruby/models/payroll_au/pay_run.rb @@ -338,7 +338,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -352,36 +352,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/pay_runs.rb b/lib/xero-ruby/models/payroll_au/pay_runs.rb index 608381fa..3046f5db 100644 --- a/lib/xero-ruby/models/payroll_au/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_au/pay_runs.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/pay_template.rb b/lib/xero-ruby/models/payroll_au/pay_template.rb index 2e49e279..b6b73939 100644 --- a/lib/xero-ruby/models/payroll_au/pay_template.rb +++ b/lib/xero-ruby/models/payroll_au/pay_template.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/payroll_calendar.rb b/lib/xero-ruby/models/payroll_au/payroll_calendar.rb index a9dbc24c..95f0b402 100644 --- a/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +++ b/lib/xero-ruby/models/payroll_au/payroll_calendar.rb @@ -241,7 +241,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -255,36 +255,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/payroll_calendars.rb b/lib/xero-ruby/models/payroll_au/payroll_calendars.rb index ecc0612e..f50e821c 100644 --- a/lib/xero-ruby/models/payroll_au/payroll_calendars.rb +++ b/lib/xero-ruby/models/payroll_au/payroll_calendars.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/payslip.rb b/lib/xero-ruby/models/payroll_au/payslip.rb index 60557570..f9fce168 100644 --- a/lib/xero-ruby/models/payroll_au/payslip.rb +++ b/lib/xero-ruby/models/payroll_au/payslip.rb @@ -375,7 +375,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -389,36 +389,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/payslip_lines.rb b/lib/xero-ruby/models/payroll_au/payslip_lines.rb index f25f702f..e7f9dc38 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_lines.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_lines.rb @@ -265,7 +265,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -279,36 +279,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/payslip_object.rb b/lib/xero-ruby/models/payroll_au/payslip_object.rb index 54494cfb..14ec520b 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_object.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_object.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/payslip_summary.rb b/lib/xero-ruby/models/payroll_au/payslip_summary.rb index eb2963c8..1ec743de 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_summary.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_summary.rb @@ -289,7 +289,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -303,36 +303,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/payslips.rb b/lib/xero-ruby/models/payroll_au/payslips.rb index 1bfd932b..7dc2ec09 100644 --- a/lib/xero-ruby/models/payroll_au/payslips.rb +++ b/lib/xero-ruby/models/payroll_au/payslips.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_line.rb b/lib/xero-ruby/models/payroll_au/reimbursement_line.rb index 665f599e..8a04f9b6 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_line.rb @@ -224,7 +224,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -238,36 +238,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb b/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb index aae30e88..e903fc56 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb @@ -182,7 +182,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -196,36 +196,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_type.rb b/lib/xero-ruby/models/payroll_au/reimbursement_type.rb index 1885092d..c8f722f0 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_type.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_type.rb @@ -234,7 +234,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -248,36 +248,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/settings.rb b/lib/xero-ruby/models/payroll_au/settings.rb index 46cc3f63..6563e2bb 100644 --- a/lib/xero-ruby/models/payroll_au/settings.rb +++ b/lib/xero-ruby/models/payroll_au/settings.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/settings_object.rb b/lib/xero-ruby/models/payroll_au/settings_object.rb index b93cab34..7795b09a 100644 --- a/lib/xero-ruby/models/payroll_au/settings_object.rb +++ b/lib/xero-ruby/models/payroll_au/settings_object.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb index dbb5d33b..f3e9c514 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb @@ -190,7 +190,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -204,36 +204,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb index 42a97072..92c3b7e3 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb @@ -190,7 +190,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -204,36 +204,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb index 0bcbc29a..dfc4acff 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb @@ -190,7 +190,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -204,36 +204,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/super_fund.rb b/lib/xero-ruby/models/payroll_au/super_fund.rb index dcba8a28..c05399c3 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund.rb @@ -306,7 +306,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -320,36 +320,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/super_fund_product.rb b/lib/xero-ruby/models/payroll_au/super_fund_product.rb index bece1e46..7ea0dc8b 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund_product.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund_product.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/super_fund_products.rb b/lib/xero-ruby/models/payroll_au/super_fund_products.rb index 5db66840..5c5110d2 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund_products.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund_products.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/super_funds.rb b/lib/xero-ruby/models/payroll_au/super_funds.rb index 9105881f..0538c681 100644 --- a/lib/xero-ruby/models/payroll_au/super_funds.rb +++ b/lib/xero-ruby/models/payroll_au/super_funds.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/super_line.rb b/lib/xero-ruby/models/payroll_au/super_line.rb index dcf00378..3c8ca6fa 100644 --- a/lib/xero-ruby/models/payroll_au/super_line.rb +++ b/lib/xero-ruby/models/payroll_au/super_line.rb @@ -249,7 +249,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -263,36 +263,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/super_membership.rb b/lib/xero-ruby/models/payroll_au/super_membership.rb index 52dd05c9..c60aab5f 100644 --- a/lib/xero-ruby/models/payroll_au/super_membership.rb +++ b/lib/xero-ruby/models/payroll_au/super_membership.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/superannuation_line.rb b/lib/xero-ruby/models/payroll_au/superannuation_line.rb index 027626c9..14d428bb 100644 --- a/lib/xero-ruby/models/payroll_au/superannuation_line.rb +++ b/lib/xero-ruby/models/payroll_au/superannuation_line.rb @@ -259,7 +259,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -273,36 +273,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/tax_declaration.rb b/lib/xero-ruby/models/payroll_au/tax_declaration.rb index 55f764ce..652eed46 100644 --- a/lib/xero-ruby/models/payroll_au/tax_declaration.rb +++ b/lib/xero-ruby/models/payroll_au/tax_declaration.rb @@ -329,7 +329,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -343,36 +343,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/tax_line.rb b/lib/xero-ruby/models/payroll_au/tax_line.rb index 0f3b58c8..85b39c93 100644 --- a/lib/xero-ruby/models/payroll_au/tax_line.rb +++ b/lib/xero-ruby/models/payroll_au/tax_line.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/timesheet.rb b/lib/xero-ruby/models/payroll_au/timesheet.rb index f591fe7d..538aac95 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet.rb @@ -278,7 +278,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -292,36 +292,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/timesheet_line.rb b/lib/xero-ruby/models/payroll_au/timesheet_line.rb index 61cefa5d..b433d3ad 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet_line.rb @@ -211,7 +211,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -225,36 +225,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/timesheet_object.rb b/lib/xero-ruby/models/payroll_au/timesheet_object.rb index 650d71be..2c49d300 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet_object.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/timesheets.rb b/lib/xero-ruby/models/payroll_au/timesheets.rb index bd8943a0..81b39ba6 100644 --- a/lib/xero-ruby/models/payroll_au/timesheets.rb +++ b/lib/xero-ruby/models/payroll_au/timesheets.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_au/validation_error.rb b/lib/xero-ruby/models/payroll_au/validation_error.rb index 79380159..7d6beb1e 100644 --- a/lib/xero-ruby/models/payroll_au/validation_error.rb +++ b/lib/xero-ruby/models/payroll_au/validation_error.rb @@ -179,7 +179,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -193,36 +193,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/account.rb b/lib/xero-ruby/models/payroll_nz/account.rb index ba72c38d..49ddb40d 100644 --- a/lib/xero-ruby/models/payroll_nz/account.rb +++ b/lib/xero-ruby/models/payroll_nz/account.rb @@ -247,7 +247,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -261,36 +261,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/accounts.rb b/lib/xero-ruby/models/payroll_nz/accounts.rb index 71bfda64..f52dad64 100644 --- a/lib/xero-ruby/models/payroll_nz/accounts.rb +++ b/lib/xero-ruby/models/payroll_nz/accounts.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/address.rb b/lib/xero-ruby/models/payroll_nz/address.rb index eeabfc80..d8ad30d5 100644 --- a/lib/xero-ruby/models/payroll_nz/address.rb +++ b/lib/xero-ruby/models/payroll_nz/address.rb @@ -244,7 +244,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -258,36 +258,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/bank_account.rb b/lib/xero-ruby/models/payroll_nz/bank_account.rb index 3d2a5aca..f2dc4042 100644 --- a/lib/xero-ruby/models/payroll_nz/bank_account.rb +++ b/lib/xero-ruby/models/payroll_nz/bank_account.rb @@ -300,7 +300,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -314,36 +314,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/benefit.rb b/lib/xero-ruby/models/payroll_nz/benefit.rb index b6b3470e..03d1b5b6 100644 --- a/lib/xero-ruby/models/payroll_nz/benefit.rb +++ b/lib/xero-ruby/models/payroll_nz/benefit.rb @@ -340,7 +340,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -354,36 +354,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/deduction.rb b/lib/xero-ruby/models/payroll_nz/deduction.rb index 89d09790..b19a60fa 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction.rb @@ -282,7 +282,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -296,36 +296,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/deduction_line.rb b/lib/xero-ruby/models/payroll_nz/deduction_line.rb index e1ca6e4d..74825b33 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction_line.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/deduction_object.rb b/lib/xero-ruby/models/payroll_nz/deduction_object.rb index d21096d8..6a40f065 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction_object.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/deductions.rb b/lib/xero-ruby/models/payroll_nz/deductions.rb index faf4b684..f3c2df06 100644 --- a/lib/xero-ruby/models/payroll_nz/deductions.rb +++ b/lib/xero-ruby/models/payroll_nz/deductions.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_line.rb b/lib/xero-ruby/models/payroll_nz/earnings_line.rb index cd7b0f4e..a96d6bae 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_line.rb @@ -269,7 +269,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -283,36 +283,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_order.rb b/lib/xero-ruby/models/payroll_nz/earnings_order.rb index 3a2fb9cf..f42a2de7 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_order.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_order.rb @@ -226,7 +226,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -240,36 +240,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb index bad4e204..90e8f6d6 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_orders.rb b/lib/xero-ruby/models/payroll_nz/earnings_orders.rb index e4a9187f..653e99a4 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_orders.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_orders.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rate.rb b/lib/xero-ruby/models/payroll_nz/earnings_rate.rb index 2bd1d0aa..0bdacc6d 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rate.rb @@ -358,7 +358,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -372,36 +372,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb index 692b1981..a179408d 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rates.rb b/lib/xero-ruby/models/payroll_nz/earnings_rates.rb index 2a8b5ecf..05612d77 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rates.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rates.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_template.rb b/lib/xero-ruby/models/payroll_nz/earnings_template.rb index e85044da..107ebbb4 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_template.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_template.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb index c452ad6b..aab5c187 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee.rb b/lib/xero-ruby/models/payroll_nz/employee.rb index 1e475944..57f12a1a 100644 --- a/lib/xero-ruby/models/payroll_nz/employee.rb +++ b/lib/xero-ruby/models/payroll_nz/employee.rb @@ -345,7 +345,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -359,36 +359,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb b/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb index 789e1c07..e93d3155 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave.rb b/lib/xero-ruby/models/payroll_nz/employee_leave.rb index 39ee6786..948b9939 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave.rb @@ -261,7 +261,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -275,36 +275,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb index 94ca6d5a..aff22cfd 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb index 4e5a2de8..d249aa99 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb index b576c6ff..e65f527a 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb index cc290afd..9c79b8a2 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb @@ -239,7 +239,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -253,36 +253,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb index 18fb5e00..eac8f60f 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb index 1eda7d00..249e0ed8 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb @@ -307,7 +307,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -321,36 +321,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb index c4002d76..0c2794be 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb index 428da280..4f376549 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_leaves.rb b/lib/xero-ruby/models/payroll_nz/employee_leaves.rb index 27bbe94b..48c4af14 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leaves.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leaves.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_object.rb b/lib/xero-ruby/models/payroll_nz/employee_object.rb index 35ea774d..74ba1132 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb index f41f23fd..87d5607d 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb b/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb index 2436b235..4916f28a 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb index 3bd2a54b..59d55ece 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb index a3cb6314..fd711586 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb index b7244b9b..5a7e9786 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb index 07054914..50954cc6 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb @@ -251,7 +251,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -265,36 +265,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb index f54475d1..76bd7795 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb index 75df15b6..071a011d 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb @@ -293,7 +293,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -307,36 +307,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb index c3d50f22..edf9cbe3 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb index e41876c1..fdf86d63 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb @@ -390,7 +390,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -404,36 +404,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb index 4e7aabf5..588dc48f 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb index 1e74adbc..2c2433b0 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_tax.rb b/lib/xero-ruby/models/payroll_nz/employee_tax.rb index 18bd3504..66708660 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_tax.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_tax.rb @@ -368,7 +368,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -382,36 +382,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb b/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb index 86996ae0..e25b9cd5 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employees.rb b/lib/xero-ruby/models/payroll_nz/employees.rb index a0f0209d..3fdbd2e6 100644 --- a/lib/xero-ruby/models/payroll_nz/employees.rb +++ b/lib/xero-ruby/models/payroll_nz/employees.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employment.rb b/lib/xero-ruby/models/payroll_nz/employment.rb index bf29d550..3c10cb8d 100644 --- a/lib/xero-ruby/models/payroll_nz/employment.rb +++ b/lib/xero-ruby/models/payroll_nz/employment.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/employment_object.rb b/lib/xero-ruby/models/payroll_nz/employment_object.rb index 36a454cb..c0923fa4 100644 --- a/lib/xero-ruby/models/payroll_nz/employment_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employment_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb b/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb index fde0c97d..673aea52 100644 --- a/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb +++ b/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/invalid_field.rb b/lib/xero-ruby/models/payroll_nz/invalid_field.rb index 2c688c66..a602eedf 100644 --- a/lib/xero-ruby/models/payroll_nz/invalid_field.rb +++ b/lib/xero-ruby/models/payroll_nz/invalid_field.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb index 83916f07..fc4d35de 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb index 5c7a909a..b0ea0451 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb @@ -269,7 +269,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -283,36 +283,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/leave_period.rb b/lib/xero-ruby/models/payroll_nz/leave_period.rb index f25606b8..e8813dd0 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_period.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_period.rb @@ -245,7 +245,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -259,36 +259,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/leave_periods.rb b/lib/xero-ruby/models/payroll_nz/leave_periods.rb index 8669fc5c..ed07f85d 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_periods.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_periods.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/leave_type.rb b/lib/xero-ruby/models/payroll_nz/leave_type.rb index 82a149ee..61c75481 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_type.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_type.rb @@ -244,7 +244,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -258,36 +258,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/leave_type_object.rb b/lib/xero-ruby/models/payroll_nz/leave_type_object.rb index a74e12b5..c30c24c4 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_type_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/leave_types.rb b/lib/xero-ruby/models/payroll_nz/leave_types.rb index e1f81992..47204180 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_types.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_types.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pagination.rb b/lib/xero-ruby/models/payroll_nz/pagination.rb index 6d1e3660..98207ee9 100644 --- a/lib/xero-ruby/models/payroll_nz/pagination.rb +++ b/lib/xero-ruby/models/payroll_nz/pagination.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_run.rb b/lib/xero-ruby/models/payroll_nz/pay_run.rb index 56d82c17..096fa72b 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run.rb @@ -342,7 +342,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -356,36 +356,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb index 68b52882..c9d27c39 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb @@ -259,7 +259,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -273,36 +273,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb index 653bd7e7..05cc3944 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb index e7af0045..cd6daa26 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_object.rb b/lib/xero-ruby/models/payroll_nz/pay_run_object.rb index 74856d27..18a72cf4 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_runs.rb b/lib/xero-ruby/models/payroll_nz/pay_runs.rb index a458743d..cc8a440c 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_runs.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_slip.rb b/lib/xero-ruby/models/payroll_nz/pay_slip.rb index 3c625f3b..1207e4ff 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slip.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slip.rb @@ -528,7 +528,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -542,36 +542,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb b/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb index c7d1619f..167eacff 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/pay_slips.rb b/lib/xero-ruby/models/payroll_nz/pay_slips.rb index f53a654d..5d511196 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slips.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slips.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/payment_line.rb b/lib/xero-ruby/models/payroll_nz/payment_line.rb index 8bf121ac..ecf015f2 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_line.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_line.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/payment_method.rb b/lib/xero-ruby/models/payroll_nz/payment_method.rb index 3929bd9c..263200c6 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_method.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_method.rb @@ -228,7 +228,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -242,36 +242,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/payment_method_object.rb b/lib/xero-ruby/models/payroll_nz/payment_method_object.rb index 4c1c6166..ab5ace2e 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_method_object.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_method_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/problem.rb b/lib/xero-ruby/models/payroll_nz/problem.rb index 7d69e6f0..10a68055 100644 --- a/lib/xero-ruby/models/payroll_nz/problem.rb +++ b/lib/xero-ruby/models/payroll_nz/problem.rb @@ -232,7 +232,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -246,36 +246,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement.rb b/lib/xero-ruby/models/payroll_nz/reimbursement.rb index 7e4898c4..33c55b8b 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement.rb @@ -335,7 +335,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -349,36 +349,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb b/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb index 5f0e2334..21a3f68b 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb b/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb index c115f94a..bebd4057 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/reimbursements.rb b/lib/xero-ruby/models/payroll_nz/reimbursements.rb index 7a19129d..c46fa523 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursements.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursements.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb index 9267751d..7fe9866e 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb @@ -355,7 +355,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -369,36 +369,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb index 0d98af8d..502cf047 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb index 3e9b9cc5..e9cc7c54 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/settings.rb b/lib/xero-ruby/models/payroll_nz/settings.rb index b5b8a31e..6838a76f 100644 --- a/lib/xero-ruby/models/payroll_nz/settings.rb +++ b/lib/xero-ruby/models/payroll_nz/settings.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb index c45f230b..a835e1ff 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb index 5ce3c33d..ea812ba6 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb index e1e8e306..d034ff36 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb b/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb index e1585650..6b13e56c 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/superannuation_line.rb b/lib/xero-ruby/models/payroll_nz/superannuation_line.rb index f6f66494..6d745664 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuation_line.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuation_line.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/superannuation_object.rb b/lib/xero-ruby/models/payroll_nz/superannuation_object.rb index 31b18d25..7cd33e3d 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuation_object.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuation_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/superannuations.rb b/lib/xero-ruby/models/payroll_nz/superannuations.rb index d034f7b4..6d51dfb0 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuations.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuations.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/tax_line.rb b/lib/xero-ruby/models/payroll_nz/tax_line.rb index b46dcaaa..d6feeb23 100644 --- a/lib/xero-ruby/models/payroll_nz/tax_line.rb +++ b/lib/xero-ruby/models/payroll_nz/tax_line.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/tax_settings.rb b/lib/xero-ruby/models/payroll_nz/tax_settings.rb index 17707255..17ce3e0a 100644 --- a/lib/xero-ruby/models/payroll_nz/tax_settings.rb +++ b/lib/xero-ruby/models/payroll_nz/tax_settings.rb @@ -265,7 +265,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -279,36 +279,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/timesheet.rb b/lib/xero-ruby/models/payroll_nz/timesheet.rb index 4d45c7ee..6571d003 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet.rb @@ -319,7 +319,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -333,36 +333,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb b/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb index d64eea2e..f75a9035 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb @@ -269,7 +269,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -283,36 +283,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_line.rb b/lib/xero-ruby/models/payroll_nz/timesheet_line.rb index df744b48..632c10be 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_line.rb @@ -234,7 +234,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -248,36 +248,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb b/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb index 5b98beb9..6fb78ca3 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_object.rb b/lib/xero-ruby/models/payroll_nz/timesheet_object.rb index 09083cd6..e0f7b77c 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/timesheets.rb b/lib/xero-ruby/models/payroll_nz/timesheets.rb index 350e4f5c..ecae2717 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheets.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheets.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/tracking_categories.rb b/lib/xero-ruby/models/payroll_nz/tracking_categories.rb index 77f67f1f..3e53c3e2 100644 --- a/lib/xero-ruby/models/payroll_nz/tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_nz/tracking_categories.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_nz/tracking_category.rb b/lib/xero-ruby/models/payroll_nz/tracking_category.rb index 0831995f..a2c2ba05 100644 --- a/lib/xero-ruby/models/payroll_nz/tracking_category.rb +++ b/lib/xero-ruby/models/payroll_nz/tracking_category.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/account.rb b/lib/xero-ruby/models/payroll_uk/account.rb index dcbeea4f..3de5c076 100644 --- a/lib/xero-ruby/models/payroll_uk/account.rb +++ b/lib/xero-ruby/models/payroll_uk/account.rb @@ -250,7 +250,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -264,36 +264,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/accounts.rb b/lib/xero-ruby/models/payroll_uk/accounts.rb index e80bc298..5298a03d 100644 --- a/lib/xero-ruby/models/payroll_uk/accounts.rb +++ b/lib/xero-ruby/models/payroll_uk/accounts.rb @@ -181,7 +181,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -195,36 +195,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/address.rb b/lib/xero-ruby/models/payroll_uk/address.rb index 6ed7e923..8e59b602 100644 --- a/lib/xero-ruby/models/payroll_uk/address.rb +++ b/lib/xero-ruby/models/payroll_uk/address.rb @@ -234,7 +234,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -248,36 +248,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/bank_account.rb b/lib/xero-ruby/models/payroll_uk/bank_account.rb index b39c505b..8e6240d3 100644 --- a/lib/xero-ruby/models/payroll_uk/bank_account.rb +++ b/lib/xero-ruby/models/payroll_uk/bank_account.rb @@ -214,7 +214,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -228,36 +228,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/benefit.rb b/lib/xero-ruby/models/payroll_uk/benefit.rb index e876a865..cf9e640e 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit.rb @@ -389,7 +389,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -403,36 +403,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/benefit_line.rb b/lib/xero-ruby/models/payroll_uk/benefit_line.rb index 4eb62590..4efd35a5 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit_line.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit_line.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/benefit_object.rb b/lib/xero-ruby/models/payroll_uk/benefit_object.rb index 55a8cd5e..ba5bcf18 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit_object.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/benefits.rb b/lib/xero-ruby/models/payroll_uk/benefits.rb index 94744ea4..854357dd 100644 --- a/lib/xero-ruby/models/payroll_uk/benefits.rb +++ b/lib/xero-ruby/models/payroll_uk/benefits.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/court_order_line.rb b/lib/xero-ruby/models/payroll_uk/court_order_line.rb index c68a367b..8cc91250 100644 --- a/lib/xero-ruby/models/payroll_uk/court_order_line.rb +++ b/lib/xero-ruby/models/payroll_uk/court_order_line.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/deduction.rb b/lib/xero-ruby/models/payroll_uk/deduction.rb index d413a507..a35b2f1a 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction.rb @@ -397,7 +397,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -411,36 +411,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/deduction_line.rb b/lib/xero-ruby/models/payroll_uk/deduction_line.rb index d5ce3c9f..48ddfeaa 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction_line.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/deduction_object.rb b/lib/xero-ruby/models/payroll_uk/deduction_object.rb index d7296f1c..21876c13 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction_object.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/deductions.rb b/lib/xero-ruby/models/payroll_uk/deductions.rb index 951f4e16..e5849e7c 100644 --- a/lib/xero-ruby/models/payroll_uk/deductions.rb +++ b/lib/xero-ruby/models/payroll_uk/deductions.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_line.rb b/lib/xero-ruby/models/payroll_uk/earnings_line.rb index 0cfe5386..d2ff734e 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_line.rb @@ -259,7 +259,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -273,36 +273,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_order.rb b/lib/xero-ruby/models/payroll_uk/earnings_order.rb index 1dc0573f..ad0d5ffe 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_order.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_order.rb @@ -226,7 +226,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -240,36 +240,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb index d3058ab6..d0ae6be6 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_orders.rb b/lib/xero-ruby/models/payroll_uk/earnings_orders.rb index 51940cde..48b562d8 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_orders.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_orders.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rate.rb b/lib/xero-ruby/models/payroll_uk/earnings_rate.rb index 687d3700..bcc9c41c 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rate.rb @@ -365,7 +365,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -379,36 +379,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb index cb0c1515..d7c8f68d 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rates.rb b/lib/xero-ruby/models/payroll_uk/earnings_rates.rb index 00df91d8..d85e9825 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rates.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rates.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_template.rb b/lib/xero-ruby/models/payroll_uk/earnings_template.rb index 2471be78..33812784 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_template.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_template.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb index 9c21d72b..179e8057 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee.rb b/lib/xero-ruby/models/payroll_uk/employee.rb index 7d2f3489..56a1fe72 100644 --- a/lib/xero-ruby/models/payroll_uk/employee.rb +++ b/lib/xero-ruby/models/payroll_uk/employee.rb @@ -355,7 +355,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -369,36 +369,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave.rb b/lib/xero-ruby/models/payroll_uk/employee_leave.rb index a6117591..b2796677 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave.rb @@ -261,7 +261,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -275,36 +275,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb index 5cb124cc..aa533b5a 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb index 22634fe2..90f8b222 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb index 70cd81f2..d3238ea6 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb index db190d7a..f4578bfa 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb @@ -277,7 +277,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -291,36 +291,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb index 2750574b..037674d9 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb index c5798873..3dffca08 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_leaves.rb b/lib/xero-ruby/models/payroll_uk/employee_leaves.rb index 6e6fb287..cb289bab 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leaves.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leaves.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_object.rb b/lib/xero-ruby/models/payroll_uk/employee_object.rb index c22559fc..75febe51 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb b/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb index ab1c8c0a..18a3f7c6 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb b/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb index 01201105..545a518a 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb index 304d2a10..fc9892b6 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb index eaefabca..ad89aecd 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb index bceb704b..4c7c75cd 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb index f65da3f1..a07d6ad2 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb @@ -251,7 +251,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -265,36 +265,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb index b6438501..a7d8d994 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb index 2691006a..41417a0b 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb @@ -293,7 +293,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -307,36 +307,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb index f778f6cd..7cb48c0f 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb index 9eba4ebe..43072c1b 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb @@ -390,7 +390,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -404,36 +404,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb index b900b026..909a95d1 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb index e0847d27..9d9ed36d 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_tax.rb b/lib/xero-ruby/models/payroll_uk/employee_tax.rb index 94a0cb76..ed80aeea 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_tax.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_tax.rb @@ -279,7 +279,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -293,36 +293,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb b/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb index a19311f5..dc8f76d3 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employees.rb b/lib/xero-ruby/models/payroll_uk/employees.rb index 8b68e4b1..1d2a491e 100644 --- a/lib/xero-ruby/models/payroll_uk/employees.rb +++ b/lib/xero-ruby/models/payroll_uk/employees.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employment.rb b/lib/xero-ruby/models/payroll_uk/employment.rb index 556917f6..62b4a088 100644 --- a/lib/xero-ruby/models/payroll_uk/employment.rb +++ b/lib/xero-ruby/models/payroll_uk/employment.rb @@ -251,7 +251,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -265,36 +265,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/employment_object.rb b/lib/xero-ruby/models/payroll_uk/employment_object.rb index 06bfdb6e..0811a109 100644 --- a/lib/xero-ruby/models/payroll_uk/employment_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employment_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/invalid_field.rb b/lib/xero-ruby/models/payroll_uk/invalid_field.rb index 1e4ecee2..6e98bbde 100644 --- a/lib/xero-ruby/models/payroll_uk/invalid_field.rb +++ b/lib/xero-ruby/models/payroll_uk/invalid_field.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb index 79f2a900..29a38aa6 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb index a910e0bb..ec58e78e 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/leave_period.rb b/lib/xero-ruby/models/payroll_uk/leave_period.rb index d442a17a..1288bc7a 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_period.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_period.rb @@ -245,7 +245,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -259,36 +259,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/leave_periods.rb b/lib/xero-ruby/models/payroll_uk/leave_periods.rb index 6dc2bbed..05c5d22b 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_periods.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_periods.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/leave_type.rb b/lib/xero-ruby/models/payroll_uk/leave_type.rb index 64a69f91..e7df9947 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_type.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_type.rb @@ -264,7 +264,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -278,36 +278,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/leave_type_object.rb b/lib/xero-ruby/models/payroll_uk/leave_type_object.rb index 2499a990..d86494b1 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_type_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/leave_types.rb b/lib/xero-ruby/models/payroll_uk/leave_types.rb index 9f3787d7..cc41b1e3 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_types.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_types.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/pagination.rb b/lib/xero-ruby/models/payroll_uk/pagination.rb index 5b9c2515..4cec3095 100644 --- a/lib/xero-ruby/models/payroll_uk/pagination.rb +++ b/lib/xero-ruby/models/payroll_uk/pagination.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/pay_run.rb b/lib/xero-ruby/models/payroll_uk/pay_run.rb index 55931c43..da1d74bd 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run.rb @@ -360,7 +360,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -374,36 +374,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb index c171641f..0aee70c3 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb @@ -299,7 +299,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -313,36 +313,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb index ff4fdb90..3d45965e 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb index 98066a9d..65246846 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_object.rb b/lib/xero-ruby/models/payroll_uk/pay_run_object.rb index 98b61a0a..0c338373 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_object.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/pay_runs.rb b/lib/xero-ruby/models/payroll_uk/pay_runs.rb index 4448bc79..384e16c3 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_runs.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/payment_line.rb b/lib/xero-ruby/models/payroll_uk/payment_line.rb index ed43148e..e5e3a57b 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_line.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_line.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/payment_method.rb b/lib/xero-ruby/models/payroll_uk/payment_method.rb index 88f67491..1b20de40 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_method.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_method.rb @@ -233,7 +233,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -247,36 +247,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/payment_method_object.rb b/lib/xero-ruby/models/payroll_uk/payment_method_object.rb index 3f23b6d0..5a113d6d 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_method_object.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_method_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/payslip.rb b/lib/xero-ruby/models/payroll_uk/payslip.rb index 6667314e..79326675 100644 --- a/lib/xero-ruby/models/payroll_uk/payslip.rb +++ b/lib/xero-ruby/models/payroll_uk/payslip.rb @@ -508,7 +508,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -522,36 +522,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/payslip_object.rb b/lib/xero-ruby/models/payroll_uk/payslip_object.rb index a60d6272..5083f230 100644 --- a/lib/xero-ruby/models/payroll_uk/payslip_object.rb +++ b/lib/xero-ruby/models/payroll_uk/payslip_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/payslips.rb b/lib/xero-ruby/models/payroll_uk/payslips.rb index 69c6d346..84bbb645 100644 --- a/lib/xero-ruby/models/payroll_uk/payslips.rb +++ b/lib/xero-ruby/models/payroll_uk/payslips.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/problem.rb b/lib/xero-ruby/models/payroll_uk/problem.rb index 99ae890a..b69ab569 100644 --- a/lib/xero-ruby/models/payroll_uk/problem.rb +++ b/lib/xero-ruby/models/payroll_uk/problem.rb @@ -232,7 +232,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -246,36 +246,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement.rb b/lib/xero-ruby/models/payroll_uk/reimbursement.rb index c693d18d..79760b9f 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb b/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb index 41d3ccee..092f0ee8 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb b/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb index 5272b89e..d4041e17 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/reimbursements.rb b/lib/xero-ruby/models/payroll_uk/reimbursements.rb index c62433aa..29f5fa91 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursements.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursements.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb index 7b55fa1c..c75e6268 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb @@ -340,7 +340,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -354,36 +354,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb index e11e1f0b..686f6b36 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb index 11816691..a7ff5967 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/settings.rb b/lib/xero-ruby/models/payroll_uk/settings.rb index 148a3c2b..ef57c1d7 100644 --- a/lib/xero-ruby/models/payroll_uk/settings.rb +++ b/lib/xero-ruby/models/payroll_uk/settings.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb b/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb index 5fafccbb..19631be6 100644 --- a/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb +++ b/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb @@ -219,7 +219,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -233,36 +233,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/tax_line.rb b/lib/xero-ruby/models/payroll_uk/tax_line.rb index 7210c0ed..1ff643a6 100644 --- a/lib/xero-ruby/models/payroll_uk/tax_line.rb +++ b/lib/xero-ruby/models/payroll_uk/tax_line.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/timesheet.rb b/lib/xero-ruby/models/payroll_uk/timesheet.rb index 878a436e..d8e7fe29 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet.rb @@ -318,7 +318,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -332,36 +332,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb b/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb index 15e350c9..1963acb4 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb @@ -229,7 +229,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -243,36 +243,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_line.rb b/lib/xero-ruby/models/payroll_uk/timesheet_line.rb index 713bd887..10e5916e 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_line.rb @@ -234,7 +234,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -248,36 +248,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb b/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb index 9b6dbe6c..69686912 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_object.rb b/lib/xero-ruby/models/payroll_uk/timesheet_object.rb index eaafe5f8..e7c352c7 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_object.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/timesheets.rb b/lib/xero-ruby/models/payroll_uk/timesheets.rb index 9cc9bed4..d3678f86 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheets.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheets.rb @@ -201,7 +201,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -215,36 +215,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/tracking_categories.rb b/lib/xero-ruby/models/payroll_uk/tracking_categories.rb index c5e16843..f533a9d8 100644 --- a/lib/xero-ruby/models/payroll_uk/tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_uk/tracking_categories.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/payroll_uk/tracking_category.rb b/lib/xero-ruby/models/payroll_uk/tracking_category.rb index a238146e..8c292e0b 100644 --- a/lib/xero-ruby/models/payroll_uk/tracking_category.rb +++ b/lib/xero-ruby/models/payroll_uk/tracking_category.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/amount.rb b/lib/xero-ruby/models/projects/amount.rb index e98a85a4..c700868a 100644 --- a/lib/xero-ruby/models/projects/amount.rb +++ b/lib/xero-ruby/models/projects/amount.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/error.rb b/lib/xero-ruby/models/projects/error.rb index 83c69342..f07081d5 100644 --- a/lib/xero-ruby/models/projects/error.rb +++ b/lib/xero-ruby/models/projects/error.rb @@ -189,7 +189,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -203,36 +203,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/pagination.rb b/lib/xero-ruby/models/projects/pagination.rb index 6a53b37b..5f35266b 100644 --- a/lib/xero-ruby/models/projects/pagination.rb +++ b/lib/xero-ruby/models/projects/pagination.rb @@ -209,7 +209,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -223,36 +223,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/project.rb b/lib/xero-ruby/models/projects/project.rb index 2534da12..9553e5e3 100644 --- a/lib/xero-ruby/models/projects/project.rb +++ b/lib/xero-ruby/models/projects/project.rb @@ -394,7 +394,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -408,36 +408,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/project_create_or_update.rb b/lib/xero-ruby/models/projects/project_create_or_update.rb index dfabfd71..a1f06987 100644 --- a/lib/xero-ruby/models/projects/project_create_or_update.rb +++ b/lib/xero-ruby/models/projects/project_create_or_update.rb @@ -214,7 +214,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -228,36 +228,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/project_patch.rb b/lib/xero-ruby/models/projects/project_patch.rb index 7388ab87..52f97d1a 100644 --- a/lib/xero-ruby/models/projects/project_patch.rb +++ b/lib/xero-ruby/models/projects/project_patch.rb @@ -184,7 +184,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -198,36 +198,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/project_user.rb b/lib/xero-ruby/models/projects/project_user.rb index fb047060..59dc6372 100644 --- a/lib/xero-ruby/models/projects/project_user.rb +++ b/lib/xero-ruby/models/projects/project_user.rb @@ -199,7 +199,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -213,36 +213,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/project_users.rb b/lib/xero-ruby/models/projects/project_users.rb index d56325cb..680e19b7 100644 --- a/lib/xero-ruby/models/projects/project_users.rb +++ b/lib/xero-ruby/models/projects/project_users.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/projects.rb b/lib/xero-ruby/models/projects/projects.rb index d5ac20a2..8c2722b2 100644 --- a/lib/xero-ruby/models/projects/projects.rb +++ b/lib/xero-ruby/models/projects/projects.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/task.rb b/lib/xero-ruby/models/projects/task.rb index 7740ecca..1e9089e8 100644 --- a/lib/xero-ruby/models/projects/task.rb +++ b/lib/xero-ruby/models/projects/task.rb @@ -356,7 +356,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -370,36 +370,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/task_create_or_update.rb b/lib/xero-ruby/models/projects/task_create_or_update.rb index 98549073..ae7e264f 100644 --- a/lib/xero-ruby/models/projects/task_create_or_update.rb +++ b/lib/xero-ruby/models/projects/task_create_or_update.rb @@ -224,7 +224,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -238,36 +238,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/tasks.rb b/lib/xero-ruby/models/projects/tasks.rb index faab5d9a..9261234c 100644 --- a/lib/xero-ruby/models/projects/tasks.rb +++ b/lib/xero-ruby/models/projects/tasks.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/time_entries.rb b/lib/xero-ruby/models/projects/time_entries.rb index befa788e..3a6b00a6 100644 --- a/lib/xero-ruby/models/projects/time_entries.rb +++ b/lib/xero-ruby/models/projects/time_entries.rb @@ -191,7 +191,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -205,36 +205,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/time_entry.rb b/lib/xero-ruby/models/projects/time_entry.rb index 66747a61..a58416b0 100644 --- a/lib/xero-ruby/models/projects/time_entry.rb +++ b/lib/xero-ruby/models/projects/time_entry.rb @@ -296,7 +296,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -310,36 +310,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/models/projects/time_entry_create_or_update.rb b/lib/xero-ruby/models/projects/time_entry_create_or_update.rb index 8862c503..940547f8 100644 --- a/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +++ b/lib/xero-ruby/models/projects/time_entry_create_or_update.rb @@ -239,7 +239,7 @@ def to_hash(downcase: false) value = self.send(attr) next if value.nil? key = downcase ? attr : param - hash[key] = _to_hash(value, param, downcase: downcase) + hash[key] = _to_hash(value, downcase: downcase) end hash end @@ -253,36 +253,40 @@ def to_attributes # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash - def _to_hash(value, param, downcase: false) - puts "2 ***********" - puts "value: #{value}" + def _to_hash(value, downcase: false) if value.is_a?(Array) - puts "2.a ARRAY" - puts "this means its a nested model, right" value.map do |v| - n = param.length - model_name_without_trailing_s = param[0..n-2] - to_hash_value = self.class.module_parent.const_get(model_name_without_trailing_s).build_from_hash(v).to_hash(downcase: downcase) - puts "to_hash_value.class #{to_hash_value.class}" - puts "to_hash_value #{to_hash_value}" - sleep 1 + to_hash_value = v.to_hash(downcase: downcase) to_hash_value end # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) - puts "2.b HASH" {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + binding.pry + value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - puts "2.c respond to hash?" value.to_hash else - puts "2.d just value?" value end end + # def deplurarlized_model_name_from(param) + # n = param.length + # case param + # when 'Addresses' + # 'Address' + # when 'TrackingCategories' + # 'TrackingCategory' + # else + # puts "param -> #{param}" + # puts "param[0..n-2] -> #{param[0..n-2]}" + # puts "********************************" + # param[0..n-2] + # end + # end + def parse_date(datestring) if datestring.include?('Date') seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 diff --git a/lib/xero-ruby/version.rb b/lib/xero-ruby/version.rb index 05a4aeac..1f1eb550 100644 --- a/lib/xero-ruby/version.rb +++ b/lib/xero-ruby/version.rb @@ -7,9 +7,9 @@ Generated by: https://openapi-generator.tech OpenAPI Generator version: 4.3.1 -The version of the XeroOpenAPI document: 2.11.1 +The version of the XeroOpenAPI document: 2.12.0 =end module XeroRuby - VERSION = '2.10.2' + VERSION = '2.11.0' end From c1f233bf1f50aa47e07c6bca38ab792c1d951ff4 Mon Sep 17 00:00:00 2001 From: serknight Date: Tue, 11 May 2021 10:51:32 -0600 Subject: [PATCH 3/7] fix for ms date parsing edge cases --- lib/xero-ruby/models/accounting/accounts.rb | 27 ++++--------------- .../models/accounting/accounts_payable.rb | 27 ++++--------------- .../models/accounting/accounts_receivable.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/action.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/actions.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/address.rb | 27 ++++--------------- .../accounting/address_for_organisation.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/allocation.rb | 27 ++++--------------- .../models/accounting/allocations.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/attachment.rb | 27 ++++--------------- .../models/accounting/attachments.rb | 27 ++++--------------- .../models/accounting/balance_details.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/balances.rb | 27 ++++--------------- .../models/accounting/bank_transaction.rb | 27 ++++--------------- .../models/accounting/bank_transactions.rb | 27 ++++--------------- .../models/accounting/bank_transfer.rb | 27 ++++--------------- .../models/accounting/bank_transfers.rb | 27 ++++--------------- .../models/accounting/batch_payment.rb | 27 ++++--------------- .../accounting/batch_payment_details.rb | 27 ++++--------------- .../models/accounting/batch_payments.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/bill.rb | 27 ++++--------------- .../models/accounting/branding_theme.rb | 27 ++++--------------- .../models/accounting/branding_themes.rb | 27 ++++--------------- .../models/accounting/cis_org_setting.rb | 27 ++++--------------- .../models/accounting/cis_org_settings.rb | 27 ++++--------------- .../models/accounting/cis_setting.rb | 27 ++++--------------- .../models/accounting/cis_settings.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/contact.rb | 27 ++++--------------- .../models/accounting/contact_group.rb | 27 ++++--------------- .../models/accounting/contact_groups.rb | 27 ++++--------------- .../models/accounting/contact_person.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/contacts.rb | 27 ++++--------------- .../models/accounting/conversion_balances.rb | 27 ++++--------------- .../models/accounting/conversion_date.rb | 27 ++++--------------- .../models/accounting/credit_note.rb | 27 ++++--------------- .../models/accounting/credit_notes.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/currencies.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/currency.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/element.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/employee.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/employees.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/error.rb | 27 ++++--------------- .../models/accounting/expense_claim.rb | 27 ++++--------------- .../models/accounting/expense_claims.rb | 27 ++++--------------- .../models/accounting/external_link.rb | 27 ++++--------------- .../models/accounting/history_record.rb | 27 ++++--------------- .../models/accounting/history_records.rb | 27 ++++--------------- .../models/accounting/import_summary.rb | 27 ++++--------------- .../accounting/import_summary_accounts.rb | 27 ++++--------------- .../accounting/import_summary_object.rb | 27 ++++--------------- .../accounting/import_summary_organisation.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/invoice.rb | 27 ++++--------------- .../models/accounting/invoice_reminder.rb | 27 ++++--------------- .../models/accounting/invoice_reminders.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/invoices.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/item.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/items.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/journal.rb | 27 ++++--------------- .../models/accounting/journal_line.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/journals.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/line_item.rb | 27 ++++--------------- .../models/accounting/line_item_tracking.rb | 27 ++++--------------- .../models/accounting/linked_transaction.rb | 27 ++++--------------- .../models/accounting/linked_transactions.rb | 27 ++++--------------- .../models/accounting/manual_journal.rb | 27 ++++--------------- .../models/accounting/manual_journal_line.rb | 27 ++++--------------- .../models/accounting/manual_journals.rb | 27 ++++--------------- .../models/accounting/online_invoice.rb | 27 ++++--------------- .../models/accounting/online_invoices.rb | 27 ++++--------------- .../models/accounting/organisations.rb | 27 ++++--------------- .../models/accounting/overpayment.rb | 27 ++++--------------- .../models/accounting/overpayments.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/payment.rb | 27 ++++--------------- .../models/accounting/payment_delete.rb | 27 ++++--------------- .../models/accounting/payment_service.rb | 27 ++++--------------- .../models/accounting/payment_services.rb | 27 ++++--------------- .../models/accounting/payment_term.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/payments.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/phone.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/prepayment.rb | 27 ++++--------------- .../models/accounting/prepayments.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/purchase.rb | 27 ++++--------------- .../models/accounting/purchase_order.rb | 27 ++++--------------- .../models/accounting/purchase_orders.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/quote.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/quotes.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/receipt.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/receipts.rb | 27 ++++--------------- .../models/accounting/repeating_invoice.rb | 27 ++++--------------- .../models/accounting/repeating_invoices.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/report.rb | 27 ++++--------------- .../models/accounting/report_attribute.rb | 27 ++++--------------- .../models/accounting/report_cell.rb | 27 ++++--------------- .../models/accounting/report_fields.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/report_row.rb | 27 ++++--------------- .../models/accounting/report_rows.rb | 27 ++++--------------- .../models/accounting/report_with_row.rb | 27 ++++--------------- .../models/accounting/report_with_rows.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/reports.rb | 27 ++++--------------- .../models/accounting/request_empty.rb | 27 ++++--------------- .../accounting/sales_tracking_category.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/schedule.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/setup.rb | 27 ++++--------------- .../models/accounting/tax_component.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/tax_rate.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/tax_rates.rb | 27 ++++--------------- .../accounting/ten_ninety_nine_contact.rb | 27 ++++--------------- .../models/accounting/tracking_categories.rb | 27 ++++--------------- .../models/accounting/tracking_category.rb | 27 ++++--------------- .../models/accounting/tracking_option.rb | 27 ++++--------------- .../models/accounting/tracking_options.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/user.rb | 27 ++++--------------- lib/xero-ruby/models/accounting/users.rb | 27 ++++--------------- .../models/accounting/validation_error.rb | 27 ++++--------------- lib/xero-ruby/models/assets/asset.rb | 27 ++++--------------- lib/xero-ruby/models/assets/asset_type.rb | 27 ++++--------------- lib/xero-ruby/models/assets/assets.rb | 27 ++++--------------- .../models/assets/book_depreciation_detail.rb | 27 ++++--------------- .../assets/book_depreciation_setting.rb | 27 ++++--------------- lib/xero-ruby/models/assets/error.rb | 27 ++++--------------- .../assets/field_validation_errors_element.rb | 27 ++++--------------- lib/xero-ruby/models/assets/pagination.rb | 27 ++++--------------- .../resource_validation_errors_element.rb | 27 ++++--------------- lib/xero-ruby/models/assets/setting.rb | 27 ++++--------------- lib/xero-ruby/models/files/association.rb | 27 ++++--------------- lib/xero-ruby/models/files/file_object.rb | 27 ++++--------------- lib/xero-ruby/models/files/files.rb | 27 ++++--------------- lib/xero-ruby/models/files/folder.rb | 27 ++++--------------- lib/xero-ruby/models/files/folders.rb | 27 ++++--------------- lib/xero-ruby/models/files/upload_object.rb | 27 ++++--------------- lib/xero-ruby/models/files/user.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/account.rb | 27 ++++--------------- .../models/payroll_au/api_exception.rb | 27 ++++--------------- .../models/payroll_au/bank_account.rb | 27 ++++--------------- .../models/payroll_au/deduction_line.rb | 27 ++++--------------- .../models/payroll_au/deduction_type.rb | 27 ++++--------------- .../models/payroll_au/earnings_line.rb | 27 ++++--------------- .../models/payroll_au/earnings_rate.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/employee.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/employees.rb | 27 ++++--------------- .../models/payroll_au/home_address.rb | 27 ++++--------------- .../models/payroll_au/leave_accrual_line.rb | 27 ++++--------------- .../models/payroll_au/leave_application.rb | 27 ++++--------------- .../models/payroll_au/leave_applications.rb | 27 ++++--------------- .../models/payroll_au/leave_balance.rb | 27 ++++--------------- .../models/payroll_au/leave_earnings_line.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/leave_line.rb | 27 ++++--------------- .../models/payroll_au/leave_lines.rb | 27 ++++--------------- .../models/payroll_au/leave_period.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/leave_type.rb | 27 ++++--------------- .../models/payroll_au/opening_balances.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/pay_item.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/pay_items.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/pay_run.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/pay_runs.rb | 27 ++++--------------- .../models/payroll_au/pay_template.rb | 27 ++++--------------- .../models/payroll_au/payroll_calendar.rb | 27 ++++--------------- .../models/payroll_au/payroll_calendars.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/payslip.rb | 27 ++++--------------- .../models/payroll_au/payslip_lines.rb | 27 ++++--------------- .../models/payroll_au/payslip_object.rb | 27 ++++--------------- .../models/payroll_au/payslip_summary.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/payslips.rb | 27 ++++--------------- .../models/payroll_au/reimbursement_line.rb | 27 ++++--------------- .../models/payroll_au/reimbursement_lines.rb | 27 ++++--------------- .../models/payroll_au/reimbursement_type.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/settings.rb | 27 ++++--------------- .../models/payroll_au/settings_object.rb | 27 ++++--------------- .../settings_tracking_categories.rb | 27 ++++--------------- ...ngs_tracking_categories_employee_groups.rb | 27 ++++--------------- ...racking_categories_timesheet_categories.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/super_fund.rb | 27 ++++--------------- .../models/payroll_au/super_fund_product.rb | 27 ++++--------------- .../models/payroll_au/super_fund_products.rb | 27 ++++--------------- .../models/payroll_au/super_funds.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/super_line.rb | 27 ++++--------------- .../models/payroll_au/super_membership.rb | 27 ++++--------------- .../models/payroll_au/superannuation_line.rb | 27 ++++--------------- .../models/payroll_au/tax_declaration.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/tax_line.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/timesheet.rb | 27 ++++--------------- .../models/payroll_au/timesheet_line.rb | 27 ++++--------------- .../models/payroll_au/timesheet_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_au/timesheets.rb | 27 ++++--------------- .../models/payroll_au/validation_error.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/account.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/accounts.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/address.rb | 27 ++++--------------- .../models/payroll_nz/bank_account.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/benefit.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/deduction.rb | 27 ++++--------------- .../models/payroll_nz/deduction_line.rb | 27 ++++--------------- .../models/payroll_nz/deduction_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/deductions.rb | 27 ++++--------------- .../models/payroll_nz/earnings_line.rb | 27 ++++--------------- .../models/payroll_nz/earnings_order.rb | 27 ++++--------------- .../payroll_nz/earnings_order_object.rb | 27 ++++--------------- .../models/payroll_nz/earnings_orders.rb | 27 ++++--------------- .../models/payroll_nz/earnings_rate.rb | 27 ++++--------------- .../models/payroll_nz/earnings_rate_object.rb | 27 ++++--------------- .../models/payroll_nz/earnings_rates.rb | 27 ++++--------------- .../models/payroll_nz/earnings_template.rb | 27 ++++--------------- .../payroll_nz/earnings_template_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/employee.rb | 27 ++++--------------- .../payroll_nz/employee_earnings_templates.rb | 27 ++++--------------- .../models/payroll_nz/employee_leave.rb | 27 ++++--------------- .../payroll_nz/employee_leave_balance.rb | 27 ++++--------------- .../payroll_nz/employee_leave_balances.rb | 27 ++++--------------- .../payroll_nz/employee_leave_object.rb | 27 ++++--------------- .../models/payroll_nz/employee_leave_setup.rb | 27 ++++--------------- .../payroll_nz/employee_leave_setup_object.rb | 27 ++++--------------- .../models/payroll_nz/employee_leave_type.rb | 27 ++++--------------- .../payroll_nz/employee_leave_type_object.rb | 27 ++++--------------- .../models/payroll_nz/employee_leave_types.rb | 27 ++++--------------- .../models/payroll_nz/employee_leaves.rb | 27 ++++--------------- .../models/payroll_nz/employee_object.rb | 27 ++++--------------- .../payroll_nz/employee_opening_balance.rb | 27 ++++--------------- .../employee_opening_balances_object.rb | 27 ++++--------------- .../payroll_nz/employee_pay_template.rb | 27 ++++--------------- .../employee_pay_template_object.rb | 27 ++++--------------- .../payroll_nz/employee_pay_templates.rb | 27 ++++--------------- .../employee_statutory_leave_balance.rb | 27 ++++--------------- ...employee_statutory_leave_balance_object.rb | 27 ++++--------------- .../employee_statutory_leave_summary.rb | 27 ++++--------------- .../employee_statutory_leaves_summaries.rb | 27 ++++--------------- .../employee_statutory_sick_leave.rb | 27 ++++--------------- .../employee_statutory_sick_leave_object.rb | 27 ++++--------------- .../employee_statutory_sick_leaves.rb | 27 ++++--------------- .../models/payroll_nz/employee_tax.rb | 27 ++++--------------- .../models/payroll_nz/employee_tax_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/employees.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/employment.rb | 27 ++++--------------- .../models/payroll_nz/employment_object.rb | 27 ++++--------------- .../payroll_nz/gross_earnings_history.rb | 27 ++++--------------- .../models/payroll_nz/invalid_field.rb | 27 ++++--------------- .../models/payroll_nz/leave_accrual_line.rb | 27 ++++--------------- .../models/payroll_nz/leave_earnings_line.rb | 27 ++++--------------- .../models/payroll_nz/leave_period.rb | 27 ++++--------------- .../models/payroll_nz/leave_periods.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/leave_type.rb | 27 ++++--------------- .../models/payroll_nz/leave_type_object.rb | 27 ++++--------------- .../models/payroll_nz/leave_types.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/pagination.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/pay_run.rb | 27 ++++--------------- .../models/payroll_nz/pay_run_calendar.rb | 27 ++++--------------- .../payroll_nz/pay_run_calendar_object.rb | 27 ++++--------------- .../models/payroll_nz/pay_run_calendars.rb | 27 ++++--------------- .../models/payroll_nz/pay_run_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/pay_runs.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/pay_slip.rb | 27 ++++--------------- .../models/payroll_nz/pay_slip_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/pay_slips.rb | 27 ++++--------------- .../models/payroll_nz/payment_line.rb | 27 ++++--------------- .../models/payroll_nz/payment_method.rb | 27 ++++--------------- .../payroll_nz/payment_method_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/problem.rb | 27 ++++--------------- .../models/payroll_nz/reimbursement.rb | 27 ++++--------------- .../models/payroll_nz/reimbursement_line.rb | 27 ++++--------------- .../models/payroll_nz/reimbursement_object.rb | 27 ++++--------------- .../models/payroll_nz/reimbursements.rb | 27 ++++--------------- .../models/payroll_nz/salary_and_wage.rb | 27 ++++--------------- .../payroll_nz/salary_and_wage_object.rb | 27 ++++--------------- .../models/payroll_nz/salary_and_wages.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/settings.rb | 27 ++++--------------- .../models/payroll_nz/statutory_deduction.rb | 27 ++++--------------- .../payroll_nz/statutory_deduction_line.rb | 27 ++++--------------- .../payroll_nz/statutory_deduction_object.rb | 27 ++++--------------- .../models/payroll_nz/statutory_deductions.rb | 27 ++++--------------- .../models/payroll_nz/superannuation_line.rb | 27 ++++--------------- .../payroll_nz/superannuation_object.rb | 27 ++++--------------- .../models/payroll_nz/superannuations.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/tax_line.rb | 27 ++++--------------- .../models/payroll_nz/tax_settings.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/timesheet.rb | 27 ++++--------------- .../payroll_nz/timesheet_earnings_line.rb | 27 ++++--------------- .../models/payroll_nz/timesheet_line.rb | 27 ++++--------------- .../payroll_nz/timesheet_line_object.rb | 27 ++++--------------- .../models/payroll_nz/timesheet_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_nz/timesheets.rb | 27 ++++--------------- .../models/payroll_nz/tracking_categories.rb | 27 ++++--------------- .../models/payroll_nz/tracking_category.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/account.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/accounts.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/address.rb | 27 ++++--------------- .../models/payroll_uk/bank_account.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/benefit.rb | 27 ++++--------------- .../models/payroll_uk/benefit_line.rb | 27 ++++--------------- .../models/payroll_uk/benefit_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/benefits.rb | 27 ++++--------------- .../models/payroll_uk/court_order_line.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/deduction.rb | 27 ++++--------------- .../models/payroll_uk/deduction_line.rb | 27 ++++--------------- .../models/payroll_uk/deduction_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/deductions.rb | 27 ++++--------------- .../models/payroll_uk/earnings_line.rb | 27 ++++--------------- .../models/payroll_uk/earnings_order.rb | 27 ++++--------------- .../payroll_uk/earnings_order_object.rb | 27 ++++--------------- .../models/payroll_uk/earnings_orders.rb | 27 ++++--------------- .../models/payroll_uk/earnings_rate.rb | 27 ++++--------------- .../models/payroll_uk/earnings_rate_object.rb | 27 ++++--------------- .../models/payroll_uk/earnings_rates.rb | 27 ++++--------------- .../models/payroll_uk/earnings_template.rb | 27 ++++--------------- .../payroll_uk/earnings_template_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/employee.rb | 27 ++++--------------- .../models/payroll_uk/employee_leave.rb | 27 ++++--------------- .../payroll_uk/employee_leave_balance.rb | 27 ++++--------------- .../payroll_uk/employee_leave_balances.rb | 27 ++++--------------- .../payroll_uk/employee_leave_object.rb | 27 ++++--------------- .../models/payroll_uk/employee_leave_type.rb | 27 ++++--------------- .../payroll_uk/employee_leave_type_object.rb | 27 ++++--------------- .../models/payroll_uk/employee_leave_types.rb | 27 ++++--------------- .../models/payroll_uk/employee_leaves.rb | 27 ++++--------------- .../models/payroll_uk/employee_object.rb | 27 ++++--------------- .../payroll_uk/employee_opening_balances.rb | 27 ++++--------------- .../employee_opening_balances_object.rb | 27 ++++--------------- .../payroll_uk/employee_pay_template.rb | 27 ++++--------------- .../employee_pay_template_object.rb | 27 ++++--------------- .../payroll_uk/employee_pay_templates.rb | 27 ++++--------------- .../employee_statutory_leave_balance.rb | 27 ++++--------------- ...employee_statutory_leave_balance_object.rb | 27 ++++--------------- .../employee_statutory_leave_summary.rb | 27 ++++--------------- .../employee_statutory_leaves_summaries.rb | 27 ++++--------------- .../employee_statutory_sick_leave.rb | 27 ++++--------------- .../employee_statutory_sick_leave_object.rb | 27 ++++--------------- .../employee_statutory_sick_leaves.rb | 27 ++++--------------- .../models/payroll_uk/employee_tax.rb | 27 ++++--------------- .../models/payroll_uk/employee_tax_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/employees.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/employment.rb | 27 ++++--------------- .../models/payroll_uk/employment_object.rb | 27 ++++--------------- .../models/payroll_uk/invalid_field.rb | 27 ++++--------------- .../models/payroll_uk/leave_accrual_line.rb | 27 ++++--------------- .../models/payroll_uk/leave_earnings_line.rb | 27 ++++--------------- .../models/payroll_uk/leave_period.rb | 27 ++++--------------- .../models/payroll_uk/leave_periods.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/leave_type.rb | 27 ++++--------------- .../models/payroll_uk/leave_type_object.rb | 27 ++++--------------- .../models/payroll_uk/leave_types.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/pagination.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/pay_run.rb | 27 ++++--------------- .../models/payroll_uk/pay_run_calendar.rb | 27 ++++--------------- .../payroll_uk/pay_run_calendar_object.rb | 27 ++++--------------- .../models/payroll_uk/pay_run_calendars.rb | 27 ++++--------------- .../models/payroll_uk/pay_run_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/pay_runs.rb | 27 ++++--------------- .../models/payroll_uk/payment_line.rb | 27 ++++--------------- .../models/payroll_uk/payment_method.rb | 27 ++++--------------- .../payroll_uk/payment_method_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/payslip.rb | 27 ++++--------------- .../models/payroll_uk/payslip_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/payslips.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/problem.rb | 27 ++++--------------- .../models/payroll_uk/reimbursement.rb | 27 ++++--------------- .../models/payroll_uk/reimbursement_line.rb | 27 ++++--------------- .../models/payroll_uk/reimbursement_object.rb | 27 ++++--------------- .../models/payroll_uk/reimbursements.rb | 27 ++++--------------- .../models/payroll_uk/salary_and_wage.rb | 27 ++++--------------- .../payroll_uk/salary_and_wage_object.rb | 27 ++++--------------- .../models/payroll_uk/salary_and_wages.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/settings.rb | 27 ++++--------------- .../models/payroll_uk/statutory_deduction.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/tax_line.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/timesheet.rb | 27 ++++--------------- .../payroll_uk/timesheet_earnings_line.rb | 27 ++++--------------- .../models/payroll_uk/timesheet_line.rb | 27 ++++--------------- .../payroll_uk/timesheet_line_object.rb | 27 ++++--------------- .../models/payroll_uk/timesheet_object.rb | 27 ++++--------------- lib/xero-ruby/models/payroll_uk/timesheets.rb | 27 ++++--------------- .../models/payroll_uk/tracking_categories.rb | 27 ++++--------------- .../models/payroll_uk/tracking_category.rb | 27 ++++--------------- lib/xero-ruby/models/projects/amount.rb | 27 ++++--------------- lib/xero-ruby/models/projects/error.rb | 27 ++++--------------- lib/xero-ruby/models/projects/pagination.rb | 27 ++++--------------- lib/xero-ruby/models/projects/project.rb | 27 ++++--------------- .../projects/project_create_or_update.rb | 27 ++++--------------- .../models/projects/project_patch.rb | 27 ++++--------------- lib/xero-ruby/models/projects/project_user.rb | 27 ++++--------------- .../models/projects/project_users.rb | 27 ++++--------------- lib/xero-ruby/models/projects/projects.rb | 27 ++++--------------- lib/xero-ruby/models/projects/task.rb | 27 ++++--------------- .../models/projects/task_create_or_update.rb | 27 ++++--------------- lib/xero-ruby/models/projects/tasks.rb | 27 ++++--------------- lib/xero-ruby/models/projects/time_entries.rb | 27 ++++--------------- lib/xero-ruby/models/projects/time_entry.rb | 27 ++++--------------- .../projects/time_entry_create_or_update.rb | 27 ++++--------------- 385 files changed, 1925 insertions(+), 8470 deletions(-) diff --git a/lib/xero-ruby/models/accounting/accounts.rb b/lib/xero-ruby/models/accounting/accounts.rb index cd869db9..42a257ad 100644 --- a/lib/xero-ruby/models/accounting/accounts.rb +++ b/lib/xero-ruby/models/accounting/accounts.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/accounts_payable.rb b/lib/xero-ruby/models/accounting/accounts_payable.rb index ca253ba1..02f817b2 100644 --- a/lib/xero-ruby/models/accounting/accounts_payable.rb +++ b/lib/xero-ruby/models/accounting/accounts_payable.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/accounts_receivable.rb b/lib/xero-ruby/models/accounting/accounts_receivable.rb index d9040555..70aeab3e 100644 --- a/lib/xero-ruby/models/accounting/accounts_receivable.rb +++ b/lib/xero-ruby/models/accounting/accounts_receivable.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/action.rb b/lib/xero-ruby/models/accounting/action.rb index 8b0f5d8f..ec8b5b39 100644 --- a/lib/xero-ruby/models/accounting/action.rb +++ b/lib/xero-ruby/models/accounting/action.rb @@ -219,9 +219,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -248,35 +245,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/actions.rb b/lib/xero-ruby/models/accounting/actions.rb index 4f4f6aca..f3f55684 100644 --- a/lib/xero-ruby/models/accounting/actions.rb +++ b/lib/xero-ruby/models/accounting/actions.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/address.rb b/lib/xero-ruby/models/accounting/address.rb index 0de123fb..556268c2 100644 --- a/lib/xero-ruby/models/accounting/address.rb +++ b/lib/xero-ruby/models/accounting/address.rb @@ -434,9 +434,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -463,35 +460,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/address_for_organisation.rb b/lib/xero-ruby/models/accounting/address_for_organisation.rb index 2392eaeb..bf52ef61 100644 --- a/lib/xero-ruby/models/accounting/address_for_organisation.rb +++ b/lib/xero-ruby/models/accounting/address_for_organisation.rb @@ -435,9 +435,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -464,35 +461,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/allocation.rb b/lib/xero-ruby/models/accounting/allocation.rb index c96b0ba5..4f597c7a 100644 --- a/lib/xero-ruby/models/accounting/allocation.rb +++ b/lib/xero-ruby/models/accounting/allocation.rb @@ -260,9 +260,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -289,35 +286,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/allocations.rb b/lib/xero-ruby/models/accounting/allocations.rb index a2c934a5..f10ac3ce 100644 --- a/lib/xero-ruby/models/accounting/allocations.rb +++ b/lib/xero-ruby/models/accounting/allocations.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/attachment.rb b/lib/xero-ruby/models/accounting/attachment.rb index 1f751ca4..b6a04fa8 100644 --- a/lib/xero-ruby/models/accounting/attachment.rb +++ b/lib/xero-ruby/models/accounting/attachment.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/attachments.rb b/lib/xero-ruby/models/accounting/attachments.rb index 3f03ef75..0bdccf9f 100644 --- a/lib/xero-ruby/models/accounting/attachments.rb +++ b/lib/xero-ruby/models/accounting/attachments.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/balance_details.rb b/lib/xero-ruby/models/accounting/balance_details.rb index bc556ef2..29a38ab7 100644 --- a/lib/xero-ruby/models/accounting/balance_details.rb +++ b/lib/xero-ruby/models/accounting/balance_details.rb @@ -194,9 +194,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -223,35 +220,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/balances.rb b/lib/xero-ruby/models/accounting/balances.rb index b4beeae3..c0f9cbde 100644 --- a/lib/xero-ruby/models/accounting/balances.rb +++ b/lib/xero-ruby/models/accounting/balances.rb @@ -184,9 +184,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -213,35 +210,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/bank_transaction.rb b/lib/xero-ruby/models/accounting/bank_transaction.rb index 4cd75e1b..047f83ed 100644 --- a/lib/xero-ruby/models/accounting/bank_transaction.rb +++ b/lib/xero-ruby/models/accounting/bank_transaction.rb @@ -461,9 +461,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -490,35 +487,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/bank_transactions.rb b/lib/xero-ruby/models/accounting/bank_transactions.rb index 4c53dda5..f58dc5d9 100644 --- a/lib/xero-ruby/models/accounting/bank_transactions.rb +++ b/lib/xero-ruby/models/accounting/bank_transactions.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/bank_transfer.rb b/lib/xero-ruby/models/accounting/bank_transfer.rb index 0122267d..e6ecd884 100644 --- a/lib/xero-ruby/models/accounting/bank_transfer.rb +++ b/lib/xero-ruby/models/accounting/bank_transfer.rb @@ -292,9 +292,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -321,35 +318,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/bank_transfers.rb b/lib/xero-ruby/models/accounting/bank_transfers.rb index 12e2bd6f..80536a51 100644 --- a/lib/xero-ruby/models/accounting/bank_transfers.rb +++ b/lib/xero-ruby/models/accounting/bank_transfers.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/batch_payment.rb b/lib/xero-ruby/models/accounting/batch_payment.rb index 3a2a9787..a860d26d 100644 --- a/lib/xero-ruby/models/accounting/batch_payment.rb +++ b/lib/xero-ruby/models/accounting/batch_payment.rb @@ -447,9 +447,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -476,35 +473,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/batch_payment_details.rb b/lib/xero-ruby/models/accounting/batch_payment_details.rb index 1c252039..e3c962c6 100644 --- a/lib/xero-ruby/models/accounting/batch_payment_details.rb +++ b/lib/xero-ruby/models/accounting/batch_payment_details.rb @@ -244,9 +244,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -273,35 +270,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/batch_payments.rb b/lib/xero-ruby/models/accounting/batch_payments.rb index 40447a62..b85117ff 100644 --- a/lib/xero-ruby/models/accounting/batch_payments.rb +++ b/lib/xero-ruby/models/accounting/batch_payments.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/bill.rb b/lib/xero-ruby/models/accounting/bill.rb index dacd2af1..f47030ef 100644 --- a/lib/xero-ruby/models/accounting/bill.rb +++ b/lib/xero-ruby/models/accounting/bill.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/branding_theme.rb b/lib/xero-ruby/models/accounting/branding_theme.rb index c25341da..860f4587 100644 --- a/lib/xero-ruby/models/accounting/branding_theme.rb +++ b/lib/xero-ruby/models/accounting/branding_theme.rb @@ -258,9 +258,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -287,35 +284,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/branding_themes.rb b/lib/xero-ruby/models/accounting/branding_themes.rb index bd500cc5..3c123868 100644 --- a/lib/xero-ruby/models/accounting/branding_themes.rb +++ b/lib/xero-ruby/models/accounting/branding_themes.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/cis_org_setting.rb b/lib/xero-ruby/models/accounting/cis_org_setting.rb index 7a421532..47a442c4 100644 --- a/lib/xero-ruby/models/accounting/cis_org_setting.rb +++ b/lib/xero-ruby/models/accounting/cis_org_setting.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/cis_org_settings.rb b/lib/xero-ruby/models/accounting/cis_org_settings.rb index 789d6a8c..ae3d7382 100644 --- a/lib/xero-ruby/models/accounting/cis_org_settings.rb +++ b/lib/xero-ruby/models/accounting/cis_org_settings.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/cis_setting.rb b/lib/xero-ruby/models/accounting/cis_setting.rb index 1e70097f..fd2b14ae 100644 --- a/lib/xero-ruby/models/accounting/cis_setting.rb +++ b/lib/xero-ruby/models/accounting/cis_setting.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/cis_settings.rb b/lib/xero-ruby/models/accounting/cis_settings.rb index 92c7c0b3..cf854f59 100644 --- a/lib/xero-ruby/models/accounting/cis_settings.rb +++ b/lib/xero-ruby/models/accounting/cis_settings.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/contact.rb b/lib/xero-ruby/models/accounting/contact.rb index 4acc3eed..bcad59a3 100644 --- a/lib/xero-ruby/models/accounting/contact.rb +++ b/lib/xero-ruby/models/accounting/contact.rb @@ -715,9 +715,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -744,35 +741,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/contact_group.rb b/lib/xero-ruby/models/accounting/contact_group.rb index 7cdee068..342983dc 100644 --- a/lib/xero-ruby/models/accounting/contact_group.rb +++ b/lib/xero-ruby/models/accounting/contact_group.rb @@ -241,9 +241,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -270,35 +267,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/contact_groups.rb b/lib/xero-ruby/models/accounting/contact_groups.rb index c7b1c857..c268c732 100644 --- a/lib/xero-ruby/models/accounting/contact_groups.rb +++ b/lib/xero-ruby/models/accounting/contact_groups.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/contact_person.rb b/lib/xero-ruby/models/accounting/contact_person.rb index ae346d97..61a96cdc 100644 --- a/lib/xero-ruby/models/accounting/contact_person.rb +++ b/lib/xero-ruby/models/accounting/contact_person.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/contacts.rb b/lib/xero-ruby/models/accounting/contacts.rb index 69ecbaae..28490cba 100644 --- a/lib/xero-ruby/models/accounting/contacts.rb +++ b/lib/xero-ruby/models/accounting/contacts.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/conversion_balances.rb b/lib/xero-ruby/models/accounting/conversion_balances.rb index 4f638799..27f26617 100644 --- a/lib/xero-ruby/models/accounting/conversion_balances.rb +++ b/lib/xero-ruby/models/accounting/conversion_balances.rb @@ -196,9 +196,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -225,35 +222,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/conversion_date.rb b/lib/xero-ruby/models/accounting/conversion_date.rb index f1f71f3b..ff57b11a 100644 --- a/lib/xero-ruby/models/accounting/conversion_date.rb +++ b/lib/xero-ruby/models/accounting/conversion_date.rb @@ -184,9 +184,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -213,35 +210,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/credit_note.rb b/lib/xero-ruby/models/accounting/credit_note.rb index 8f32f2fd..999a2c98 100644 --- a/lib/xero-ruby/models/accounting/credit_note.rb +++ b/lib/xero-ruby/models/accounting/credit_note.rb @@ -531,9 +531,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -560,35 +557,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/credit_notes.rb b/lib/xero-ruby/models/accounting/credit_notes.rb index 2fcf2743..c1fcdc26 100644 --- a/lib/xero-ruby/models/accounting/credit_notes.rb +++ b/lib/xero-ruby/models/accounting/credit_notes.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/currencies.rb b/lib/xero-ruby/models/accounting/currencies.rb index 65c0f291..24959687 100644 --- a/lib/xero-ruby/models/accounting/currencies.rb +++ b/lib/xero-ruby/models/accounting/currencies.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/currency.rb b/lib/xero-ruby/models/accounting/currency.rb index 59d440af..d30b62b9 100644 --- a/lib/xero-ruby/models/accounting/currency.rb +++ b/lib/xero-ruby/models/accounting/currency.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/element.rb b/lib/xero-ruby/models/accounting/element.rb index a40d1bb5..9ce4b268 100644 --- a/lib/xero-ruby/models/accounting/element.rb +++ b/lib/xero-ruby/models/accounting/element.rb @@ -245,9 +245,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -274,35 +271,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/employee.rb b/lib/xero-ruby/models/accounting/employee.rb index 8c891c64..5d1fbd5a 100644 --- a/lib/xero-ruby/models/accounting/employee.rb +++ b/lib/xero-ruby/models/accounting/employee.rb @@ -313,9 +313,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -342,35 +339,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/employees.rb b/lib/xero-ruby/models/accounting/employees.rb index 8668f238..6d0bd152 100644 --- a/lib/xero-ruby/models/accounting/employees.rb +++ b/lib/xero-ruby/models/accounting/employees.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/error.rb b/lib/xero-ruby/models/accounting/error.rb index ad08ae4c..aa75840d 100644 --- a/lib/xero-ruby/models/accounting/error.rb +++ b/lib/xero-ruby/models/accounting/error.rb @@ -205,9 +205,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -234,35 +231,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/expense_claim.rb b/lib/xero-ruby/models/accounting/expense_claim.rb index fe93acf5..ef507cd8 100644 --- a/lib/xero-ruby/models/accounting/expense_claim.rb +++ b/lib/xero-ruby/models/accounting/expense_claim.rb @@ -326,9 +326,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -355,35 +352,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/expense_claims.rb b/lib/xero-ruby/models/accounting/expense_claims.rb index 26d81029..bf58d0c5 100644 --- a/lib/xero-ruby/models/accounting/expense_claims.rb +++ b/lib/xero-ruby/models/accounting/expense_claims.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/external_link.rb b/lib/xero-ruby/models/accounting/external_link.rb index 49455b4d..ab52a12a 100644 --- a/lib/xero-ruby/models/accounting/external_link.rb +++ b/lib/xero-ruby/models/accounting/external_link.rb @@ -232,9 +232,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -261,35 +258,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/history_record.rb b/lib/xero-ruby/models/accounting/history_record.rb index d9bc5f1e..451171c3 100644 --- a/lib/xero-ruby/models/accounting/history_record.rb +++ b/lib/xero-ruby/models/accounting/history_record.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/history_records.rb b/lib/xero-ruby/models/accounting/history_records.rb index 9cf0ae67..559b8e97 100644 --- a/lib/xero-ruby/models/accounting/history_records.rb +++ b/lib/xero-ruby/models/accounting/history_records.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/import_summary.rb b/lib/xero-ruby/models/accounting/import_summary.rb index 9112eb93..ee59a536 100644 --- a/lib/xero-ruby/models/accounting/import_summary.rb +++ b/lib/xero-ruby/models/accounting/import_summary.rb @@ -184,9 +184,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -213,35 +210,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/import_summary_accounts.rb b/lib/xero-ruby/models/accounting/import_summary_accounts.rb index b14f37b9..8c68c9a3 100644 --- a/lib/xero-ruby/models/accounting/import_summary_accounts.rb +++ b/lib/xero-ruby/models/accounting/import_summary_accounts.rb @@ -254,9 +254,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -283,35 +280,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/import_summary_object.rb b/lib/xero-ruby/models/accounting/import_summary_object.rb index 85a23253..b09719f6 100644 --- a/lib/xero-ruby/models/accounting/import_summary_object.rb +++ b/lib/xero-ruby/models/accounting/import_summary_object.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/import_summary_organisation.rb b/lib/xero-ruby/models/accounting/import_summary_organisation.rb index 4dd6239d..4b0699e5 100644 --- a/lib/xero-ruby/models/accounting/import_summary_organisation.rb +++ b/lib/xero-ruby/models/accounting/import_summary_organisation.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/invoice.rb b/lib/xero-ruby/models/accounting/invoice.rb index b7178fb8..355f65ed 100644 --- a/lib/xero-ruby/models/accounting/invoice.rb +++ b/lib/xero-ruby/models/accounting/invoice.rb @@ -658,9 +658,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -687,35 +684,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/invoice_reminder.rb b/lib/xero-ruby/models/accounting/invoice_reminder.rb index 40007003..8bf2f6db 100644 --- a/lib/xero-ruby/models/accounting/invoice_reminder.rb +++ b/lib/xero-ruby/models/accounting/invoice_reminder.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/invoice_reminders.rb b/lib/xero-ruby/models/accounting/invoice_reminders.rb index 7ac7367a..ef3bfe43 100644 --- a/lib/xero-ruby/models/accounting/invoice_reminders.rb +++ b/lib/xero-ruby/models/accounting/invoice_reminders.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/invoices.rb b/lib/xero-ruby/models/accounting/invoices.rb index d6f6b66b..4cf67852 100644 --- a/lib/xero-ruby/models/accounting/invoices.rb +++ b/lib/xero-ruby/models/accounting/invoices.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/item.rb b/lib/xero-ruby/models/accounting/item.rb index 95650f81..ef7f122b 100644 --- a/lib/xero-ruby/models/accounting/item.rb +++ b/lib/xero-ruby/models/accounting/item.rb @@ -394,9 +394,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -423,35 +420,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/items.rb b/lib/xero-ruby/models/accounting/items.rb index 3744124a..9ecd5d4b 100644 --- a/lib/xero-ruby/models/accounting/items.rb +++ b/lib/xero-ruby/models/accounting/items.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/journal.rb b/lib/xero-ruby/models/accounting/journal.rb index 5107fa34..c423d79a 100644 --- a/lib/xero-ruby/models/accounting/journal.rb +++ b/lib/xero-ruby/models/accounting/journal.rb @@ -304,9 +304,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -333,35 +330,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/journal_line.rb b/lib/xero-ruby/models/accounting/journal_line.rb index 54f7ba53..61cd9b37 100644 --- a/lib/xero-ruby/models/accounting/journal_line.rb +++ b/lib/xero-ruby/models/accounting/journal_line.rb @@ -285,9 +285,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -314,35 +311,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/journals.rb b/lib/xero-ruby/models/accounting/journals.rb index b6b06aeb..c73d64f5 100644 --- a/lib/xero-ruby/models/accounting/journals.rb +++ b/lib/xero-ruby/models/accounting/journals.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/line_item.rb b/lib/xero-ruby/models/accounting/line_item.rb index b0298eb3..3592e0a3 100644 --- a/lib/xero-ruby/models/accounting/line_item.rb +++ b/lib/xero-ruby/models/accounting/line_item.rb @@ -295,9 +295,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -324,35 +321,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/line_item_tracking.rb b/lib/xero-ruby/models/accounting/line_item_tracking.rb index ea102510..621cd0e1 100644 --- a/lib/xero-ruby/models/accounting/line_item_tracking.rb +++ b/lib/xero-ruby/models/accounting/line_item_tracking.rb @@ -218,9 +218,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -247,35 +244,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/linked_transaction.rb b/lib/xero-ruby/models/accounting/linked_transaction.rb index 5be34408..4825127a 100644 --- a/lib/xero-ruby/models/accounting/linked_transaction.rb +++ b/lib/xero-ruby/models/accounting/linked_transaction.rb @@ -341,9 +341,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -370,35 +367,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/linked_transactions.rb b/lib/xero-ruby/models/accounting/linked_transactions.rb index 187ee391..1bdf643b 100644 --- a/lib/xero-ruby/models/accounting/linked_transactions.rb +++ b/lib/xero-ruby/models/accounting/linked_transactions.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/manual_journal.rb b/lib/xero-ruby/models/accounting/manual_journal.rb index 0071ddc9..a9e9deff 100644 --- a/lib/xero-ruby/models/accounting/manual_journal.rb +++ b/lib/xero-ruby/models/accounting/manual_journal.rb @@ -357,9 +357,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -386,35 +383,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/manual_journal_line.rb b/lib/xero-ruby/models/accounting/manual_journal_line.rb index 90a01d88..bb617ac8 100644 --- a/lib/xero-ruby/models/accounting/manual_journal_line.rb +++ b/lib/xero-ruby/models/accounting/manual_journal_line.rb @@ -245,9 +245,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -274,35 +271,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/manual_journals.rb b/lib/xero-ruby/models/accounting/manual_journals.rb index c2dc9073..d0b31efc 100644 --- a/lib/xero-ruby/models/accounting/manual_journals.rb +++ b/lib/xero-ruby/models/accounting/manual_journals.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/online_invoice.rb b/lib/xero-ruby/models/accounting/online_invoice.rb index 9d280310..88c41935 100644 --- a/lib/xero-ruby/models/accounting/online_invoice.rb +++ b/lib/xero-ruby/models/accounting/online_invoice.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/online_invoices.rb b/lib/xero-ruby/models/accounting/online_invoices.rb index fbed496a..1c3be31e 100644 --- a/lib/xero-ruby/models/accounting/online_invoices.rb +++ b/lib/xero-ruby/models/accounting/online_invoices.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/organisations.rb b/lib/xero-ruby/models/accounting/organisations.rb index 16a8f173..4ea0e288 100644 --- a/lib/xero-ruby/models/accounting/organisations.rb +++ b/lib/xero-ruby/models/accounting/organisations.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/overpayment.rb b/lib/xero-ruby/models/accounting/overpayment.rb index b8002960..9aa2e1eb 100644 --- a/lib/xero-ruby/models/accounting/overpayment.rb +++ b/lib/xero-ruby/models/accounting/overpayment.rb @@ -415,9 +415,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -444,35 +441,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/overpayments.rb b/lib/xero-ruby/models/accounting/overpayments.rb index c1675934..0fc31516 100644 --- a/lib/xero-ruby/models/accounting/overpayments.rb +++ b/lib/xero-ruby/models/accounting/overpayments.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/payment.rb b/lib/xero-ruby/models/accounting/payment.rb index 41eeae19..fcb27504 100644 --- a/lib/xero-ruby/models/accounting/payment.rb +++ b/lib/xero-ruby/models/accounting/payment.rb @@ -475,9 +475,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -504,35 +501,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/payment_delete.rb b/lib/xero-ruby/models/accounting/payment_delete.rb index c118d38e..b5257acc 100644 --- a/lib/xero-ruby/models/accounting/payment_delete.rb +++ b/lib/xero-ruby/models/accounting/payment_delete.rb @@ -180,9 +180,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -209,35 +206,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/payment_service.rb b/lib/xero-ruby/models/accounting/payment_service.rb index 096e5e26..3732707c 100644 --- a/lib/xero-ruby/models/accounting/payment_service.rb +++ b/lib/xero-ruby/models/accounting/payment_service.rb @@ -225,9 +225,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -254,35 +251,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/payment_services.rb b/lib/xero-ruby/models/accounting/payment_services.rb index 9a7e1a70..16edffff 100644 --- a/lib/xero-ruby/models/accounting/payment_services.rb +++ b/lib/xero-ruby/models/accounting/payment_services.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/payment_term.rb b/lib/xero-ruby/models/accounting/payment_term.rb index 9ba78b3f..a3d19d1a 100644 --- a/lib/xero-ruby/models/accounting/payment_term.rb +++ b/lib/xero-ruby/models/accounting/payment_term.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/payments.rb b/lib/xero-ruby/models/accounting/payments.rb index 95f13516..d9868452 100644 --- a/lib/xero-ruby/models/accounting/payments.rb +++ b/lib/xero-ruby/models/accounting/payments.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/phone.rb b/lib/xero-ruby/models/accounting/phone.rb index abb37c0c..966d4e57 100644 --- a/lib/xero-ruby/models/accounting/phone.rb +++ b/lib/xero-ruby/models/accounting/phone.rb @@ -287,9 +287,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -316,35 +313,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/prepayment.rb b/lib/xero-ruby/models/accounting/prepayment.rb index 6a813a8b..cc216ddf 100644 --- a/lib/xero-ruby/models/accounting/prepayment.rb +++ b/lib/xero-ruby/models/accounting/prepayment.rb @@ -426,9 +426,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -455,35 +452,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/prepayments.rb b/lib/xero-ruby/models/accounting/prepayments.rb index c53a3a6d..321f0d7e 100644 --- a/lib/xero-ruby/models/accounting/prepayments.rb +++ b/lib/xero-ruby/models/accounting/prepayments.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/purchase.rb b/lib/xero-ruby/models/accounting/purchase.rb index c088f174..808996da 100644 --- a/lib/xero-ruby/models/accounting/purchase.rb +++ b/lib/xero-ruby/models/accounting/purchase.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/purchase_order.rb b/lib/xero-ruby/models/accounting/purchase_order.rb index f0becfce..af02516b 100644 --- a/lib/xero-ruby/models/accounting/purchase_order.rb +++ b/lib/xero-ruby/models/accounting/purchase_order.rb @@ -492,9 +492,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -521,35 +518,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/purchase_orders.rb b/lib/xero-ruby/models/accounting/purchase_orders.rb index 5676aadb..a43364dc 100644 --- a/lib/xero-ruby/models/accounting/purchase_orders.rb +++ b/lib/xero-ruby/models/accounting/purchase_orders.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/quote.rb b/lib/xero-ruby/models/accounting/quote.rb index 2a7bf5b9..3e3de3f9 100644 --- a/lib/xero-ruby/models/accounting/quote.rb +++ b/lib/xero-ruby/models/accounting/quote.rb @@ -482,9 +482,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -511,35 +508,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/quotes.rb b/lib/xero-ruby/models/accounting/quotes.rb index bc2b279f..458c5efe 100644 --- a/lib/xero-ruby/models/accounting/quotes.rb +++ b/lib/xero-ruby/models/accounting/quotes.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/receipt.rb b/lib/xero-ruby/models/accounting/receipt.rb index fc3a401b..655ef852 100644 --- a/lib/xero-ruby/models/accounting/receipt.rb +++ b/lib/xero-ruby/models/accounting/receipt.rb @@ -392,9 +392,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -421,35 +418,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/receipts.rb b/lib/xero-ruby/models/accounting/receipts.rb index 27803b3d..99655eea 100644 --- a/lib/xero-ruby/models/accounting/receipts.rb +++ b/lib/xero-ruby/models/accounting/receipts.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/repeating_invoice.rb b/lib/xero-ruby/models/accounting/repeating_invoice.rb index 0983689e..2a5e460c 100644 --- a/lib/xero-ruby/models/accounting/repeating_invoice.rb +++ b/lib/xero-ruby/models/accounting/repeating_invoice.rb @@ -380,9 +380,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -409,35 +406,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/repeating_invoices.rb b/lib/xero-ruby/models/accounting/repeating_invoices.rb index 73a855a7..b2924656 100644 --- a/lib/xero-ruby/models/accounting/repeating_invoices.rb +++ b/lib/xero-ruby/models/accounting/repeating_invoices.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report.rb b/lib/xero-ruby/models/accounting/report.rb index 30bc82d0..02132f5d 100644 --- a/lib/xero-ruby/models/accounting/report.rb +++ b/lib/xero-ruby/models/accounting/report.rb @@ -270,9 +270,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -299,35 +296,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report_attribute.rb b/lib/xero-ruby/models/accounting/report_attribute.rb index c849e7ac..ec6bd9bc 100644 --- a/lib/xero-ruby/models/accounting/report_attribute.rb +++ b/lib/xero-ruby/models/accounting/report_attribute.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report_cell.rb b/lib/xero-ruby/models/accounting/report_cell.rb index f2c5b2b1..89daf1e7 100644 --- a/lib/xero-ruby/models/accounting/report_cell.rb +++ b/lib/xero-ruby/models/accounting/report_cell.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report_fields.rb b/lib/xero-ruby/models/accounting/report_fields.rb index 974fe9ca..56f803a0 100644 --- a/lib/xero-ruby/models/accounting/report_fields.rb +++ b/lib/xero-ruby/models/accounting/report_fields.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report_row.rb b/lib/xero-ruby/models/accounting/report_row.rb index 6287a567..56e83dc6 100644 --- a/lib/xero-ruby/models/accounting/report_row.rb +++ b/lib/xero-ruby/models/accounting/report_row.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report_rows.rb b/lib/xero-ruby/models/accounting/report_rows.rb index a3091716..2ad102a9 100644 --- a/lib/xero-ruby/models/accounting/report_rows.rb +++ b/lib/xero-ruby/models/accounting/report_rows.rb @@ -207,9 +207,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -236,35 +233,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report_with_row.rb b/lib/xero-ruby/models/accounting/report_with_row.rb index ca376240..d986f91f 100644 --- a/lib/xero-ruby/models/accounting/report_with_row.rb +++ b/lib/xero-ruby/models/accounting/report_with_row.rb @@ -259,9 +259,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -288,35 +285,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/report_with_rows.rb b/lib/xero-ruby/models/accounting/report_with_rows.rb index a5db7cd5..c5b00840 100644 --- a/lib/xero-ruby/models/accounting/report_with_rows.rb +++ b/lib/xero-ruby/models/accounting/report_with_rows.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/reports.rb b/lib/xero-ruby/models/accounting/reports.rb index 8e4ca5b8..40e87c6a 100644 --- a/lib/xero-ruby/models/accounting/reports.rb +++ b/lib/xero-ruby/models/accounting/reports.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/request_empty.rb b/lib/xero-ruby/models/accounting/request_empty.rb index 5a4e0556..d2cde658 100644 --- a/lib/xero-ruby/models/accounting/request_empty.rb +++ b/lib/xero-ruby/models/accounting/request_empty.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/sales_tracking_category.rb b/lib/xero-ruby/models/accounting/sales_tracking_category.rb index fb71510a..b95a1165 100644 --- a/lib/xero-ruby/models/accounting/sales_tracking_category.rb +++ b/lib/xero-ruby/models/accounting/sales_tracking_category.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/schedule.rb b/lib/xero-ruby/models/accounting/schedule.rb index eb428883..500f3d20 100644 --- a/lib/xero-ruby/models/accounting/schedule.rb +++ b/lib/xero-ruby/models/accounting/schedule.rb @@ -287,9 +287,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -316,35 +313,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/setup.rb b/lib/xero-ruby/models/accounting/setup.rb index 878134a6..77a4818a 100644 --- a/lib/xero-ruby/models/accounting/setup.rb +++ b/lib/xero-ruby/models/accounting/setup.rb @@ -197,9 +197,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -226,35 +223,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/tax_component.rb b/lib/xero-ruby/models/accounting/tax_component.rb index ef074e88..14f736a9 100644 --- a/lib/xero-ruby/models/accounting/tax_component.rb +++ b/lib/xero-ruby/models/accounting/tax_component.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/tax_rate.rb b/lib/xero-ruby/models/accounting/tax_rate.rb index 81c221b1..0c8c5130 100644 --- a/lib/xero-ruby/models/accounting/tax_rate.rb +++ b/lib/xero-ruby/models/accounting/tax_rate.rb @@ -409,9 +409,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -438,35 +435,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/tax_rates.rb b/lib/xero-ruby/models/accounting/tax_rates.rb index b4737316..dbe1c5f7 100644 --- a/lib/xero-ruby/models/accounting/tax_rates.rb +++ b/lib/xero-ruby/models/accounting/tax_rates.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb b/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb index 5a1140f9..90f99351 100644 --- a/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb +++ b/lib/xero-ruby/models/accounting/ten_ninety_nine_contact.rb @@ -383,9 +383,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -412,35 +409,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/tracking_categories.rb b/lib/xero-ruby/models/accounting/tracking_categories.rb index daf98bcf..3a9f3932 100644 --- a/lib/xero-ruby/models/accounting/tracking_categories.rb +++ b/lib/xero-ruby/models/accounting/tracking_categories.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/tracking_category.rb b/lib/xero-ruby/models/accounting/tracking_category.rb index 512fd174..05f6a178 100644 --- a/lib/xero-ruby/models/accounting/tracking_category.rb +++ b/lib/xero-ruby/models/accounting/tracking_category.rb @@ -292,9 +292,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -321,35 +318,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/tracking_option.rb b/lib/xero-ruby/models/accounting/tracking_option.rb index 15f96878..9c3d809c 100644 --- a/lib/xero-ruby/models/accounting/tracking_option.rb +++ b/lib/xero-ruby/models/accounting/tracking_option.rb @@ -255,9 +255,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -284,35 +281,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/tracking_options.rb b/lib/xero-ruby/models/accounting/tracking_options.rb index d5416625..d59ce26f 100644 --- a/lib/xero-ruby/models/accounting/tracking_options.rb +++ b/lib/xero-ruby/models/accounting/tracking_options.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/user.rb b/lib/xero-ruby/models/accounting/user.rb index 6819857e..7b42c201 100644 --- a/lib/xero-ruby/models/accounting/user.rb +++ b/lib/xero-ruby/models/accounting/user.rb @@ -274,9 +274,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -303,35 +300,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/users.rb b/lib/xero-ruby/models/accounting/users.rb index 9bf04801..224721a0 100644 --- a/lib/xero-ruby/models/accounting/users.rb +++ b/lib/xero-ruby/models/accounting/users.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/accounting/validation_error.rb b/lib/xero-ruby/models/accounting/validation_error.rb index 10400869..2768ab10 100644 --- a/lib/xero-ruby/models/accounting/validation_error.rb +++ b/lib/xero-ruby/models/accounting/validation_error.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/asset.rb b/lib/xero-ruby/models/assets/asset.rb index 8dccbb6f..b6c468c7 100644 --- a/lib/xero-ruby/models/assets/asset.rb +++ b/lib/xero-ruby/models/assets/asset.rb @@ -328,9 +328,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -357,35 +354,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/asset_type.rb b/lib/xero-ruby/models/assets/asset_type.rb index ae778286..1b66a88c 100644 --- a/lib/xero-ruby/models/assets/asset_type.rb +++ b/lib/xero-ruby/models/assets/asset_type.rb @@ -243,9 +243,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -272,35 +269,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/assets.rb b/lib/xero-ruby/models/assets/assets.rb index 133e36db..f70b64d9 100644 --- a/lib/xero-ruby/models/assets/assets.rb +++ b/lib/xero-ruby/models/assets/assets.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/book_depreciation_detail.rb b/lib/xero-ruby/models/assets/book_depreciation_detail.rb index 1e3c4a42..04313826 100644 --- a/lib/xero-ruby/models/assets/book_depreciation_detail.rb +++ b/lib/xero-ruby/models/assets/book_depreciation_detail.rb @@ -233,9 +233,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -262,35 +259,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/book_depreciation_setting.rb b/lib/xero-ruby/models/assets/book_depreciation_setting.rb index 2b537524..f87f7fb1 100644 --- a/lib/xero-ruby/models/assets/book_depreciation_setting.rb +++ b/lib/xero-ruby/models/assets/book_depreciation_setting.rb @@ -312,9 +312,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -341,35 +338,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/error.rb b/lib/xero-ruby/models/assets/error.rb index 3a35a57f..0231b2f2 100644 --- a/lib/xero-ruby/models/assets/error.rb +++ b/lib/xero-ruby/models/assets/error.rb @@ -217,9 +217,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -246,35 +243,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/field_validation_errors_element.rb b/lib/xero-ruby/models/assets/field_validation_errors_element.rb index 3bda35e3..2eb7ef27 100644 --- a/lib/xero-ruby/models/assets/field_validation_errors_element.rb +++ b/lib/xero-ruby/models/assets/field_validation_errors_element.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/pagination.rb b/lib/xero-ruby/models/assets/pagination.rb index 1c642a85..aea460d0 100644 --- a/lib/xero-ruby/models/assets/pagination.rb +++ b/lib/xero-ruby/models/assets/pagination.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/resource_validation_errors_element.rb b/lib/xero-ruby/models/assets/resource_validation_errors_element.rb index 7c1f5626..c27395b3 100644 --- a/lib/xero-ruby/models/assets/resource_validation_errors_element.rb +++ b/lib/xero-ruby/models/assets/resource_validation_errors_element.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/assets/setting.rb b/lib/xero-ruby/models/assets/setting.rb index a3731e4d..f35542c9 100644 --- a/lib/xero-ruby/models/assets/setting.rb +++ b/lib/xero-ruby/models/assets/setting.rb @@ -243,9 +243,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -272,35 +269,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/files/association.rb b/lib/xero-ruby/models/files/association.rb index 32400113..d2245d31 100644 --- a/lib/xero-ruby/models/files/association.rb +++ b/lib/xero-ruby/models/files/association.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/files/file_object.rb b/lib/xero-ruby/models/files/file_object.rb index 8b082911..8cc1b250 100644 --- a/lib/xero-ruby/models/files/file_object.rb +++ b/lib/xero-ruby/models/files/file_object.rb @@ -243,9 +243,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -272,35 +269,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/files/files.rb b/lib/xero-ruby/models/files/files.rb index 73d1c5ce..5475cded 100644 --- a/lib/xero-ruby/models/files/files.rb +++ b/lib/xero-ruby/models/files/files.rb @@ -205,9 +205,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -234,35 +231,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/files/folder.rb b/lib/xero-ruby/models/files/folder.rb index c419e241..fb1ebe36 100644 --- a/lib/xero-ruby/models/files/folder.rb +++ b/lib/xero-ruby/models/files/folder.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/files/folders.rb b/lib/xero-ruby/models/files/folders.rb index f4c07ae1..df0cd297 100644 --- a/lib/xero-ruby/models/files/folders.rb +++ b/lib/xero-ruby/models/files/folders.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/files/upload_object.rb b/lib/xero-ruby/models/files/upload_object.rb index ac93a929..20edfa24 100644 --- a/lib/xero-ruby/models/files/upload_object.rb +++ b/lib/xero-ruby/models/files/upload_object.rb @@ -218,9 +218,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -247,35 +244,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/files/user.rb b/lib/xero-ruby/models/files/user.rb index e7c72eb5..46c0f791 100644 --- a/lib/xero-ruby/models/files/user.rb +++ b/lib/xero-ruby/models/files/user.rb @@ -218,9 +218,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -247,35 +244,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/account.rb b/lib/xero-ruby/models/payroll_au/account.rb index 9b4aa9ee..67a0ee3e 100644 --- a/lib/xero-ruby/models/payroll_au/account.rb +++ b/lib/xero-ruby/models/payroll_au/account.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/api_exception.rb b/lib/xero-ruby/models/payroll_au/api_exception.rb index fe8eee8f..d37b7c2b 100644 --- a/lib/xero-ruby/models/payroll_au/api_exception.rb +++ b/lib/xero-ruby/models/payroll_au/api_exception.rb @@ -194,9 +194,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -223,35 +220,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/bank_account.rb b/lib/xero-ruby/models/payroll_au/bank_account.rb index 0de45342..29972bbf 100644 --- a/lib/xero-ruby/models/payroll_au/bank_account.rb +++ b/lib/xero-ruby/models/payroll_au/bank_account.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/deduction_line.rb b/lib/xero-ruby/models/payroll_au/deduction_line.rb index 8051991d..ee0cd58c 100644 --- a/lib/xero-ruby/models/payroll_au/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_au/deduction_line.rb @@ -218,9 +218,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -247,35 +244,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/deduction_type.rb b/lib/xero-ruby/models/payroll_au/deduction_type.rb index 8388a752..858231af 100644 --- a/lib/xero-ruby/models/payroll_au/deduction_type.rb +++ b/lib/xero-ruby/models/payroll_au/deduction_type.rb @@ -305,9 +305,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -334,35 +331,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/earnings_line.rb b/lib/xero-ruby/models/payroll_au/earnings_line.rb index a4700163..d4b621f7 100644 --- a/lib/xero-ruby/models/payroll_au/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_au/earnings_line.rb @@ -258,9 +258,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -287,35 +284,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/earnings_rate.rb b/lib/xero-ruby/models/payroll_au/earnings_rate.rb index 0bbf00fa..69055564 100644 --- a/lib/xero-ruby/models/payroll_au/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_au/earnings_rate.rb @@ -363,9 +363,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -392,35 +389,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/employee.rb b/lib/xero-ruby/models/payroll_au/employee.rb index 33d3040a..6cee6e11 100644 --- a/lib/xero-ruby/models/payroll_au/employee.rb +++ b/lib/xero-ruby/models/payroll_au/employee.rb @@ -536,9 +536,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -565,35 +562,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/employees.rb b/lib/xero-ruby/models/payroll_au/employees.rb index 31238be7..a3307ae7 100644 --- a/lib/xero-ruby/models/payroll_au/employees.rb +++ b/lib/xero-ruby/models/payroll_au/employees.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/home_address.rb b/lib/xero-ruby/models/payroll_au/home_address.rb index 959721c1..61176fcc 100644 --- a/lib/xero-ruby/models/payroll_au/home_address.rb +++ b/lib/xero-ruby/models/payroll_au/home_address.rb @@ -228,9 +228,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -257,35 +254,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb index 89a7e981..03035778 100644 --- a/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_accrual_line.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_application.rb b/lib/xero-ruby/models/payroll_au/leave_application.rb index 2274b4a6..9df881f0 100644 --- a/lib/xero-ruby/models/payroll_au/leave_application.rb +++ b/lib/xero-ruby/models/payroll_au/leave_application.rb @@ -267,9 +267,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -296,35 +293,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_applications.rb b/lib/xero-ruby/models/payroll_au/leave_applications.rb index 5c9da8b6..c2dbe7a7 100644 --- a/lib/xero-ruby/models/payroll_au/leave_applications.rb +++ b/lib/xero-ruby/models/payroll_au/leave_applications.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_balance.rb b/lib/xero-ruby/models/payroll_au/leave_balance.rb index 0b82076f..c2171df1 100644 --- a/lib/xero-ruby/models/payroll_au/leave_balance.rb +++ b/lib/xero-ruby/models/payroll_au/leave_balance.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb index 3d1e5c02..c2015042 100644 --- a/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_earnings_line.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_line.rb b/lib/xero-ruby/models/payroll_au/leave_line.rb index d80e0c5d..784cc3cf 100644 --- a/lib/xero-ruby/models/payroll_au/leave_line.rb +++ b/lib/xero-ruby/models/payroll_au/leave_line.rb @@ -243,9 +243,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -272,35 +269,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_lines.rb b/lib/xero-ruby/models/payroll_au/leave_lines.rb index de3de052..83290290 100644 --- a/lib/xero-ruby/models/payroll_au/leave_lines.rb +++ b/lib/xero-ruby/models/payroll_au/leave_lines.rb @@ -176,9 +176,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -205,35 +202,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_period.rb b/lib/xero-ruby/models/payroll_au/leave_period.rb index aafbfe3c..326f3677 100644 --- a/lib/xero-ruby/models/payroll_au/leave_period.rb +++ b/lib/xero-ruby/models/payroll_au/leave_period.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/leave_type.rb b/lib/xero-ruby/models/payroll_au/leave_type.rb index a30a41c4..943c7776 100644 --- a/lib/xero-ruby/models/payroll_au/leave_type.rb +++ b/lib/xero-ruby/models/payroll_au/leave_type.rb @@ -268,9 +268,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -297,35 +294,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/opening_balances.rb b/lib/xero-ruby/models/payroll_au/opening_balances.rb index e5d62686..464a7550 100644 --- a/lib/xero-ruby/models/payroll_au/opening_balances.rb +++ b/lib/xero-ruby/models/payroll_au/opening_balances.rb @@ -243,9 +243,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -272,35 +269,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/pay_item.rb b/lib/xero-ruby/models/payroll_au/pay_item.rb index 1a79367d..43cb7a75 100644 --- a/lib/xero-ruby/models/payroll_au/pay_item.rb +++ b/lib/xero-ruby/models/payroll_au/pay_item.rb @@ -211,9 +211,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -240,35 +237,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/pay_items.rb b/lib/xero-ruby/models/payroll_au/pay_items.rb index c88862e9..54c3963b 100644 --- a/lib/xero-ruby/models/payroll_au/pay_items.rb +++ b/lib/xero-ruby/models/payroll_au/pay_items.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/pay_run.rb b/lib/xero-ruby/models/payroll_au/pay_run.rb index 7f03204b..6d7781fc 100644 --- a/lib/xero-ruby/models/payroll_au/pay_run.rb +++ b/lib/xero-ruby/models/payroll_au/pay_run.rb @@ -332,9 +332,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -361,35 +358,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/pay_runs.rb b/lib/xero-ruby/models/payroll_au/pay_runs.rb index 3046f5db..650aa370 100644 --- a/lib/xero-ruby/models/payroll_au/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_au/pay_runs.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/pay_template.rb b/lib/xero-ruby/models/payroll_au/pay_template.rb index b6b73939..374b8b14 100644 --- a/lib/xero-ruby/models/payroll_au/pay_template.rb +++ b/lib/xero-ruby/models/payroll_au/pay_template.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/payroll_calendar.rb b/lib/xero-ruby/models/payroll_au/payroll_calendar.rb index 95f0b402..0bb529c3 100644 --- a/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +++ b/lib/xero-ruby/models/payroll_au/payroll_calendar.rb @@ -235,9 +235,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -264,35 +261,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/payroll_calendars.rb b/lib/xero-ruby/models/payroll_au/payroll_calendars.rb index f50e821c..5f3737d4 100644 --- a/lib/xero-ruby/models/payroll_au/payroll_calendars.rb +++ b/lib/xero-ruby/models/payroll_au/payroll_calendars.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/payslip.rb b/lib/xero-ruby/models/payroll_au/payslip.rb index f9fce168..f04b7b83 100644 --- a/lib/xero-ruby/models/payroll_au/payslip.rb +++ b/lib/xero-ruby/models/payroll_au/payslip.rb @@ -369,9 +369,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -398,35 +395,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/payslip_lines.rb b/lib/xero-ruby/models/payroll_au/payslip_lines.rb index e7f9dc38..69ffb248 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_lines.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_lines.rb @@ -259,9 +259,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -288,35 +285,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/payslip_object.rb b/lib/xero-ruby/models/payroll_au/payslip_object.rb index 14ec520b..dd415e63 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_object.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_object.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/payslip_summary.rb b/lib/xero-ruby/models/payroll_au/payslip_summary.rb index 1ec743de..21d8978d 100644 --- a/lib/xero-ruby/models/payroll_au/payslip_summary.rb +++ b/lib/xero-ruby/models/payroll_au/payslip_summary.rb @@ -283,9 +283,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -312,35 +309,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/payslips.rb b/lib/xero-ruby/models/payroll_au/payslips.rb index 7dc2ec09..f5702e33 100644 --- a/lib/xero-ruby/models/payroll_au/payslips.rb +++ b/lib/xero-ruby/models/payroll_au/payslips.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_line.rb b/lib/xero-ruby/models/payroll_au/reimbursement_line.rb index 8a04f9b6..6ddefdbd 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_line.rb @@ -218,9 +218,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -247,35 +244,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb b/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb index e903fc56..bf40e73c 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_lines.rb @@ -176,9 +176,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -205,35 +202,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/reimbursement_type.rb b/lib/xero-ruby/models/payroll_au/reimbursement_type.rb index c8f722f0..01933521 100644 --- a/lib/xero-ruby/models/payroll_au/reimbursement_type.rb +++ b/lib/xero-ruby/models/payroll_au/reimbursement_type.rb @@ -228,9 +228,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -257,35 +254,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/settings.rb b/lib/xero-ruby/models/payroll_au/settings.rb index 6563e2bb..2d371c45 100644 --- a/lib/xero-ruby/models/payroll_au/settings.rb +++ b/lib/xero-ruby/models/payroll_au/settings.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/settings_object.rb b/lib/xero-ruby/models/payroll_au/settings_object.rb index 7795b09a..8cf083e2 100644 --- a/lib/xero-ruby/models/payroll_au/settings_object.rb +++ b/lib/xero-ruby/models/payroll_au/settings_object.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb index f3e9c514..1c2f9442 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories.rb @@ -184,9 +184,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -213,35 +210,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb index 92c3b7e3..33f5efcb 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_employee_groups.rb @@ -184,9 +184,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -213,35 +210,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb index dfc4acff..11bddb5c 100644 --- a/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb +++ b/lib/xero-ruby/models/payroll_au/settings_tracking_categories_timesheet_categories.rb @@ -184,9 +184,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -213,35 +210,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/super_fund.rb b/lib/xero-ruby/models/payroll_au/super_fund.rb index c05399c3..640781bf 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund.rb @@ -300,9 +300,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -329,35 +326,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/super_fund_product.rb b/lib/xero-ruby/models/payroll_au/super_fund_product.rb index 7ea0dc8b..bd36678b 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund_product.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund_product.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/super_fund_products.rb b/lib/xero-ruby/models/payroll_au/super_fund_products.rb index 5c5110d2..3d125bae 100644 --- a/lib/xero-ruby/models/payroll_au/super_fund_products.rb +++ b/lib/xero-ruby/models/payroll_au/super_fund_products.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/super_funds.rb b/lib/xero-ruby/models/payroll_au/super_funds.rb index 0538c681..7c073749 100644 --- a/lib/xero-ruby/models/payroll_au/super_funds.rb +++ b/lib/xero-ruby/models/payroll_au/super_funds.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/super_line.rb b/lib/xero-ruby/models/payroll_au/super_line.rb index 3c8ca6fa..3263df8e 100644 --- a/lib/xero-ruby/models/payroll_au/super_line.rb +++ b/lib/xero-ruby/models/payroll_au/super_line.rb @@ -243,9 +243,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -272,35 +269,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/super_membership.rb b/lib/xero-ruby/models/payroll_au/super_membership.rb index c60aab5f..65b974ce 100644 --- a/lib/xero-ruby/models/payroll_au/super_membership.rb +++ b/lib/xero-ruby/models/payroll_au/super_membership.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/superannuation_line.rb b/lib/xero-ruby/models/payroll_au/superannuation_line.rb index 14d428bb..54553d66 100644 --- a/lib/xero-ruby/models/payroll_au/superannuation_line.rb +++ b/lib/xero-ruby/models/payroll_au/superannuation_line.rb @@ -253,9 +253,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -282,35 +279,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/tax_declaration.rb b/lib/xero-ruby/models/payroll_au/tax_declaration.rb index 652eed46..6ea991e3 100644 --- a/lib/xero-ruby/models/payroll_au/tax_declaration.rb +++ b/lib/xero-ruby/models/payroll_au/tax_declaration.rb @@ -323,9 +323,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -352,35 +349,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/tax_line.rb b/lib/xero-ruby/models/payroll_au/tax_line.rb index 85b39c93..7632bba5 100644 --- a/lib/xero-ruby/models/payroll_au/tax_line.rb +++ b/lib/xero-ruby/models/payroll_au/tax_line.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/timesheet.rb b/lib/xero-ruby/models/payroll_au/timesheet.rb index 538aac95..5e46f36b 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet.rb @@ -272,9 +272,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -301,35 +298,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/timesheet_line.rb b/lib/xero-ruby/models/payroll_au/timesheet_line.rb index b433d3ad..469e5aa8 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet_line.rb @@ -205,9 +205,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -234,35 +231,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/timesheet_object.rb b/lib/xero-ruby/models/payroll_au/timesheet_object.rb index 2c49d300..6beb58bc 100644 --- a/lib/xero-ruby/models/payroll_au/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_au/timesheet_object.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/timesheets.rb b/lib/xero-ruby/models/payroll_au/timesheets.rb index 81b39ba6..d03ca029 100644 --- a/lib/xero-ruby/models/payroll_au/timesheets.rb +++ b/lib/xero-ruby/models/payroll_au/timesheets.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_au/validation_error.rb b/lib/xero-ruby/models/payroll_au/validation_error.rb index 7d6beb1e..f9d80bd0 100644 --- a/lib/xero-ruby/models/payroll_au/validation_error.rb +++ b/lib/xero-ruby/models/payroll_au/validation_error.rb @@ -173,9 +173,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -202,35 +199,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/account.rb b/lib/xero-ruby/models/payroll_nz/account.rb index 49ddb40d..ef149b46 100644 --- a/lib/xero-ruby/models/payroll_nz/account.rb +++ b/lib/xero-ruby/models/payroll_nz/account.rb @@ -241,9 +241,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -270,35 +267,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/accounts.rb b/lib/xero-ruby/models/payroll_nz/accounts.rb index f52dad64..855b69bb 100644 --- a/lib/xero-ruby/models/payroll_nz/accounts.rb +++ b/lib/xero-ruby/models/payroll_nz/accounts.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/address.rb b/lib/xero-ruby/models/payroll_nz/address.rb index d8ad30d5..2a3e98fa 100644 --- a/lib/xero-ruby/models/payroll_nz/address.rb +++ b/lib/xero-ruby/models/payroll_nz/address.rb @@ -238,9 +238,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -267,35 +264,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/bank_account.rb b/lib/xero-ruby/models/payroll_nz/bank_account.rb index f2dc4042..73d87c9f 100644 --- a/lib/xero-ruby/models/payroll_nz/bank_account.rb +++ b/lib/xero-ruby/models/payroll_nz/bank_account.rb @@ -294,9 +294,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -323,35 +320,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/benefit.rb b/lib/xero-ruby/models/payroll_nz/benefit.rb index 03d1b5b6..5fc212ba 100644 --- a/lib/xero-ruby/models/payroll_nz/benefit.rb +++ b/lib/xero-ruby/models/payroll_nz/benefit.rb @@ -334,9 +334,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -363,35 +360,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/deduction.rb b/lib/xero-ruby/models/payroll_nz/deduction.rb index b19a60fa..96cefb96 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction.rb @@ -276,9 +276,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -305,35 +302,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/deduction_line.rb b/lib/xero-ruby/models/payroll_nz/deduction_line.rb index 74825b33..bc9517cc 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction_line.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/deduction_object.rb b/lib/xero-ruby/models/payroll_nz/deduction_object.rb index 6a40f065..8e2deaf7 100644 --- a/lib/xero-ruby/models/payroll_nz/deduction_object.rb +++ b/lib/xero-ruby/models/payroll_nz/deduction_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/deductions.rb b/lib/xero-ruby/models/payroll_nz/deductions.rb index f3c2df06..738d89bf 100644 --- a/lib/xero-ruby/models/payroll_nz/deductions.rb +++ b/lib/xero-ruby/models/payroll_nz/deductions.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_line.rb b/lib/xero-ruby/models/payroll_nz/earnings_line.rb index a96d6bae..78beada6 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_line.rb @@ -263,9 +263,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -292,35 +289,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_order.rb b/lib/xero-ruby/models/payroll_nz/earnings_order.rb index f42a2de7..3c4cb006 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_order.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_order.rb @@ -220,9 +220,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -249,35 +246,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb index 90e8f6d6..4449a58c 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_order_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_orders.rb b/lib/xero-ruby/models/payroll_nz/earnings_orders.rb index 653e99a4..e5a9c67b 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_orders.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_orders.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rate.rb b/lib/xero-ruby/models/payroll_nz/earnings_rate.rb index 0bdacc6d..2ca4a818 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rate.rb @@ -352,9 +352,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -381,35 +378,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb index a179408d..f1b6896f 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rate_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_rates.rb b/lib/xero-ruby/models/payroll_nz/earnings_rates.rb index 05612d77..a1235d2e 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_rates.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_rates.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_template.rb b/lib/xero-ruby/models/payroll_nz/earnings_template.rb index 107ebbb4..8ada7bb7 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_template.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_template.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb b/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb index aab5c187..d6481b87 100644 --- a/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb +++ b/lib/xero-ruby/models/payroll_nz/earnings_template_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee.rb b/lib/xero-ruby/models/payroll_nz/employee.rb index 57f12a1a..09dc5537 100644 --- a/lib/xero-ruby/models/payroll_nz/employee.rb +++ b/lib/xero-ruby/models/payroll_nz/employee.rb @@ -339,9 +339,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -368,35 +365,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb b/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb index e93d3155..028340a1 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_earnings_templates.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave.rb b/lib/xero-ruby/models/payroll_nz/employee_leave.rb index 948b9939..af5f4b94 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave.rb @@ -255,9 +255,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -284,35 +281,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb index aff22cfd..dc8df367 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_balance.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb index d249aa99..830a49dc 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_balances.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb index e65f527a..7f6f39b7 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb index 9c79b8a2..c93e6e79 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_setup.rb @@ -233,9 +233,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -262,35 +259,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb index eac8f60f..03f98909 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_setup_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb index 249e0ed8..9bb56f31 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_type.rb @@ -301,9 +301,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -330,35 +327,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb index 0c2794be..00c16feb 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_type_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb b/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb index 4f376549..604891f8 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leave_types.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_leaves.rb b/lib/xero-ruby/models/payroll_nz/employee_leaves.rb index 48c4af14..f86abd30 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_leaves.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_leaves.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_object.rb b/lib/xero-ruby/models/payroll_nz/employee_object.rb index 74ba1132..97be03ad 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb index 87d5607d..743e7db3 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_opening_balance.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb b/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb index 4916f28a..2398f194 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_opening_balances_object.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb index 59d55ece..9b184b08 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_template.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb index fd711586..afdc5f2c 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_template_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb b/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb index 5a7e9786..11d32cfa 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_pay_templates.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb index 50954cc6..1be8afc0 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance.rb @@ -245,9 +245,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -274,35 +271,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb index 76bd7795..3d7c88fa 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_balance_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb index 071a011d..83061f40 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leave_summary.rb @@ -287,9 +287,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -316,35 +313,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb index edf9cbe3..cb8f62bd 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_leaves_summaries.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb index fdf86d63..7ae18d13 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave.rb @@ -384,9 +384,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -413,35 +410,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb index 588dc48f..259487e7 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leave_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb index 2c2433b0..25c470ee 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_statutory_sick_leaves.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_tax.rb b/lib/xero-ruby/models/payroll_nz/employee_tax.rb index 66708660..d28047ad 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_tax.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_tax.rb @@ -362,9 +362,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -391,35 +388,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb b/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb index e25b9cd5..59c742fb 100644 --- a/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employee_tax_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employees.rb b/lib/xero-ruby/models/payroll_nz/employees.rb index 3fdbd2e6..df69e724 100644 --- a/lib/xero-ruby/models/payroll_nz/employees.rb +++ b/lib/xero-ruby/models/payroll_nz/employees.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employment.rb b/lib/xero-ruby/models/payroll_nz/employment.rb index 3c10cb8d..288767c2 100644 --- a/lib/xero-ruby/models/payroll_nz/employment.rb +++ b/lib/xero-ruby/models/payroll_nz/employment.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/employment_object.rb b/lib/xero-ruby/models/payroll_nz/employment_object.rb index c0923fa4..e41fd604 100644 --- a/lib/xero-ruby/models/payroll_nz/employment_object.rb +++ b/lib/xero-ruby/models/payroll_nz/employment_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb b/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb index 673aea52..e3fed3dd 100644 --- a/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb +++ b/lib/xero-ruby/models/payroll_nz/gross_earnings_history.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/invalid_field.rb b/lib/xero-ruby/models/payroll_nz/invalid_field.rb index a602eedf..1f39f660 100644 --- a/lib/xero-ruby/models/payroll_nz/invalid_field.rb +++ b/lib/xero-ruby/models/payroll_nz/invalid_field.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb index fc4d35de..a4be2a18 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_accrual_line.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb index b0ea0451..669b1045 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_earnings_line.rb @@ -263,9 +263,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -292,35 +289,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/leave_period.rb b/lib/xero-ruby/models/payroll_nz/leave_period.rb index e8813dd0..851ed2a7 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_period.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_period.rb @@ -239,9 +239,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -268,35 +265,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/leave_periods.rb b/lib/xero-ruby/models/payroll_nz/leave_periods.rb index ed07f85d..4fa6d15f 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_periods.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_periods.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/leave_type.rb b/lib/xero-ruby/models/payroll_nz/leave_type.rb index 61c75481..7b6ce8f8 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_type.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_type.rb @@ -238,9 +238,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -267,35 +264,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/leave_type_object.rb b/lib/xero-ruby/models/payroll_nz/leave_type_object.rb index c30c24c4..041d7f7a 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_type_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/leave_types.rb b/lib/xero-ruby/models/payroll_nz/leave_types.rb index 47204180..03772503 100644 --- a/lib/xero-ruby/models/payroll_nz/leave_types.rb +++ b/lib/xero-ruby/models/payroll_nz/leave_types.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pagination.rb b/lib/xero-ruby/models/payroll_nz/pagination.rb index 98207ee9..efdfd060 100644 --- a/lib/xero-ruby/models/payroll_nz/pagination.rb +++ b/lib/xero-ruby/models/payroll_nz/pagination.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run.rb b/lib/xero-ruby/models/payroll_nz/pay_run.rb index 096fa72b..d1f5a6b2 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run.rb @@ -336,9 +336,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -365,35 +362,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb index c9d27c39..78078275 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendar.rb @@ -253,9 +253,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -282,35 +279,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb index 05cc3944..3c270a8c 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendar_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb b/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb index cd6daa26..cba62804 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_calendars.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_run_object.rb b/lib/xero-ruby/models/payroll_nz/pay_run_object.rb index 18a72cf4..09cbf9a3 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_run_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_run_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_runs.rb b/lib/xero-ruby/models/payroll_nz/pay_runs.rb index cc8a440c..dfb8c924 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_runs.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_slip.rb b/lib/xero-ruby/models/payroll_nz/pay_slip.rb index 1207e4ff..c12be003 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slip.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slip.rb @@ -522,9 +522,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -551,35 +548,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb b/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb index 167eacff..8504b8dd 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slip_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/pay_slips.rb b/lib/xero-ruby/models/payroll_nz/pay_slips.rb index 5d511196..7aa94a72 100644 --- a/lib/xero-ruby/models/payroll_nz/pay_slips.rb +++ b/lib/xero-ruby/models/payroll_nz/pay_slips.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/payment_line.rb b/lib/xero-ruby/models/payroll_nz/payment_line.rb index ecf015f2..a237e95d 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_line.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_line.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/payment_method.rb b/lib/xero-ruby/models/payroll_nz/payment_method.rb index 263200c6..d7cde601 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_method.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_method.rb @@ -222,9 +222,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -251,35 +248,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/payment_method_object.rb b/lib/xero-ruby/models/payroll_nz/payment_method_object.rb index ab5ace2e..1192ba9a 100644 --- a/lib/xero-ruby/models/payroll_nz/payment_method_object.rb +++ b/lib/xero-ruby/models/payroll_nz/payment_method_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/problem.rb b/lib/xero-ruby/models/payroll_nz/problem.rb index 10a68055..db5218c6 100644 --- a/lib/xero-ruby/models/payroll_nz/problem.rb +++ b/lib/xero-ruby/models/payroll_nz/problem.rb @@ -226,9 +226,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -255,35 +252,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement.rb b/lib/xero-ruby/models/payroll_nz/reimbursement.rb index 33c55b8b..abbbc761 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement.rb @@ -329,9 +329,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -358,35 +355,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb b/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb index 21a3f68b..088a30cd 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement_line.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb b/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb index bebd4057..37bc1e5e 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursement_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/reimbursements.rb b/lib/xero-ruby/models/payroll_nz/reimbursements.rb index c46fa523..a67bf8c1 100644 --- a/lib/xero-ruby/models/payroll_nz/reimbursements.rb +++ b/lib/xero-ruby/models/payroll_nz/reimbursements.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb index 7fe9866e..f68a7089 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wage.rb @@ -349,9 +349,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -378,35 +375,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb index 502cf047..23bdf2e3 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wage_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb b/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb index e9cc7c54..82bb0457 100644 --- a/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb +++ b/lib/xero-ruby/models/payroll_nz/salary_and_wages.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/settings.rb b/lib/xero-ruby/models/payroll_nz/settings.rb index 6838a76f..802b8ef3 100644 --- a/lib/xero-ruby/models/payroll_nz/settings.rb +++ b/lib/xero-ruby/models/payroll_nz/settings.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb index a835e1ff..cad8ab54 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb index ea812ba6..24f31e31 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction_line.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb b/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb index d034ff36..1e26f0bf 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deduction_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb b/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb index 6b13e56c..2d84a2af 100644 --- a/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb +++ b/lib/xero-ruby/models/payroll_nz/statutory_deductions.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/superannuation_line.rb b/lib/xero-ruby/models/payroll_nz/superannuation_line.rb index 6d745664..b66f8e61 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuation_line.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuation_line.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/superannuation_object.rb b/lib/xero-ruby/models/payroll_nz/superannuation_object.rb index 7cd33e3d..cca06204 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuation_object.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuation_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/superannuations.rb b/lib/xero-ruby/models/payroll_nz/superannuations.rb index 6d51dfb0..6381a219 100644 --- a/lib/xero-ruby/models/payroll_nz/superannuations.rb +++ b/lib/xero-ruby/models/payroll_nz/superannuations.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/tax_line.rb b/lib/xero-ruby/models/payroll_nz/tax_line.rb index d6feeb23..fa5226c8 100644 --- a/lib/xero-ruby/models/payroll_nz/tax_line.rb +++ b/lib/xero-ruby/models/payroll_nz/tax_line.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/tax_settings.rb b/lib/xero-ruby/models/payroll_nz/tax_settings.rb index 17ce3e0a..bde91f13 100644 --- a/lib/xero-ruby/models/payroll_nz/tax_settings.rb +++ b/lib/xero-ruby/models/payroll_nz/tax_settings.rb @@ -259,9 +259,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -288,35 +285,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet.rb b/lib/xero-ruby/models/payroll_nz/timesheet.rb index 6571d003..e4998393 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet.rb @@ -313,9 +313,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -342,35 +339,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb b/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb index f75a9035..9af76f0e 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_earnings_line.rb @@ -263,9 +263,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -292,35 +289,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_line.rb b/lib/xero-ruby/models/payroll_nz/timesheet_line.rb index 632c10be..ab80ece6 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_line.rb @@ -228,9 +228,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -257,35 +254,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb b/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb index 6fb78ca3..70da8bcc 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_line_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/timesheet_object.rb b/lib/xero-ruby/models/payroll_nz/timesheet_object.rb index e0f7b77c..85ae344e 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheet_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/timesheets.rb b/lib/xero-ruby/models/payroll_nz/timesheets.rb index ecae2717..564e4a42 100644 --- a/lib/xero-ruby/models/payroll_nz/timesheets.rb +++ b/lib/xero-ruby/models/payroll_nz/timesheets.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/tracking_categories.rb b/lib/xero-ruby/models/payroll_nz/tracking_categories.rb index 3e53c3e2..f5d3632c 100644 --- a/lib/xero-ruby/models/payroll_nz/tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_nz/tracking_categories.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_nz/tracking_category.rb b/lib/xero-ruby/models/payroll_nz/tracking_category.rb index a2c2ba05..14e13e50 100644 --- a/lib/xero-ruby/models/payroll_nz/tracking_category.rb +++ b/lib/xero-ruby/models/payroll_nz/tracking_category.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/account.rb b/lib/xero-ruby/models/payroll_uk/account.rb index 3de5c076..a424a2fb 100644 --- a/lib/xero-ruby/models/payroll_uk/account.rb +++ b/lib/xero-ruby/models/payroll_uk/account.rb @@ -244,9 +244,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -273,35 +270,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/accounts.rb b/lib/xero-ruby/models/payroll_uk/accounts.rb index 5298a03d..d0cf2940 100644 --- a/lib/xero-ruby/models/payroll_uk/accounts.rb +++ b/lib/xero-ruby/models/payroll_uk/accounts.rb @@ -175,9 +175,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -204,35 +201,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/address.rb b/lib/xero-ruby/models/payroll_uk/address.rb index 8e59b602..b54945df 100644 --- a/lib/xero-ruby/models/payroll_uk/address.rb +++ b/lib/xero-ruby/models/payroll_uk/address.rb @@ -228,9 +228,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -257,35 +254,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/bank_account.rb b/lib/xero-ruby/models/payroll_uk/bank_account.rb index 8e6240d3..3d4fe68b 100644 --- a/lib/xero-ruby/models/payroll_uk/bank_account.rb +++ b/lib/xero-ruby/models/payroll_uk/bank_account.rb @@ -208,9 +208,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -237,35 +234,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/benefit.rb b/lib/xero-ruby/models/payroll_uk/benefit.rb index cf9e640e..e7b2d1ef 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit.rb @@ -383,9 +383,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -412,35 +409,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/benefit_line.rb b/lib/xero-ruby/models/payroll_uk/benefit_line.rb index 4efd35a5..acd2fd05 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit_line.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit_line.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/benefit_object.rb b/lib/xero-ruby/models/payroll_uk/benefit_object.rb index ba5bcf18..a75dc507 100644 --- a/lib/xero-ruby/models/payroll_uk/benefit_object.rb +++ b/lib/xero-ruby/models/payroll_uk/benefit_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/benefits.rb b/lib/xero-ruby/models/payroll_uk/benefits.rb index 854357dd..2e4eed73 100644 --- a/lib/xero-ruby/models/payroll_uk/benefits.rb +++ b/lib/xero-ruby/models/payroll_uk/benefits.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/court_order_line.rb b/lib/xero-ruby/models/payroll_uk/court_order_line.rb index 8cc91250..c1cf44bf 100644 --- a/lib/xero-ruby/models/payroll_uk/court_order_line.rb +++ b/lib/xero-ruby/models/payroll_uk/court_order_line.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/deduction.rb b/lib/xero-ruby/models/payroll_uk/deduction.rb index a35b2f1a..b1afdcfb 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction.rb @@ -391,9 +391,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -420,35 +417,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/deduction_line.rb b/lib/xero-ruby/models/payroll_uk/deduction_line.rb index 48ddfeaa..f1920f07 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction_line.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction_line.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/deduction_object.rb b/lib/xero-ruby/models/payroll_uk/deduction_object.rb index 21876c13..d1000a41 100644 --- a/lib/xero-ruby/models/payroll_uk/deduction_object.rb +++ b/lib/xero-ruby/models/payroll_uk/deduction_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/deductions.rb b/lib/xero-ruby/models/payroll_uk/deductions.rb index e5849e7c..18a59b95 100644 --- a/lib/xero-ruby/models/payroll_uk/deductions.rb +++ b/lib/xero-ruby/models/payroll_uk/deductions.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_line.rb b/lib/xero-ruby/models/payroll_uk/earnings_line.rb index d2ff734e..69d6433e 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_line.rb @@ -253,9 +253,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -282,35 +279,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_order.rb b/lib/xero-ruby/models/payroll_uk/earnings_order.rb index ad0d5ffe..e18c180d 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_order.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_order.rb @@ -220,9 +220,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -249,35 +246,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb index d0ae6be6..d61077c9 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_order_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_orders.rb b/lib/xero-ruby/models/payroll_uk/earnings_orders.rb index 48b562d8..3472dd09 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_orders.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_orders.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rate.rb b/lib/xero-ruby/models/payroll_uk/earnings_rate.rb index bcc9c41c..ebec8827 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rate.rb @@ -359,9 +359,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -388,35 +385,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb index d7c8f68d..4d0ac851 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rate_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_rates.rb b/lib/xero-ruby/models/payroll_uk/earnings_rates.rb index d85e9825..007e6f7d 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_rates.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_rates.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_template.rb b/lib/xero-ruby/models/payroll_uk/earnings_template.rb index 33812784..020b1aca 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_template.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_template.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb b/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb index 179e8057..50d0ddcb 100644 --- a/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb +++ b/lib/xero-ruby/models/payroll_uk/earnings_template_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee.rb b/lib/xero-ruby/models/payroll_uk/employee.rb index 56a1fe72..cc088122 100644 --- a/lib/xero-ruby/models/payroll_uk/employee.rb +++ b/lib/xero-ruby/models/payroll_uk/employee.rb @@ -349,9 +349,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -378,35 +375,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave.rb b/lib/xero-ruby/models/payroll_uk/employee_leave.rb index b2796677..3f11c7e5 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave.rb @@ -255,9 +255,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -284,35 +281,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb index aa533b5a..6d828894 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_balance.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb index 90f8b222..bb0b1728 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_balances.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb index d3238ea6..8ae95f7f 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb index f4578bfa..a30c938b 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_type.rb @@ -271,9 +271,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -300,35 +297,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb index 037674d9..05dfe045 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_type_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb b/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb index 3dffca08..1df08211 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leave_types.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_leaves.rb b/lib/xero-ruby/models/payroll_uk/employee_leaves.rb index cb289bab..3f45feb6 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_leaves.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_leaves.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_object.rb b/lib/xero-ruby/models/payroll_uk/employee_object.rb index 75febe51..378c41aa 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb b/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb index 18a3f7c6..476d200c 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_opening_balances.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb b/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb index 545a518a..2566b0fd 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_opening_balances_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb index fc9892b6..ff27538d 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_template.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb index ad89aecd..40d05c49 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_template_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb b/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb index 4c7c75cd..901941c1 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_pay_templates.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb index a07d6ad2..198cdba5 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance.rb @@ -245,9 +245,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -274,35 +271,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb index a7d8d994..4d3c7564 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_balance_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb index 41417a0b..5b70ff86 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leave_summary.rb @@ -287,9 +287,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -316,35 +313,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb index 7cb48c0f..57e71b3f 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_leaves_summaries.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb index 43072c1b..f68583c1 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave.rb @@ -384,9 +384,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -413,35 +410,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb index 909a95d1..78f6a9a5 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leave_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb index 9d9ed36d..74763f0c 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_statutory_sick_leaves.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_tax.rb b/lib/xero-ruby/models/payroll_uk/employee_tax.rb index ed80aeea..7eeca6b9 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_tax.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_tax.rb @@ -273,9 +273,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -302,35 +299,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb b/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb index dc8f76d3..ed78be49 100644 --- a/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employee_tax_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employees.rb b/lib/xero-ruby/models/payroll_uk/employees.rb index 1d2a491e..07380226 100644 --- a/lib/xero-ruby/models/payroll_uk/employees.rb +++ b/lib/xero-ruby/models/payroll_uk/employees.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employment.rb b/lib/xero-ruby/models/payroll_uk/employment.rb index 62b4a088..23e6087e 100644 --- a/lib/xero-ruby/models/payroll_uk/employment.rb +++ b/lib/xero-ruby/models/payroll_uk/employment.rb @@ -245,9 +245,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -274,35 +271,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/employment_object.rb b/lib/xero-ruby/models/payroll_uk/employment_object.rb index 0811a109..578c292d 100644 --- a/lib/xero-ruby/models/payroll_uk/employment_object.rb +++ b/lib/xero-ruby/models/payroll_uk/employment_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/invalid_field.rb b/lib/xero-ruby/models/payroll_uk/invalid_field.rb index 6e98bbde..af45034f 100644 --- a/lib/xero-ruby/models/payroll_uk/invalid_field.rb +++ b/lib/xero-ruby/models/payroll_uk/invalid_field.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb b/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb index 29a38aa6..14d15292 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_accrual_line.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb b/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb index ec58e78e..52fdfac7 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_earnings_line.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/leave_period.rb b/lib/xero-ruby/models/payroll_uk/leave_period.rb index 1288bc7a..bb512713 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_period.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_period.rb @@ -239,9 +239,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -268,35 +265,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/leave_periods.rb b/lib/xero-ruby/models/payroll_uk/leave_periods.rb index 05c5d22b..6c0da074 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_periods.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_periods.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/leave_type.rb b/lib/xero-ruby/models/payroll_uk/leave_type.rb index e7df9947..d52014a5 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_type.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_type.rb @@ -258,9 +258,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -287,35 +284,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/leave_type_object.rb b/lib/xero-ruby/models/payroll_uk/leave_type_object.rb index d86494b1..49bdfec9 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_type_object.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_type_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/leave_types.rb b/lib/xero-ruby/models/payroll_uk/leave_types.rb index cc41b1e3..9e99d53b 100644 --- a/lib/xero-ruby/models/payroll_uk/leave_types.rb +++ b/lib/xero-ruby/models/payroll_uk/leave_types.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/pagination.rb b/lib/xero-ruby/models/payroll_uk/pagination.rb index 4cec3095..228f1e02 100644 --- a/lib/xero-ruby/models/payroll_uk/pagination.rb +++ b/lib/xero-ruby/models/payroll_uk/pagination.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run.rb b/lib/xero-ruby/models/payroll_uk/pay_run.rb index da1d74bd..0bd54bfd 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run.rb @@ -354,9 +354,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -383,35 +380,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb index 0aee70c3..c33ea07e 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendar.rb @@ -293,9 +293,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -322,35 +319,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb index 3d45965e..403e6ea8 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendar_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb b/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb index 65246846..9554b429 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_calendars.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/pay_run_object.rb b/lib/xero-ruby/models/payroll_uk/pay_run_object.rb index 0c338373..5dacc138 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_run_object.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_run_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/pay_runs.rb b/lib/xero-ruby/models/payroll_uk/pay_runs.rb index 384e16c3..fd195e3b 100644 --- a/lib/xero-ruby/models/payroll_uk/pay_runs.rb +++ b/lib/xero-ruby/models/payroll_uk/pay_runs.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/payment_line.rb b/lib/xero-ruby/models/payroll_uk/payment_line.rb index e5e3a57b..c95c69b8 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_line.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_line.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/payment_method.rb b/lib/xero-ruby/models/payroll_uk/payment_method.rb index 1b20de40..0bd875cf 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_method.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_method.rb @@ -227,9 +227,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -256,35 +253,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/payment_method_object.rb b/lib/xero-ruby/models/payroll_uk/payment_method_object.rb index 5a113d6d..4e25438e 100644 --- a/lib/xero-ruby/models/payroll_uk/payment_method_object.rb +++ b/lib/xero-ruby/models/payroll_uk/payment_method_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/payslip.rb b/lib/xero-ruby/models/payroll_uk/payslip.rb index 79326675..f42f4f51 100644 --- a/lib/xero-ruby/models/payroll_uk/payslip.rb +++ b/lib/xero-ruby/models/payroll_uk/payslip.rb @@ -502,9 +502,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -531,35 +528,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/payslip_object.rb b/lib/xero-ruby/models/payroll_uk/payslip_object.rb index 5083f230..1fb0a762 100644 --- a/lib/xero-ruby/models/payroll_uk/payslip_object.rb +++ b/lib/xero-ruby/models/payroll_uk/payslip_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/payslips.rb b/lib/xero-ruby/models/payroll_uk/payslips.rb index 84bbb645..99ddc56a 100644 --- a/lib/xero-ruby/models/payroll_uk/payslips.rb +++ b/lib/xero-ruby/models/payroll_uk/payslips.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/problem.rb b/lib/xero-ruby/models/payroll_uk/problem.rb index b69ab569..fa6a840e 100644 --- a/lib/xero-ruby/models/payroll_uk/problem.rb +++ b/lib/xero-ruby/models/payroll_uk/problem.rb @@ -226,9 +226,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -255,35 +252,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement.rb b/lib/xero-ruby/models/payroll_uk/reimbursement.rb index 79760b9f..307c4159 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb b/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb index 092f0ee8..6b0517e1 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement_line.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb b/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb index d4041e17..66c8f388 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursement_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/reimbursements.rb b/lib/xero-ruby/models/payroll_uk/reimbursements.rb index 29f5fa91..dfe5a01c 100644 --- a/lib/xero-ruby/models/payroll_uk/reimbursements.rb +++ b/lib/xero-ruby/models/payroll_uk/reimbursements.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb index c75e6268..704357a8 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wage.rb @@ -334,9 +334,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -363,35 +360,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb index 686f6b36..7c38538f 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wage_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb b/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb index a7ff5967..9d10046d 100644 --- a/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb +++ b/lib/xero-ruby/models/payroll_uk/salary_and_wages.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/settings.rb b/lib/xero-ruby/models/payroll_uk/settings.rb index ef57c1d7..75314ca8 100644 --- a/lib/xero-ruby/models/payroll_uk/settings.rb +++ b/lib/xero-ruby/models/payroll_uk/settings.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb b/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb index 19631be6..0791960e 100644 --- a/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb +++ b/lib/xero-ruby/models/payroll_uk/statutory_deduction.rb @@ -213,9 +213,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -242,35 +239,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/tax_line.rb b/lib/xero-ruby/models/payroll_uk/tax_line.rb index 1ff643a6..9d2378a7 100644 --- a/lib/xero-ruby/models/payroll_uk/tax_line.rb +++ b/lib/xero-ruby/models/payroll_uk/tax_line.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet.rb b/lib/xero-ruby/models/payroll_uk/timesheet.rb index d8e7fe29..9b2543b7 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet.rb @@ -312,9 +312,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -341,35 +338,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb b/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb index 1963acb4..e9364dbf 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_earnings_line.rb @@ -223,9 +223,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -252,35 +249,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_line.rb b/lib/xero-ruby/models/payroll_uk/timesheet_line.rb index 10e5916e..95ee20df 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_line.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_line.rb @@ -228,9 +228,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -257,35 +254,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb b/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb index 69686912..22aff1e7 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_line_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/timesheet_object.rb b/lib/xero-ruby/models/payroll_uk/timesheet_object.rb index e7c352c7..9cb946dd 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheet_object.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheet_object.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/timesheets.rb b/lib/xero-ruby/models/payroll_uk/timesheets.rb index d3678f86..22b68e79 100644 --- a/lib/xero-ruby/models/payroll_uk/timesheets.rb +++ b/lib/xero-ruby/models/payroll_uk/timesheets.rb @@ -195,9 +195,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -224,35 +221,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/tracking_categories.rb b/lib/xero-ruby/models/payroll_uk/tracking_categories.rb index f533a9d8..1fdefa90 100644 --- a/lib/xero-ruby/models/payroll_uk/tracking_categories.rb +++ b/lib/xero-ruby/models/payroll_uk/tracking_categories.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/payroll_uk/tracking_category.rb b/lib/xero-ruby/models/payroll_uk/tracking_category.rb index 8c292e0b..75cd3279 100644 --- a/lib/xero-ruby/models/payroll_uk/tracking_category.rb +++ b/lib/xero-ruby/models/payroll_uk/tracking_category.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/amount.rb b/lib/xero-ruby/models/projects/amount.rb index c700868a..e132bfba 100644 --- a/lib/xero-ruby/models/projects/amount.rb +++ b/lib/xero-ruby/models/projects/amount.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/error.rb b/lib/xero-ruby/models/projects/error.rb index f07081d5..7cb48bf1 100644 --- a/lib/xero-ruby/models/projects/error.rb +++ b/lib/xero-ruby/models/projects/error.rb @@ -183,9 +183,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -212,35 +209,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/pagination.rb b/lib/xero-ruby/models/projects/pagination.rb index 5f35266b..1215791f 100644 --- a/lib/xero-ruby/models/projects/pagination.rb +++ b/lib/xero-ruby/models/projects/pagination.rb @@ -203,9 +203,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -232,35 +229,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/project.rb b/lib/xero-ruby/models/projects/project.rb index 9553e5e3..5190c37b 100644 --- a/lib/xero-ruby/models/projects/project.rb +++ b/lib/xero-ruby/models/projects/project.rb @@ -388,9 +388,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -417,35 +414,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/project_create_or_update.rb b/lib/xero-ruby/models/projects/project_create_or_update.rb index a1f06987..7446e836 100644 --- a/lib/xero-ruby/models/projects/project_create_or_update.rb +++ b/lib/xero-ruby/models/projects/project_create_or_update.rb @@ -208,9 +208,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -237,35 +234,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/project_patch.rb b/lib/xero-ruby/models/projects/project_patch.rb index 52f97d1a..433eb063 100644 --- a/lib/xero-ruby/models/projects/project_patch.rb +++ b/lib/xero-ruby/models/projects/project_patch.rb @@ -178,9 +178,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -207,35 +204,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/project_user.rb b/lib/xero-ruby/models/projects/project_user.rb index 59dc6372..95146c8c 100644 --- a/lib/xero-ruby/models/projects/project_user.rb +++ b/lib/xero-ruby/models/projects/project_user.rb @@ -193,9 +193,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -222,35 +219,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/project_users.rb b/lib/xero-ruby/models/projects/project_users.rb index 680e19b7..6137b5d7 100644 --- a/lib/xero-ruby/models/projects/project_users.rb +++ b/lib/xero-ruby/models/projects/project_users.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/projects.rb b/lib/xero-ruby/models/projects/projects.rb index 8c2722b2..924d5c84 100644 --- a/lib/xero-ruby/models/projects/projects.rb +++ b/lib/xero-ruby/models/projects/projects.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/task.rb b/lib/xero-ruby/models/projects/task.rb index 1e9089e8..630697a9 100644 --- a/lib/xero-ruby/models/projects/task.rb +++ b/lib/xero-ruby/models/projects/task.rb @@ -350,9 +350,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -379,35 +376,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/task_create_or_update.rb b/lib/xero-ruby/models/projects/task_create_or_update.rb index ae7e264f..b0e92bf1 100644 --- a/lib/xero-ruby/models/projects/task_create_or_update.rb +++ b/lib/xero-ruby/models/projects/task_create_or_update.rb @@ -218,9 +218,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -247,35 +244,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/tasks.rb b/lib/xero-ruby/models/projects/tasks.rb index 9261234c..0fb706bf 100644 --- a/lib/xero-ruby/models/projects/tasks.rb +++ b/lib/xero-ruby/models/projects/tasks.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/time_entries.rb b/lib/xero-ruby/models/projects/time_entries.rb index 3a6b00a6..cc1c7d4d 100644 --- a/lib/xero-ruby/models/projects/time_entries.rb +++ b/lib/xero-ruby/models/projects/time_entries.rb @@ -185,9 +185,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -214,35 +211,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/time_entry.rb b/lib/xero-ruby/models/projects/time_entry.rb index a58416b0..2375f2a3 100644 --- a/lib/xero-ruby/models/projects/time_entry.rb +++ b/lib/xero-ruby/models/projects/time_entry.rb @@ -290,9 +290,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -319,35 +316,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end diff --git a/lib/xero-ruby/models/projects/time_entry_create_or_update.rb b/lib/xero-ruby/models/projects/time_entry_create_or_update.rb index 940547f8..8c2a2d62 100644 --- a/lib/xero-ruby/models/projects/time_entry_create_or_update.rb +++ b/lib/xero-ruby/models/projects/time_entry_create_or_update.rb @@ -233,9 +233,6 @@ def to_body def to_hash(downcase: false) hash = {} self.class.attribute_map.each_pair do |attr, param| - puts "1 ***********" - puts "attr: #{attr}" - puts "param: #{param}" value = self.send(attr) next if value.nil? key = downcase ? attr : param @@ -262,35 +259,21 @@ def _to_hash(value, downcase: false) # value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| - binding.pry value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) } end elsif value.respond_to? :to_hash - value.to_hash + value.to_hash(downcase: downcase) else value end end - # def deplurarlized_model_name_from(param) - # n = param.length - # case param - # when 'Addresses' - # 'Address' - # when 'TrackingCategories' - # 'TrackingCategory' - # else - # puts "param -> #{param}" - # puts "param[0..n-2] -> #{param[0..n-2]}" - # puts "********************************" - # param[0..n-2] - # end - # end - def parse_date(datestring) if datestring.include?('Date') - seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i / 1000.0 - Time.at(seconds_since_epoch).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s + date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// + original, date, timezone = *date_pattern.match(datestring) + date = (date.to_i / 1000) + Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end From ebe836641c1118c8c6d03bfbdd76ae3078899b0f Mon Sep 17 00:00:00 2001 From: serknight Date: Tue, 11 May 2021 10:52:51 -0600 Subject: [PATCH 4/7] bump to version 3 --- lib/xero-ruby/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xero-ruby/version.rb b/lib/xero-ruby/version.rb index 1f1eb550..023122b1 100644 --- a/lib/xero-ruby/version.rb +++ b/lib/xero-ruby/version.rb @@ -11,5 +11,5 @@ =end module XeroRuby - VERSION = '2.11.0' + VERSION = '3.0.0' end From e3cae67a2b4e87f20f6ecbf51182606e544e70bd Mon Sep 17 00:00:00 2001 From: serknight Date: Tue, 11 May 2021 11:25:28 -0600 Subject: [PATCH 5/7] specs fixed, and removed duplicate enums --- Gemfile.lock | 21 ++++---- README.md | 12 ++--- docs/accounting/index.html | 2 +- docs/assets/index.html | 2 +- docs/files/index.html | 2 +- docs/payroll_au/index.html | 2 +- docs/payroll_nz/index.html | 2 +- docs/payroll_uk/index.html | 2 +- docs/projects/index.html | 2 +- lib/xero-ruby/models/accounting/account.rb | 29 +++------- .../models/accounting/organisation.rb | 53 +++++++------------ spec/helper_methods_spec.rb | 14 ++--- 12 files changed, 54 insertions(+), 89 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8192da95..f5871234 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - xero-ruby (2.10.0) + xero-ruby (3.0.0) faraday (~> 1.0, >= 1.0.1) json (~> 2.1, >= 2.1.0) json-jwt (~> 1.5, >= 1.5.2) @@ -9,12 +9,12 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.0.3.4) + activesupport (6.1.3.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) aes_key_wrap (1.1.0) ast (2.4.1) bindata (2.4.9) @@ -31,7 +31,7 @@ GEM faraday-excon (1.1.0) faraday-net_http (1.0.1) faraday-net_http_persistent (1.1.0) - i18n (1.8.7) + i18n (1.8.10) concurrent-ruby (~> 1.0) jaro_winkler (1.5.4) json (2.5.1) @@ -40,7 +40,7 @@ GEM aes_key_wrap bindata method_source (1.0.0) - minitest (5.14.3) + minitest (5.14.4) multipart-post (2.1.1) parallel (1.20.1) parser (2.7.2.0) @@ -77,9 +77,8 @@ GEM unicode-display_width (>= 1.4.0, < 1.6) ruby-progressbar (1.10.1) ruby2_keywords (0.0.4) - thread_safe (0.3.6) - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) unicode-display_width (1.5.0) zeitwerk (2.4.2) diff --git a/README.md b/README.md index 65719af7..4a0ea6d7 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,6 @@ We have two sample apps showing SDK usage: * Login to your Xero developer [/myapps](https://developer.xero.com/myapps) dashboard & create an API application * Copy the credentials from your API app and store/access them using a secure ENV variable strategy * 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"`" - - - ## Installation To install this gem to your project: ``` @@ -110,7 +107,7 @@ A `token_set` is what we call the XeroAPI response that contains data about your 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. -Both the `id_token` & `access_token` are JWT's, and can be decoded for to see additional metadata described in the Token Helpers section: +Both the `id_token` & `access_token` are JWT's, and can be decoded to see additional metadata described in the Token Helpers section: ## Making API calls with a valid token_set After the initial user interaction you can simply setup a xero_client by passing the whole token_set to the client. ```ruby @@ -118,7 +115,7 @@ xero_client.set_token_set(user.token_set) xero_client.refresh_token_set(user.token_set) ``` -This sets the access_token on the client, and returns a refreshed `token_set` you should save in your database for the next time you need to connect to Xero's API. +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. ## Token Helpers ```ruby xero_client.token_set @@ -228,10 +225,13 @@ accounts = xero_client.accounting_api.get_accounts(tenant_id).accounts 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 }]} invoice = xero_client.accounting_api.create_invoices(tenant_id, invoices).invoices.first -# display out all the serialized data as a hash +# display out all the serialized data as a snake_case hash puts invoices.to_attributes => {type: 'ACCREC', line_items: [...]} +puts invoices.to_hash(downcase: false) +=> {'Type': 'ACCREC', 'LineItems': [...]} + # Create History payment = xero_client.accounting_api.get_payments(tenant_id).payments.first history_records = { history_records: [{ details: "This payment now has some History!" }]} diff --git a/docs/accounting/index.html b/docs/accounting/index.html index 21377559..0d0a8ea0 100644 --- a/docs/accounting/index.html +++ b/docs/accounting/index.html @@ -5825,7 +5825,7 @@