Created
December 8, 2016 05:41
-
-
Save hayduke19us/92f0fb153c4e1a23f7222b1f02abf9fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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