encode<V> static method
V
encode<
V>( - Price instance,
- Encoder<V> encoder
)
override
Implementation
static V encode<V>(
Price instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
container.encodeBool(
'active',
instance.active,
);
InvoiceitemPlanBillingScheme.encode(
instance.billingScheme,
container.nestedSingleValueContainer('billing_scheme').encoder,
);
container.encodeDateTime(
'created',
instance.created,
);
container.encodeString(
'currency',
instance.currency,
);
if (instance.currencyOptions != null) {
container.encodeMap(
'currency_options',
(container) => instance.currencyOptions!.forEach((
key,
value,
) =>
CurrencyOption.encode(
value,
container.nestedSingleValueContainer(key).encoder,
)),
);
}
if (instance.customUnitAmount != null) {
CustomUnitAmount.encode(
instance.customUnitAmount!,
container.nestedSingleValueContainer('custom_unit_amount').encoder,
);
}
container.encodeString(
'id',
instance.id,
);
container.encodeBool(
'livemode',
instance.livemode,
);
if (instance.lookupKey != null) {
container.encodeString(
'lookup_key',
instance.lookupKey!,
);
}
container.encodeMap(
'metadata',
(container) => instance.metadata.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
if (instance.nickname != null) {
container.encodeString(
'nickname',
instance.nickname!,
);
}
container.encodeString(
'object',
'price',
);
InvoiceitemPlanProductOrId.encode(
instance.product,
container.nestedSingleValueContainer('product').encoder,
);
if (instance.recurring != null) {
InvoiceitemPriceRecurring.encode(
instance.recurring!,
container.nestedSingleValueContainer('recurring').encoder,
);
}
if (instance.taxBehavior != null) {
CurrencyOptionTaxBehavior.encode(
instance.taxBehavior!,
container.nestedSingleValueContainer('tax_behavior').encoder,
);
}
if (instance.tiers != null) {
container.encodeList(
'tiers',
(container) => instance.tiers!.forEach((el) => PriceTier.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.tiersMode != null) {
InvoiceitemPlanTiersMode.encode(
instance.tiersMode!,
container.nestedSingleValueContainer('tiers_mode').encoder,
);
}
if (instance.transformQuantity != null) {
InvoiceitemPlanTransformUsage.encode(
instance.transformQuantity!,
container.nestedSingleValueContainer('transform_quantity').encoder,
);
}
InvoiceitemPriceType.encode(
instance.type,
container.nestedSingleValueContainer('type').encoder,
);
if (instance.unitAmount != null) {
container.encodeInt(
'unit_amount',
instance.unitAmount!,
);
}
if (instance.unitAmountDecimal != null) {
container.encodeString(
'unit_amount_decimal',
instance.unitAmountDecimal!,
);
}
return container.value;
}