encode<V> static method

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

Implementation

static V encode<V>(
  TaxCalculationCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.customer != null) {
    container.encodeString(
      'customer',
      instance.customer!,
    );
  }
  if (instance.customerDetails != null) {
    CalculationCustomerDetails.encode(
      instance.customerDetails!,
      container.nestedSingleValueContainer('customer_details').encoder,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  container.encodeList(
    'line_items',
    (container) =>
        instance.lineItems.forEach((el) => CalculationLineItemsItem.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  if (instance.shippingCost != null) {
    CalculationShippingCost.encode(
      instance.shippingCost!,
      container.nestedSingleValueContainer('shipping_cost').encoder,
    );
  }
  if (instance.taxDate != null) {
    container.encodeInt(
      'tax_date',
      instance.taxDate!,
    );
  }
  return container.value;
}