encode<V> static method

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

Implementation

static V encode<V>(
  CustomerUpdateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.address != null) {
    AccountSupportAddress.encode(
      instance.address!,
      container.nestedSingleValueContainer('address').encoder,
    );
  }
  if (instance.balance != null) {
    container.encodeInt(
      'balance',
      instance.balance!,
    );
  }
  if (instance.cashBalance != null) {
    CustomerCashBalance.encode(
      instance.cashBalance!,
      container.nestedSingleValueContainer('cash_balance').encoder,
    );
  }
  if (instance.coupon != null) {
    container.encodeString(
      'coupon',
      instance.coupon!,
    );
  }
  if (instance.defaultSource != null) {
    container.encodeString(
      'default_source',
      instance.defaultSource!,
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  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.invoicePrefix != null) {
    container.encodeString(
      'invoice_prefix',
      instance.invoicePrefix!,
    );
  }
  if (instance.invoiceSettings != null) {
    CustomerInvoiceSettings.encode(
      instance.invoiceSettings!,
      container.nestedSingleValueContainer('invoice_settings').encoder,
    );
  }
  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.nextInvoiceSequence != null) {
    container.encodeInt(
      'next_invoice_sequence',
      instance.nextInvoiceSequence!,
    );
  }
  if (instance.phone != null) {
    container.encodeString(
      'phone',
      instance.phone!,
    );
  }
  if (instance.preferredLocales != null) {
    container.encodeList(
      'preferred_locales',
      (container) => instance.preferredLocales!
          .forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.promotionCode != null) {
    container.encodeString(
      'promotion_code',
      instance.promotionCode!,
    );
  }
  if (instance.shipping != null) {
    CustomerShipping.encode(
      instance.shipping!,
      container.nestedSingleValueContainer('shipping').encoder,
    );
  }
  if (instance.source != null) {
    container.encodeString(
      'source',
      instance.source!,
    );
  }
  if (instance.tax != null) {
    CustomerTax.encode(
      instance.tax!,
      container.nestedSingleValueContainer('tax').encoder,
    );
  }
  if (instance.taxExempt != null) {
    CustomerTaxExempt.encode(
      instance.taxExempt!,
      container.nestedSingleValueContainer('tax_exempt').encoder,
    );
  }
  if (instance.validate != null) {
    container.encodeBool(
      'validate',
      instance.validate!,
    );
  }
  return container.value;
}