encode<V> static method

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

Implementation

static V encode<V>(
  Source instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.achCreditTransfer != null) {
    SourceTypeAchCreditTransfer.encode(
      instance.achCreditTransfer!,
      container.nestedSingleValueContainer('ach_credit_transfer').encoder,
    );
  }
  if (instance.achDebit != null) {
    SourceTypeAchDebit.encode(
      instance.achDebit!,
      container.nestedSingleValueContainer('ach_debit').encoder,
    );
  }
  if (instance.acssDebit != null) {
    SourceTypeAcssDebit.encode(
      instance.acssDebit!,
      container.nestedSingleValueContainer('acss_debit').encoder,
    );
  }
  if (instance.alipay != null) {
    SourceTypeAlipay.encode(
      instance.alipay!,
      container.nestedSingleValueContainer('alipay').encoder,
    );
  }
  if (instance.amount != null) {
    container.encodeInt(
      'amount',
      instance.amount!,
    );
  }
  if (instance.auBecsDebit != null) {
    SourceTypeAuBecsDebit.encode(
      instance.auBecsDebit!,
      container.nestedSingleValueContainer('au_becs_debit').encoder,
    );
  }
  if (instance.bancontact != null) {
    SourceTypeBancontact.encode(
      instance.bancontact!,
      container.nestedSingleValueContainer('bancontact').encoder,
    );
  }
  if (instance.card != null) {
    SourceTypeCard.encode(
      instance.card!,
      container.nestedSingleValueContainer('card').encoder,
    );
  }
  if (instance.cardPresent != null) {
    SourceTypeCardPresent.encode(
      instance.cardPresent!,
      container.nestedSingleValueContainer('card_present').encoder,
    );
  }
  container.encodeString(
    'client_secret',
    instance.clientSecret,
  );
  if (instance.codeVerification != null) {
    SourceCodeVerificationFlow.encode(
      instance.codeVerification!,
      container.nestedSingleValueContainer('code_verification').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.currency != null) {
    container.encodeString(
      'currency',
      instance.currency!,
    );
  }
  if (instance.customer != null) {
    container.encodeString(
      'customer',
      instance.customer!,
    );
  }
  if (instance.eps != null) {
    SourceTypeEps.encode(
      instance.eps!,
      container.nestedSingleValueContainer('eps').encoder,
    );
  }
  container.encodeString(
    'flow',
    instance.flow,
  );
  if (instance.giropay != null) {
    SourceTypeGiropay.encode(
      instance.giropay!,
      container.nestedSingleValueContainer('giropay').encoder,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.ideal != null) {
    SourceTypeIdeal.encode(
      instance.ideal!,
      container.nestedSingleValueContainer('ideal').encoder,
    );
  }
  if (instance.klarna != null) {
    SourceTypeKlarna.encode(
      instance.klarna!,
      container.nestedSingleValueContainer('klarna').encoder,
    );
  }
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.multibanco != null) {
    SourceTypeMultibanco.encode(
      instance.multibanco!,
      container.nestedSingleValueContainer('multibanco').encoder,
    );
  }
  container.encodeString(
    'object',
    'source',
  );
  if (instance.owner != null) {
    SourceOwner.encode(
      instance.owner!,
      container.nestedSingleValueContainer('owner').encoder,
    );
  }
  if (instance.p24 != null) {
    SourceTypeP24.encode(
      instance.p24!,
      container.nestedSingleValueContainer('p24').encoder,
    );
  }
  if (instance.receiver != null) {
    SourceReceiverFlow.encode(
      instance.receiver!,
      container.nestedSingleValueContainer('receiver').encoder,
    );
  }
  if (instance.redirect != null) {
    SourceRedirectFlow.encode(
      instance.redirect!,
      container.nestedSingleValueContainer('redirect').encoder,
    );
  }
  if (instance.sepaCreditTransfer != null) {
    SourceTypeSepaCreditTransfer.encode(
      instance.sepaCreditTransfer!,
      container.nestedSingleValueContainer('sepa_credit_transfer').encoder,
    );
  }
  if (instance.sepaDebit != null) {
    SourceTypeSepaDebit.encode(
      instance.sepaDebit!,
      container.nestedSingleValueContainer('sepa_debit').encoder,
    );
  }
  if (instance.sofort != null) {
    SourceTypeSofort.encode(
      instance.sofort!,
      container.nestedSingleValueContainer('sofort').encoder,
    );
  }
  if (instance.sourceOrder != null) {
    SourceOrder.encode(
      instance.sourceOrder!,
      container.nestedSingleValueContainer('source_order').encoder,
    );
  }
  if (instance.statementDescriptor != null) {
    container.encodeString(
      'statement_descriptor',
      instance.statementDescriptor!,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  if (instance.threeDSecure != null) {
    SourceTypeThreeDSecure.encode(
      instance.threeDSecure!,
      container.nestedSingleValueContainer('three_d_secure').encoder,
    );
  }
  container.encodeString(
    'type',
    instance.type,
  );
  if (instance.usage != null) {
    container.encodeString(
      'usage',
      instance.usage!,
    );
  }
  if (instance.wechat != null) {
    SourceTypeWechat.encode(
      instance.wechat!,
      container.nestedSingleValueContainer('wechat').encoder,
    );
  }
  return container.value;
}