encode<V> static method
V
encode<
V>( - SetupIntent instance,
- Encoder<V> encoder
)
override
Implementation
static V encode<V>(
SetupIntent instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
if (instance.application != null) {
ApplicationOrId.encode(
instance.application!,
container.nestedSingleValueContainer('application').encoder,
);
}
if (instance.attachToSelf != null) {
container.encodeBool(
'attach_to_self',
instance.attachToSelf!,
);
}
if (instance.automaticPaymentMethods != null) {
PaymentFlowsAutomaticPaymentMethodsSetupIntent.encode(
instance.automaticPaymentMethods!,
container
.nestedSingleValueContainer('automatic_payment_methods')
.encoder,
);
}
if (instance.cancellationReason != null) {
container.encodeString(
'cancellation_reason',
instance.cancellationReason!,
);
}
if (instance.clientSecret != null) {
container.encodeString(
'client_secret',
instance.clientSecret!,
);
}
container.encodeDateTime(
'created',
instance.created,
);
if (instance.customer != null) {
BankAccountCustomerOrId.encode(
instance.customer!,
container.nestedSingleValueContainer('customer').encoder,
);
}
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
if (instance.flowDirections != null) {
container.encodeList(
'flow_directions',
(container) => instance.flowDirections!
.forEach((el) => SetupAttemptFlowDirectionsItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
container.encodeString(
'id',
instance.id,
);
if (instance.lastSetupError != null) {
ApiErrors.encode(
instance.lastSetupError!,
container.nestedSingleValueContainer('last_setup_error').encoder,
);
}
if (instance.latestAttempt != null) {
SetupAttemptOrId.encode(
instance.latestAttempt!,
container.nestedSingleValueContainer('latest_attempt').encoder,
);
}
container.encodeBool(
'livemode',
instance.livemode,
);
if (instance.mandate != null) {
MandateOrId.encode(
instance.mandate!,
container.nestedSingleValueContainer('mandate').encoder,
);
}
if (instance.metadata != null) {
container.encodeMap(
'metadata',
(container) => instance.metadata!.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
}
if (instance.nextAction != null) {
SetupIntentNextAction.encode(
instance.nextAction!,
container.nestedSingleValueContainer('next_action').encoder,
);
}
container.encodeString(
'object',
'setup_intent',
);
if (instance.onBehalfOf != null) {
AccountOrId.encode(
instance.onBehalfOf!,
container.nestedSingleValueContainer('on_behalf_of').encoder,
);
}
if (instance.paymentMethod != null) {
PaymentMethodOrId.encode(
instance.paymentMethod!,
container.nestedSingleValueContainer('payment_method').encoder,
);
}
if (instance.paymentMethodConfigurationDetails != null) {
PaymentMethodConfigBizPaymentMethodConfigurationDetails.encode(
instance.paymentMethodConfigurationDetails!,
container
.nestedSingleValueContainer('payment_method_configuration_details')
.encoder,
);
}
if (instance.paymentMethodOptions != null) {
SetupIntentPaymentMethodOptions.encode(
instance.paymentMethodOptions!,
container.nestedSingleValueContainer('payment_method_options').encoder,
);
}
container.encodeList(
'payment_method_types',
(container) => instance.paymentMethodTypes
.forEach((el) => container.encodeString(el)),
);
if (instance.singleUseMandate != null) {
MandateOrId.encode(
instance.singleUseMandate!,
container.nestedSingleValueContainer('single_use_mandate').encoder,
);
}
container.encodeString(
'status',
instance.status,
);
container.encodeString(
'usage',
instance.usage,
);
return container.value;
}