lib/docusign/model/billing_plans.ex

# NOTE: This file is auto generated by OpenAPI Generator
# https://openapi-generator.tech
# Do not edit this file manually.

defmodule DocuSign.Model.BillingPlans do
  @moduledoc """
  Billing plans
  """

  alias DocuSign.Deserializer
  alias DocuSign.Model.AccountAddress
  alias DocuSign.Model.AccountBillingPlan
  alias DocuSign.Model.BillingEntityInformationResponse
  alias DocuSign.Model.BillingPlan
  alias DocuSign.Model.CreditCardInformation
  alias DocuSign.Model.DirectDebitProcessorInformation
  alias DocuSign.Model.DowngradePlanUpdateResponse
  alias DocuSign.Model.DowngradeRequestInformation
  alias DocuSign.Model.PaymentProcessorInformation
  alias DocuSign.Model.ReferralInformation

  defstruct [
    :billingAddress,
    :billingAddressIsCreditCardAddress,
    :billingPlan,
    :creditCardInformation,
    :directDebitProcessorInformation,
    :downgradePlanInformation,
    :downgradeRequestInformation,
    :entityInformation,
    :paymentMethod,
    :paymentProcessorInformation,
    :referralInformation,
    :successorPlans,
    :taxExemptId
  ]

  @doc false
  defimpl Jason.Encoder, for: __MODULE__ do
    def encode(struct, opts) do
      struct
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> is_nil(v) end)
      |> Map.new()
      |> Jason.Encode.map(opts)
    end
  end

  @type t :: %__MODULE__{
          :billingAddress => AccountAddress.t() | nil,
          :billingAddressIsCreditCardAddress => String.t() | nil,
          :billingPlan => AccountBillingPlan.t() | nil,
          :creditCardInformation => CreditCardInformation.t() | nil,
          :directDebitProcessorInformation => DirectDebitProcessorInformation.t() | nil,
          :downgradePlanInformation => DowngradePlanUpdateResponse.t() | nil,
          :downgradeRequestInformation => DowngradeRequestInformation.t() | nil,
          :entityInformation => BillingEntityInformationResponse.t() | nil,
          :paymentMethod => String.t() | nil,
          :paymentProcessorInformation => PaymentProcessorInformation.t() | nil,
          :referralInformation => ReferralInformation.t() | nil,
          :successorPlans => [BillingPlan.t()] | nil,
          :taxExemptId => String.t() | nil
        }

  def decode(value) do
    value
    |> Deserializer.deserialize(
      :billingAddress,
      :struct,
      AccountAddress
    )
    |> Deserializer.deserialize(
      :billingPlan,
      :struct,
      AccountBillingPlan
    )
    |> Deserializer.deserialize(
      :creditCardInformation,
      :struct,
      CreditCardInformation
    )
    |> Deserializer.deserialize(
      :directDebitProcessorInformation,
      :struct,
      DirectDebitProcessorInformation
    )
    |> Deserializer.deserialize(
      :downgradePlanInformation,
      :struct,
      DowngradePlanUpdateResponse
    )
    |> Deserializer.deserialize(
      :downgradeRequestInformation,
      :struct,
      DowngradeRequestInformation
    )
    |> Deserializer.deserialize(
      :entityInformation,
      :struct,
      BillingEntityInformationResponse
    )
    |> Deserializer.deserialize(
      :paymentProcessorInformation,
      :struct,
      PaymentProcessorInformation
    )
    |> Deserializer.deserialize(
      :referralInformation,
      :struct,
      ReferralInformation
    )
    |> Deserializer.deserialize(
      :successorPlans,
      :list,
      BillingPlan
    )
    |> then(&struct(__MODULE__, &1))
  end
end