encode<V> static method

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

Implementation

static V encode<V>(
  TreasuryReceivedCredit 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,
  );
  TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails
      .encode(
    instance.initiatingPaymentMethodDetails,
    container
        .nestedSingleValueContainer('initiating_payment_method_details')
        .encoder,
  );
  TreasuryReceivedCreditsResourceLinkedFlows.encode(
    instance.linkedFlows,
    container.nestedSingleValueContainer('linked_flows').encoder,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'network',
    instance.network,
  );
  container.encodeString(
    'object',
    'treasury.received_credit',
  );
  if (instance.reversalDetails != null) {
    TreasuryReceivedCreditReversalDetails.encode(
      instance.reversalDetails!,
      container.nestedSingleValueContainer('reversal_details').encoder,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  if (instance.transaction != null) {
    TreasuryTransactionOrId.encode(
      instance.transaction!,
      container.nestedSingleValueContainer('transaction').encoder,
    );
  }
  return container.value;
}