encode<V> static method

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

Implementation

static V encode<V>(
  TreasuryReceivedDebit instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  container.encodeString(
    'description',
    instance.description,
  );
  if (instance.failureCode != null) {
    container.encodeString(
      'failure_code',
      instance.failureCode!,
    );
  }
  if (instance.financialAccount != null) {
    container.encodeString(
      'financial_account',
      instance.financialAccount!,
    );
  }
  if (instance.hostedRegulatoryReceiptUrl != null) {
    container.encodeString(
      'hosted_regulatory_receipt_url',
      instance.hostedRegulatoryReceiptUrl!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.initiatingPaymentMethodDetails != null) {
    TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails
        .encode(
      instance.initiatingPaymentMethodDetails!,
      container
          .nestedSingleValueContainer('initiating_payment_method_details')
          .encoder,
    );
  }
  TreasuryReceivedDebitsResourceLinkedFlows.encode(
    instance.linkedFlows,
    container.nestedSingleValueContainer('linked_flows').encoder,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'network',
    instance.network,
  );
  container.encodeString(
    'object',
    'treasury.received_debit',
  );
  if (instance.reversalDetails != null) {
    TreasuryReceivedCreditReversalDetails.encode(
      instance.reversalDetails!,
      container.nestedSingleValueContainer('reversal_details').encoder,
    );
  }
  TreasuryReceivedCreditStatus.encode(
    instance.status,
    container.nestedSingleValueContainer('status').encoder,
  );
  if (instance.transaction != null) {
    TreasuryTransactionOrId.encode(
      instance.transaction!,
      container.nestedSingleValueContainer('transaction').encoder,
    );
  }
  return container.value;
}