lib/requests/payments/three_d_s/integrated.ex

defmodule Requests.Payments.ThreeDS.Integrated do
  @type t :: %{
          allow_upgrade: true | false,
          attempt_n3d: true | false,
          challenge_indicator: String.t(),
          enabled: true | false,
          exemption: String.t(),
          type: String.t()
        }

  @enforce_keys [:enabled, :type]
  defstruct [
    :allow_upgrade,
    :attempt_n3d,
    :challenge_indicator,
    :enabled,
    :exemption,
    :type
  ]

  def build(%{type: "integrated"} = params) when is_map(params) do
    %{
      allow_upgrade: params[:allow_upgrade],
      attempt_n3d: params[:attempt_n3d],
      challenge_indicator: params[:challenge_indicator],
      enabled: params[:enabled],
      exemption: params[:exemption]
    }
  end

  def build(_), do: nil
end