encode<V> static method

V encode<V>(
  1. SetupAttempt instance,
  2. Encoder<V> encoder
)
override

Implementation

static V encode<V>(
  SetupAttempt 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!,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.customer != null) {
    BankAccountCustomerOrId.encode(
      instance.customer!,
      container.nestedSingleValueContainer('customer').encoder,
    );
  }
  if (instance.flowDirections != null) {
    container.encodeList(
      'flow_directions',
      (container) => instance.flowDirections!
          .forEach((el) => container.encodeString(el)),
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'object',
    'setup_attempt',
  );
  if (instance.onBehalfOf != null) {
    AccountOrId.encode(
      instance.onBehalfOf!,
      container.nestedSingleValueContainer('on_behalf_of').encoder,
    );
  }
  PaymentMethodOrId.encode(
    instance.paymentMethod,
    container.nestedSingleValueContainer('payment_method').encoder,
  );
  SetupAttemptPaymentMethodDetails.encode(
    instance.paymentMethodDetails,
    container.nestedSingleValueContainer('payment_method_details').encoder,
  );
  if (instance.setupError != null) {
    ApiErrors.encode(
      instance.setupError!,
      container.nestedSingleValueContainer('setup_error').encoder,
    );
  }
  SetupIntentOrId.encode(
    instance.setupIntent,
    container.nestedSingleValueContainer('setup_intent').encoder,
  );
  container.encodeString(
    'status',
    instance.status,
  );
  container.encodeString(
    'usage',
    instance.usage,
  );
  return container.value;
}