encode<V> static method

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

Implementation

static V encode<V>(
  IssuingCardholderUpdateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.billing != null) {
    CardholderBilling.encode(
      instance.billing!,
      container.nestedSingleValueContainer('billing').encoder,
    );
  }
  if (instance.company != null) {
    CardholderCompany.encode(
      instance.company!,
      container.nestedSingleValueContainer('company').encoder,
    );
  }
  if (instance.email != null) {
    container.encodeString(
      'email',
      instance.email!,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.individual != null) {
    CardholderIndividual.encode(
      instance.individual!,
      container.nestedSingleValueContainer('individual').encoder,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.phoneNumber != null) {
    container.encodeString(
      'phone_number',
      instance.phoneNumber!,
    );
  }
  if (instance.preferredLocales != null) {
    container.encodeList(
      'preferred_locales',
      (container) => instance.preferredLocales!
          .forEach((el) => IssuingCardholderPreferredLocalesItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.spendingControls != null) {
    CardholderSpendingControls.encode(
      instance.spendingControls!,
      container.nestedSingleValueContainer('spending_controls').encoder,
    );
  }
  if (instance.status != null) {
    BillingMeterStatus.encode(
      instance.status!,
      container.nestedSingleValueContainer('status').encoder,
    );
  }
  return container.value;
}