encode<V> static method
Implementation
static V encode<V>(
PromotionCodeCreateOptions instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
if (instance.active != null) {
container.encodeBool(
'active',
instance.active!,
);
}
if (instance.code != null) {
container.encodeString(
'code',
instance.code!,
);
}
container.encodeString(
'coupon',
instance.coupon,
);
if (instance.customer != null) {
container.encodeString(
'customer',
instance.customer!,
);
}
if (instance.expand != null) {
container.encodeList(
'expand',
(container) =>
instance.expand!.forEach((el) => container.encodeString(el)),
);
}
if (instance.expiresAt != null) {
container.encodeDateTime(
'expires_at',
instance.expiresAt!,
);
}
if (instance.maxRedemptions != null) {
container.encodeInt(
'max_redemptions',
instance.maxRedemptions!,
);
}
if (instance.metadata != null) {
container.encodeMap(
'metadata',
(container) => instance.metadata!.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
}
if (instance.restrictions != null) {
PromotionCodeRestrictions.encode(
instance.restrictions!,
container.nestedSingleValueContainer('restrictions').encoder,
);
}
return container.value;
}