Created
June 3, 2018 17:16
-
-
Save AndrewDryga/59f84c57d00dcf645d8a3f40a86e3b98 to your computer and use it in GitHub Desktop.
Sage: Booking Happy-Case
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
def book_trip(attrs) do | |
with {:ok, exchange_rates} <- BillingAPI.fetch_currency_exchange_rates(attrs), | |
{:ok, card_authorization} <- BillingAPI.authorize_card(exchange_rates, attrs), | |
{:ok, hotel_booking} <- HotelBookingAPI.book_hotel(attrs), | |
:ok <- Mailer.send_email_confirmation(card_authorization, hotel_booking, attrs), | |
{:ok, charge} <- BillingAPI.charge_card(card_authorization) do | |
{:ok, %{charge: charge, bookings: [hotel_booking]}} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment