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
class TripBooker | |
# Given a trip and a list of vendors, this class makes bookings for all the vendors | |
def initialize(trip, vendors = :all) | |
@trip = trip | |
@vendors = VendorSelector.new(vendors).all | |
@credentials = CredentialSelector.get_available_credentials | |
end | |
def book!(vendors = nil) | |
{ | |
:results => ((Array(vendors) if vendors) || @vendors).map do |vendor| | |
book_with_vendor!(vendor) | |
end | |
} | |
end | |
private | |
def book_with_vendor!(vendor) | |
VendorBooker.new(@trip, vendor, @credentials.send(vendor)).book! | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment