I have a class structure like below:
abstract class AuthorizeSalesRequestDto {
open val sequenceNumber: Int = 0
open val currentService: String = ""
open val amount: Int = 0
open val taxOthers: Int = 0
open val trainingMode: Boolean = false
}
data class CreditAuthorizeSales(
override val currentService: String = "Credit"
) : AuthorizeSalesRequestDto() {
}
data class UnionPayAuthorizeSales(
override val currentService: String = "UnionPay"
) : AuthorizeSalesRequestDto() {
}
I want to init the CreditAuthorizeSales and UnionPayAuthorizeSales like below:
val creditObject = CreditPayment(
sequenceNumber = 1,
amount = 100,
taxOthers = 10,
trainingMode = true
)
I create class structure because future will be more data class like CreditAuthorizeSales for different service. But I can't figure out a way to make a constructor like above. Can somebody please help me with the syntax or change the class structure? Thanks in advace!!!
Note: Enviroment
- Kotlin v1.4.3