Skip to content

Instantly share code, notes, and snippets.

@svs
Last active December 11, 2015 02:39
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 svs/4532644 to your computer and use it in GitHub Desktop.
Save svs/4532644 to your computer and use it in GitHub Desktop.
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