encode<V> static method

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

Implementation

static V encode<V>(
  Level3 instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.customerReference != null) {
    container.encodeString(
      'customer_reference',
      instance.customerReference!,
    );
  }
  container.encodeList(
    'line_items',
    (container) => instance.lineItems.forEach((el) => Level3LineItems.encode(
          el,
          container.nestedSingleValueContainer().encoder,
        )),
  );
  container.encodeString(
    'merchant_reference',
    instance.merchantReference,
  );
  if (instance.shippingAddressZip != null) {
    container.encodeString(
      'shipping_address_zip',
      instance.shippingAddressZip!,
    );
  }
  if (instance.shippingAmount != null) {
    container.encodeInt(
      'shipping_amount',
      instance.shippingAmount!,
    );
  }
  if (instance.shippingFromZip != null) {
    container.encodeString(
      'shipping_from_zip',
      instance.shippingFromZip!,
    );
  }
  return container.value;
}