encode<V> static method

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

Implementation

static V encode<V>(
  IssuingCard instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeString(
    'brand',
    instance.brand,
  );
  if (instance.cancellationReason != null) {
    container.encodeString(
      'cancellation_reason',
      instance.cancellationReason!,
    );
  }
  IssuingCardholder.encode(
    instance.cardholder,
    container.nestedSingleValueContainer('cardholder').encoder,
  );
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.cvc != null) {
    container.encodeString(
      'cvc',
      instance.cvc!,
    );
  }
  container.encodeInt(
    'exp_month',
    instance.expMonth,
  );
  container.encodeInt(
    'exp_year',
    instance.expYear,
  );
  if (instance.financialAccount != null) {
    container.encodeString(
      'financial_account',
      instance.financialAccount!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeString(
    'last4',
    instance.last4,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  if (instance.number != null) {
    container.encodeString(
      'number',
      instance.number!,
    );
  }
  container.encodeString(
    'object',
    'issuing.card',
  );
  if (instance.personalizationDesign != null) {
    IssuingPersonalizationDesignOrId.encode(
      instance.personalizationDesign!,
      container.nestedSingleValueContainer('personalization_design').encoder,
    );
  }
  if (instance.replacedBy != null) {
    IssuingCardOrId.encode(
      instance.replacedBy!,
      container.nestedSingleValueContainer('replaced_by').encoder,
    );
  }
  if (instance.replacementFor != null) {
    IssuingCardOrId.encode(
      instance.replacementFor!,
      container.nestedSingleValueContainer('replacement_for').encoder,
    );
  }
  if (instance.replacementReason != null) {
    container.encodeString(
      'replacement_reason',
      instance.replacementReason!,
    );
  }
  if (instance.shipping != null) {
    IssuingCardShipping.encode(
      instance.shipping!,
      container.nestedSingleValueContainer('shipping').encoder,
    );
  }
  IssuingCardAuthorizationControls.encode(
    instance.spendingControls,
    container.nestedSingleValueContainer('spending_controls').encoder,
  );
  container.encodeString(
    'status',
    instance.status,
  );
  container.encodeString(
    'type',
    instance.type,
  );
  if (instance.wallets != null) {
    IssuingCardWallets.encode(
      instance.wallets!,
      container.nestedSingleValueContainer('wallets').encoder,
    );
  }
  return container.value;
}