encode<V> static method
V
encode<
V>( - CreditNote instance,
- Encoder<V> encoder
)
override
Implementation
static V encode<V>(
CreditNote instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
container.encodeInt(
'amount',
instance.amount,
);
container.encodeInt(
'amount_shipping',
instance.amountShipping,
);
container.encodeDateTime(
'created',
instance.created,
);
container.encodeString(
'currency',
instance.currency,
);
BankAccountCustomerOrId.encode(
instance.customer,
container.nestedSingleValueContainer('customer').encoder,
);
if (instance.customerBalanceTransaction != null) {
CustomerBalanceTransactionOrId.encode(
instance.customerBalanceTransaction!,
container
.nestedSingleValueContainer('customer_balance_transaction')
.encoder,
);
}
container.encodeInt(
'discount_amount',
instance.discountAmount,
);
container.encodeList(
'discount_amounts',
(container) => instance.discountAmounts
.forEach((el) => DiscountsResourceDiscountAmount.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
if (instance.effectiveAt != null) {
container.encodeDateTime(
'effective_at',
instance.effectiveAt!,
);
}
container.encodeString(
'id',
instance.id,
);
InvoiceOrId.encode(
instance.invoice,
container.nestedSingleValueContainer('invoice').encoder,
);
CreditNoteLines.encode(
instance.lines,
container.nestedSingleValueContainer('lines').encoder,
);
container.encodeBool(
'livemode',
instance.livemode,
);
if (instance.memo != null) {
container.encodeString(
'memo',
instance.memo!,
);
}
if (instance.metadata != null) {
container.encodeMap(
'metadata',
(container) => instance.metadata!.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
}
container.encodeString(
'number',
instance.number,
);
container.encodeString(
'object',
'credit_note',
);
if (instance.outOfBandAmount != null) {
container.encodeInt(
'out_of_band_amount',
instance.outOfBandAmount!,
);
}
container.encodeString(
'pdf',
instance.pdf,
);
if (instance.reason != null) {
container.encodeString(
'reason',
instance.reason!,
);
}
if (instance.refund != null) {
RefundOrId.encode(
instance.refund!,
container.nestedSingleValueContainer('refund').encoder,
);
}
if (instance.shippingCost != null) {
CheckoutSessionShippingCost.encode(
instance.shippingCost!,
container.nestedSingleValueContainer('shipping_cost').encoder,
);
}
container.encodeString(
'status',
instance.status,
);
container.encodeInt(
'subtotal',
instance.subtotal,
);
if (instance.subtotalExcludingTax != null) {
container.encodeInt(
'subtotal_excluding_tax',
instance.subtotalExcludingTax!,
);
}
container.encodeList(
'tax_amounts',
(container) =>
instance.taxAmounts.forEach((el) => CreditNoteTaxAmount.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
container.encodeInt(
'total',
instance.total,
);
if (instance.totalExcludingTax != null) {
container.encodeInt(
'total_excluding_tax',
instance.totalExcludingTax!,
);
}
container.encodeString(
'type',
instance.type,
);
if (instance.voidedAt != null) {
container.encodeDateTime(
'voided_at',
instance.voidedAt!,
);
}
return container.value;
}