encode<V> static method

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

Implementation

static V encode<V>(
  ShippingRateCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.deliveryEstimate != null) {
    SessionDeliveryEstimate.encode(
      instance.deliveryEstimate!,
      container.nestedSingleValueContainer('delivery_estimate').encoder,
    );
  }
  container.encodeString(
    'display_name',
    instance.displayName,
  );
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.fixedAmount != null) {
    SessionFixedAmount.encode(
      instance.fixedAmount!,
      container.nestedSingleValueContainer('fixed_amount').encoder,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.taxBehavior != null) {
    ShippingRateCurrencyOptionTaxBehavior.encode(
      instance.taxBehavior!,
      container.nestedSingleValueContainer('tax_behavior').encoder,
    );
  }
  if (instance.taxCode != null) {
    container.encodeString(
      'tax_code',
      instance.taxCode!,
    );
  }
  if (instance.type != null) {
    container.encodeString(
      'type',
      'fixed_amount',
    );
  }
  return container.value;
}