encode<V> static method

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

Implementation

static V encode<V>(
  TaxTransactionCreateReversalOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.flatAmount != null) {
    container.encodeInt(
      'flat_amount',
      instance.flatAmount!,
    );
  }
  if (instance.lineItems != null) {
    container.encodeList(
      'line_items',
      (container) =>
          instance.lineItems!.forEach((el) => TransactionLineItemsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  container.encodeString(
    'mode',
    instance.mode,
  );
  container.encodeString(
    'original_transaction',
    instance.originalTransaction,
  );
  container.encodeString(
    'reference',
    instance.reference,
  );
  if (instance.shippingCost != null) {
    TransactionShippingCost.encode(
      instance.shippingCost!,
      container.nestedSingleValueContainer('shipping_cost').encoder,
    );
  }
  return container.value;
}