Необходимо создать API для онлайн магазина. Для покупки необходимо создать корзину, добавить туда товары и затем купить все товары из корзины. API подразумевает возможности просматривать список всех продуктов, список корзин.
Ожидается использование GenServer для хранения данных корзин.
This file contains hidden or 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
defmodule MyApp.Calculator do | |
def convert(amount, currency_from, currency_to) do | |
with {:ok, rate_currency_from} <- MyApp.Rates.get_current_rate(currency_from), | |
{:ok, rate_currency_to} <- MyApp.Rates.get_current_rate(currency_to), | |
value = amount * rate_currency_from / rate_currency_to do | |
{:ok, value} | |
end | |
end | |
end |