Skip to content

Instantly share code, notes, and snippets.

@hayduke19us
Created December 8, 2016 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hayduke19us/92f0fb153c4e1a23f7222b1f02abf9fd to your computer and use it in GitHub Desktop.
Save hayduke19us/92f0fb153c4e1a23f7222b1f02abf9fd to your computer and use it in GitHub Desktop.
module Serializers
class Reservation < Base
template(:default) do |reservation|
{
adults: reservation.adults.count,
booked_datetime: reservation.booked_at.to_s,
cancellation_policy: reservation.room_rate.cancellation_policy,
cancelled_datetime: reservation.cancelled_at.to_s,
check_in: reservation.check_in,
check_out: reservation.check_out,
children: reservation.children.count,
children_ages: reservation.children_ages,
currency: reservation.net_rate_currency,
gross_profit: reservation.gross_profit,
hotel_address: Serializers::Address.new.sanitize(reservation.address, :single_line),
hotel_name: reservation.property.try(:name),
nightly_net_rates: Serializers::NetRate.new.sanitize(reservation, :nightly_rates),
nightly_sell_rates: Serializers::SellRate.new.sanitize(reservation, :nightly_rates),
confirmation_code: reservation.number,
room_type: reservation.room_type_names.first,
supplier: reservation.supplier_code,
supplier_confirmation_code: reservation.supplier_confirmation_code,
supplier_gurantee: reservation.supplier_guarantee_method,
total_net_rate: reservation.net_rate_total,
total_sell_rate: reservation.sell_rate_total
}
end
template(:summary) do |reservation|
{
confirmation_code: reservation.number,
check_in: reservation.check_in,
check_out: reservation.check_out,
currency: reservation.net_rate_currency,
total_sell_rate: reservation.sell_rate_total
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment