defmodule Requests.Payments.ThreeDS.ThirdParty do
@type t :: %__MODULE__{
enabled: true | false,
eci: String.t(),
cryptogram: String.t(),
xid: String.t(),
version: String.t(),
exemption: String.t(),
status: String.t(),
authentication_date: String.t(),
authentication_amount: integer(),
flow_type: String.t(),
challenge_indicator: String.t(),
status_reason_code: String.t(),
challenge_cancel_reason: String.t(),
score: String.t(),
cryptogram_algorithm: String.t(),
type: String.t()
}
@enforce_keys [:enabled, :eci, :cryptogram, :xid, :version, :type]
defstruct [
:enabled,
:eci,
:cryptogram,
:xid,
:version,
:exemption,
:status,
:authentication_date,
:authentication_amount,
:flow_type,
:challenge_indicator,
:status_reason_code,
:challenge_cancel_reason,
:score,
:cryptogram_algorithm,
:type
]
def build(%{type: "third_party"} = params) when is_map(params) do
%{
enabled: params[:enabled],
eci: params[:eci],
cryptogram: params[:cryptogram],
xid: params[:xid],
version: params[:version],
exemption: params[:exemption],
status: params[:status],
authentication_date: params[:authentication_date],
authentication_amount: params[:authentication_amount],
flow_type: params[:flow_type],
challenge_indicator: params[:challenge_indicator],
status_reason_code: params[:status_reason_code],
challenge_cancel_reason: params[:challenge_cancel_reason],
score: params[:score],
cryptogram_algorithm: params[:score]
}
end
def build(_), do: nil
end