encode<V> static method

V encode<V>(
  1. TokenCreateOptions instance,
  2. Encoder<V> encoder
)

Implementation

static V encode<V>(
  TokenCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.account != null) {
    TokenAccount.encode(
      instance.account!,
      container.nestedSingleValueContainer('account').encoder,
    );
  }
  if (instance.bankAccount != null) {
    TokenBankAccount.encode(
      instance.bankAccount!,
      container.nestedSingleValueContainer('bank_account').encoder,
    );
  }
  if (instance.card != null) {
    TokenCard.encode(
      instance.card!,
      container.nestedSingleValueContainer('card').encoder,
    );
  }
  if (instance.customer != null) {
    container.encodeString(
      'customer',
      instance.customer!,
    );
  }
  if (instance.cvcUpdate != null) {
    TokenCvcUpdate.encode(
      instance.cvcUpdate!,
      container.nestedSingleValueContainer('cvc_update').encoder,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.person != null) {
    TokenPerson.encode(
      instance.person!,
      container.nestedSingleValueContainer('person').encoder,
    );
  }
  if (instance.pii != null) {
    TokenPii.encode(
      instance.pii!,
      container.nestedSingleValueContainer('pii').encoder,
    );
  }
  return container.value;
}