encode<V> static method

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

Implementation

static V encode<V>(
  SourceOrder instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.email != null) {
    container.encodeString(
      'email',
      instance.email!,
    );
  }
  if (instance.items != null) {
    container.encodeList(
      'items',
      (container) => instance.items!.forEach((el) => SourceOrderItem.encode(
            el,
            container.nestedSingleValueContainer().encoder,
          )),
    );
  }
  if (instance.shipping != null) {
    Shipping.encode(
      instance.shipping!,
      container.nestedSingleValueContainer('shipping').encoder,
    );
  }
  return container.value;
}