Instantly share code, notes, and snippets.

@svs /trip_booker.rb
Last active Dec 11, 2015

Embed
What would you like to do?
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