encode<V> static method

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

Implementation

static V encode<V>(
  Refund instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  if (instance.balanceTransaction != null) {
    BalanceTransactionOrId.encode(
      instance.balanceTransaction!,
      container.nestedSingleValueContainer('balance_transaction').encoder,
    );
  }
  if (instance.charge != null) {
    ChargeOrId.encode(
      instance.charge!,
      container.nestedSingleValueContainer('charge').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.destinationDetails != null) {
    RefundDestinationDetails.encode(
      instance.destinationDetails!,
      container.nestedSingleValueContainer('destination_details').encoder,
    );
  }
  if (instance.failureBalanceTransaction != null) {
    BalanceTransactionOrId.encode(
      instance.failureBalanceTransaction!,
      container
          .nestedSingleValueContainer('failure_balance_transaction')
          .encoder,
    );
  }
  if (instance.failureReason != null) {
    container.encodeString(
      'failure_reason',
      instance.failureReason!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.instructionsEmail != null) {
    container.encodeString(
      'instructions_email',
      instance.instructionsEmail!,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.nextAction != null) {
    RefundNextAction.encode(
      instance.nextAction!,
      container.nestedSingleValueContainer('next_action').encoder,
    );
  }
  container.encodeString(
    'object',
    'refund',
  );
  if (instance.paymentIntent != null) {
    PaymentIntentOrId.encode(
      instance.paymentIntent!,
      container.nestedSingleValueContainer('payment_intent').encoder,
    );
  }
  if (instance.reason != null) {
    container.encodeString(
      'reason',
      instance.reason!,
    );
  }
  if (instance.receiptNumber != null) {
    container.encodeString(
      'receipt_number',
      instance.receiptNumber!,
    );
  }
  if (instance.sourceTransferReversal != null) {
    TransferReversalOrId.encode(
      instance.sourceTransferReversal!,
      container
          .nestedSingleValueContainer('source_transfer_reversal')
          .encoder,
    );
  }
  if (instance.status != null) {
    container.encodeString(
      'status',
      instance.status!,
    );
  }
  if (instance.transferReversal != null) {
    TransferReversalOrId.encode(
      instance.transferReversal!,
      container.nestedSingleValueContainer('transfer_reversal').encoder,
    );
  }
  return container.value;
}