Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@

package com.example.zarinpal.data.remote.dto.reverse

import com.example.zarinpal.data.remote.dto.Config
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents the request data required to reverse a payment.
* Data model for a payment reversal request.
*
* @property merchantId The unique identifier for the merchant (nullable).
* @property sandBox Indicates if the payment reversal should be processed in sandbox mode (test mode).
* @property authority The authorization code for the payment reversal (required).
* @property merchantId Optional merchant ID. If not provided, a default can be applied.
* @property sandBox Optional flag for sandbox mode (test environment).
* @property authority Required authorization code associated with the original payment.
*/
@Serializable
data class PaymentReverseRequest(
@SerialName("merchant_id")
val merchantId: String?=null,
val sandBox :Boolean?=null,
val authority :String,
){
val merchantId: String? = null,
val sandBox: Boolean? = null,
val authority: String
) {
/**
* Creates a copy of the request with the merchantId and sandBox values
* replaced by the ones from the provided [Config] if they are null.
* Creates a copy of the current instance, substituting null values for [merchantId]
* and [sandBox] with the corresponding values from the provided [config].
*
* @param config The [Config] object that provides default values for merchantId and sandBox.
* @return A new instance of [PaymentReverseRequest] with updated values.
* @param config Configuration containing default values.
* @return A new [PaymentReverseRequest] instance with updated fields.
*/
fun copyWithConfig(config: Config): PaymentReverseRequest {
return this.copy(
merchantId = this.merchantId ?: config.merchantId,
sandBox = this.sandBox ?: config.sandBox
)
}
fun copyWithConfig(config: Config): PaymentReverseRequest = copy(
merchantId = merchantId ?: config.merchantId,
sandBox = sandBox ?: config.sandBox
)
}