lib/requests/payments/sources/customer.ex

defmodule Requests.Payments.Sources.Customer do
    @moduledoc false
  @type t :: %__MODULE__{
          type: String.t(),
          id: String.t()
        }

  @enforce_keys [:type, :id]
  defstruct [
    :type,
    :id
  ]

  def build(raw_params) when is_map(raw_params) do
    params =
      Enum.into(raw_params, %{}, fn {key, value} -> {String.to_existing_atom(key), value} end)

    %{
      type: params[:type],
      id: params[:id]
    }
  end

  def build(_), do: nil
end