encode<V> static method

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

Implementation

static V encode<V>(
  CardUpdateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.accountHolderName != null) {
    container.encodeString(
      'account_holder_name',
      instance.accountHolderName!,
    );
  }
  if (instance.accountHolderType != null) {
    IssuingCardholderType.encode(
      instance.accountHolderType!,
      container.nestedSingleValueContainer('account_holder_type').encoder,
    );
  }
  if (instance.addressCity != null) {
    container.encodeString(
      'address_city',
      instance.addressCity!,
    );
  }
  if (instance.addressCountry != null) {
    container.encodeString(
      'address_country',
      instance.addressCountry!,
    );
  }
  if (instance.addressLine1 != null) {
    container.encodeString(
      'address_line1',
      instance.addressLine1!,
    );
  }
  if (instance.addressLine2 != null) {
    container.encodeString(
      'address_line2',
      instance.addressLine2!,
    );
  }
  if (instance.addressState != null) {
    container.encodeString(
      'address_state',
      instance.addressState!,
    );
  }
  if (instance.addressZip != null) {
    container.encodeString(
      'address_zip',
      instance.addressZip!,
    );
  }
  if (instance.expMonth != null) {
    container.encodeString(
      'exp_month',
      instance.expMonth!,
    );
  }
  if (instance.expYear != null) {
    container.encodeString(
      'exp_year',
      instance.expYear!,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.name != null) {
    container.encodeString(
      'name',
      instance.name!,
    );
  }
  if (instance.owner != null) {
    CardOwner.encode(
      instance.owner!,
      container.nestedSingleValueContainer('owner').encoder,
    );
  }
  return container.value;
}