encode<V> static method

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

Implementation

static V encode<V>(
  SessionInvoiceData instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.accountTaxIds != null) {
    container.encodeList(
      'account_tax_ids',
      (container) =>
          instance.accountTaxIds!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.customFields != null) {
    container.encodeList(
      'custom_fields',
      (container) => instance.customFields!
          .forEach((el) => InvoiceSettingCustomField.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.footer != null) {
    container.encodeString(
      'footer',
      instance.footer!,
    );
  }
  if (instance.issuer != null) {
    SessionLiability.encode(
      instance.issuer!,
      container.nestedSingleValueContainer('issuer').encoder,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.renderingOptions != null) {
    SessionRenderingOptions.encode(
      instance.renderingOptions!,
      container.nestedSingleValueContainer('rendering_options').encoder,
    );
  }
  return container.value;
}