Last active
March 29, 2019 14:22
-
-
Save leandrocp/cccbc82d9424ff46190b093639554de5 to your computer and use it in GitHub Desktop.
art_bc_sales_customer_service.ex
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
# apps/sales/lib/client/support.ex | |
defmodule Sales.Client.Support do | |
alias Sales.Domain | |
def get_customer(%Domain.Customer{id: customer_id} = customer) do | |
customer_has_support_ticket = | |
customer_id | |
|> Support.get_customer() | |
|> has_support_ticket() | |
%Domain.Customer{customer | has_support_ticket: customer_has_support_ticket} | |
end | |
defp has_support_ticket(%{last_ticket_id: last_ticket_id}) when is_nil(last_ticket_id), do: false | |
defp has_support_ticket(_), do: true | |
end | |
# apps/sales/lib/service/customer.ex | |
defmodule Sales.Service.Customer do | |
alias Sales.Domain | |
alias Sales.Client | |
def current_score(%Domain.Customer{} = customer) do | |
customer = Client.Support.get_customer(customer) | |
case customer.has_support_ticket do | |
false -> 100 | |
true -> 50 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment