encode<V> static method
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;
}