defmodule Responses do
alias Customers.Customer
alias Responses.PaymentCapture
alias Responses.Instruments.{
CreateBankAccount,
BankAccountDetails,
CardDetails,
CreateCard,
Update
}
alias Responses.Payment
alias Responses.PaymentList
def build(%{"type" => "bank_account"} = body, "create_instrument") do
CreateBankAccount.build(body)
end
def build(%{"type" => "card"} = body, "create_instrument") do
CreateCard.build(body)
end
def build(%{"type" => "bank_account"} = body, "instrument_details") do
BankAccountDetails.build(body)
end
def build(%{"type" => "card"} = body, "instrument_details") do
CardDetails.build(body)
end
def build(body, "update_instrument"), do: Update.build(body)
def build(response, "capture_payment") do
PaymentCapture.build(response)
end
def build(body, "payments"), do: Payment.build(body)
def build(%{"id" => id}, "create_customer"), do: %{id: id}
def build(body, "customer_details"), do: Customer.build(body)
def build(body, "payment_list"), do: PaymentList.build(body)
end