defmodule Requests.Payments.Sources.WeChatPay do
alias Customers.BillingAddress
@type t :: %__MODULE__{
type: String.t(),
billing_address: String.t()
}
@enforce_keys [:type]
defstruct [
:type,
:billing_address
]
def build(%{type: type, billing_address: billing_address}) do
%{
type: type,
billing_address: BillingAddress.build(billing_address)
}
end
def build(%{"type" => type, "billing_address" => billing_address}) do
%{
type: type,
billing_address: BillingAddress.build(billing_address)
}
end
def build(_), do: nil
end