defmodule Requests.Payments.Senders.Individual do
@moduledoc false
alias Customers.BillingAddress
alias Requests.Payments.Senders.Identification
@type t :: %__MODULE__{
type: String.t(),
first_name: String.t(),
last_name: String.t(),
middle_name: String.t(),
address: BillingAddress.t(),
reference: String.t(),
reference_type: String.t(),
source_of_funds: String.t(),
identification: Identification.t(),
date_of_birth: String.t(),
country_of_birth: String.t(),
nationality: String.t()
}
@enforce_keys [
:type,
:first_name,
:last_name,
:address,
:reference,
:reference_type,
:source_of_funds
]
defstruct [
:type,
:first_name,
:last_name,
:middle_name,
:address,
:reference,
:reference_type,
:source_of_funds,
:identification,
:date_of_birth,
:country_of_birth,
:nationality
]
def build(params) when is_map(params) do
%{
type: params[:type],
first_name: params[:first_name],
last_name: params[:last_name],
middle_name: params[:middle_name],
address: BillingAddress.build(params[:address]),
reference: params[:reference],
reference_type: params[:reference_type],
source_of_funds: params[:source_of_funds],
identification: Identification.build(params[:identification]),
date_of_birth: params[:date_of_birth],
country_of_birth: params[:country_of_birth],
nationality: params[:nationality]
}
end
def build(_), do: nil
end