package com.sambath.sbc.remote

import com.gdtlib.lib.adapter.BaseListItem
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class MainResponse(
    @Json(name = "code")
    val resultCode: String,
    @Json(name = "message")
    val message: MainMessage,
    @Json(name = "data")
    val data: MainData?
)

@JsonClass(generateAdapter = true)
data class CfMainResponse(
    @Json(name = "code")
    val resultCode: String,
    @Json(name = "message")
    val message: MainMessage,
    @Json(name = "data")
    val data: CfMainData?
)

@JsonClass(generateAdapter = true)
data class MainMessage(
    @Json(name = "code")
    val code: String,

    @Json(name = "descriptions")
    val description: String

)

@JsonClass(generateAdapter = true)
data class CfMainData(
    @Json(name = "userInfo")
    val userInfo: UserInfo,
    @Json(name = "chanel")
    val channel: Channel,
    @Json(name = "lastResult")
    val lastResult: LastResult?
)

@JsonClass(generateAdapter = true)
data class LastResult(
    @Json(name = "_id")
    val id: String,
    @Json(name = "user_id")
    val user_id: String,
    @Json(name = "chanel_id")
    val channelId: String,
    @Json(name = "fight_no")
    val fightNo: String,
    @Json(name = "type_betting")
    val typeBetting: String,
    @Json(name = "date")
    val date: String,
    @Json(name = "no")
    val no: String,
    @Json(name = "color")
    val color: String,
    @Json(name = "cid")
    val cid: String,
    @Json(name = "rid")
    val rid: String,
    @Json(name = "group")
    val group: String
)
@JsonClass(generateAdapter = true)
data class MainData(
    @Json(name = "userInfo")
    val userInfo: UserInfo,
    @Json(name = "chanel")
    val channel: Channel,

//below will clear soon
    @Json(name = "accountBalances")
    val accountBalance: String,
    @Json(name = "newResult")
    val nextNo: String?,
    @Json(name = "currentResult")
    val result: Result?,
    @Json(name = "currentBetting")
    val myBetting: MyBetting?
)

@JsonClass(generateAdapter = true)
data class UserInfo(
    @Json(name = "account_info")
    val accountInfo: String?,
    @Json(name = "account_name")
    val accountName: String?,
    @Json(name = "account_number")
    val accountNumber: Int?,
    @Json(name = "balance")
    val balance: Long,
    @Json(name = "currency_type")
    val currencyType: String,
    @Json(name = "enable")
    val enable: Boolean,
    @Json(name = "role")
    val role: String,
    @Json(name = "user_name")
    val userName: String
)

@JsonClass(generateAdapter = true)
data class Channel(
    @Json(name = "_id")
    val id: String,
    @Json(name = "tem_id")
    val temId: String,
    @Json(name = "name")
    val name: String,
    @Json(name = "status")
    val status: String,
    @Json(name = "info")
    val info: String,
    @Json(name = "date")
    val date: String,
    @Json(name = "type_of_play")
    val typeOfPlay: String,
    @Json(name = "fight_no")
    val fightNo: Int,
    @Json(name = "group")
    val group: Int,
    @Json(name = "amount_red")
    val amountRed: Int,
    @Json(name = "payout_red")
    val payoutRed: Double,
    @Json(name = "cast_red")
    val castRed: Long,
    @Json(name = "amount_equal")
    val amountEqual: Int,
    @Json(name = "payout_equal")
    val payoutEqual: Int,
    @Json(name = "cast_equal")
    val castEqual: Int,
    @Json(name = "amount_blue")
    val amountBlue: Int,
    @Json(name = "payout_blue")
    val payoutBlue: Double,
    @Json(name = "cast_blue")
    val castBlue: Long,
    @Json(name = "weigh_red_blue")
    val weighRedBlue: Int,
    @Json(name = "column")
    val column: Int,
    @Json(name = "fix_column")
    val fixColumn: Int,
    @Json(name = "target")
    val target: Long,
    @Json(name = "amount_min")
    val amountMin: Int,
    @Json(name = "amount_max")
    val amountMax: Int,
) {
    override fun toString(): String {
        return "{_id: ${this.id}, tem_id: ${this.temId}, name: ${this.name}, status: ${this.status}, info: ${this.info}, date: ${this.date}, type_of_play: ${this.typeOfPlay}, fight_no: ${this.fightNo}, " +
                "group: ${this.group}, amount_red: ${this.amountRed}, payout_red: ${this.payoutRed}, cast_red: ${this.castRed}, amount_equal: ${this.amountEqual}, payout_equal: ${this.payoutEqual}, castEqual: ${this.castEqual}, amountBlue: ${this.amountBlue}, " +
                "payout_blue: ${this.payoutBlue}, cast_blue: ${this.castBlue}, weigh_red_blue: ${this.weighRedBlue}, column: ${this.column}, fix_column: ${this.fixColumn}, target: ${this.target}, amount_min: ${this.amountMin}, amount_max: ${this.amountMax}}"
    }
}

@JsonClass(generateAdapter = true)
data class MyBetting(
    @Json(name = "_id")
    var id: String?,

    @Json(name = "tem_id")
    val data: List<ListItem>?
)

@JsonClass(generateAdapter = true)
data class ListItem(
    @Json(name = "_id")
    var id: String,

    @Json(name = "set_result_id")
    var setId: String,

    @Json(name = "type_of_betting")
    val typeOfBetting: String,

    @Json(name = "category")
    val category: String,

    @Json(name = "user_id")
    val user_id: String,

    @Json(name = "date")
    val date: String,

    @Json(name = "amount")
    val amount: String,

    @Json(name = "cast")
    val cast: String,

    @Json(name = "win_lose")
    val win_lose: String?,

    @Json(name = "amount_win")
    val amount_win: String?
) : BaseListItem() {
    override fun getUnique(): String = id

}

@JsonClass(generateAdapter = true)
data class Result(

    @Json(name = "_id")
    var id: String,

    @Json(name = "no")
    var no: String,

    @Json(name = "total_ramdom")
    var totalValue: String,

    @Json(name = "set_result_id")
    var smallBigSetId: String,

    @Json(name = "type_of_betting")
    val resultSmallOrBig: String,

    @Json(name = "category")
    var categorySmallOrBig: String,

    @Json(name = "set_result_id_range")
    var rangeSetId: String,

    @Json(name = "type_of_betting_range")
    val resultRange: String,

    @Json(name = "category_range")
    var categoryRange: String
)

@JsonClass(generateAdapter = true)
data class TodayReportResponse(
    @Json(name = "code")
    val resultCode: String,
    @Json(name = "message")
    val message: MainMessage,
    @Json(name = "data")
    val data: TodayReportData?
)

@JsonClass(generateAdapter = true)
data class TodayReportData(
    @Json(name = "todayReport")
    val todayReportList: List<CfTodayReport>?
)

@JsonClass(generateAdapter = true)
data class CfTodayReport(
    @Json(name = "_id")
    val id: String,
    @Json(name = "fight_no")
    val fightNo: Int?,
    @Json(name = "type_betting")
    val typeBetting: String?,
    @Json(name = "amount")
    val amount: Long?,
    @Json(name = "payout")
    val payout: Double?,
    @Json(name = "cast")
    val cast: String?,
    @Json(name = "result")
    val result: String?,
    @Json(name = "win_lose")
    val winLose: String?,
    @Json(name = "amount_win")
    val amountWin: String?,
    @Json(name = "date")
    val date: String?,
    @Json(name = "updatedAt")
    val updateAt: String?,
): BaseListItem(){
    override fun getUnique(): String = id
}

@JsonClass(generateAdapter = true)
data class CurrentBetsResponse(
    @Json(name = "code")
    val resultCode: String,
    @Json(name = "message")
    val message: MainMessage,
    @Json(name = "data")
    val data: CurrentBetsData?
)

@JsonClass(generateAdapter = true)
data class CurrentBetsData(
    @Json(name = "currenBetting")
    val currentBetsList: List<CfCurrentBets>?
)

@JsonClass(generateAdapter = true)
data class CfCurrentBets(
    @Json(name = "_id")
    val id: String,
    @Json(name = "user_id")
    val userId: String?,
    @Json(name = "fight_no")
    val fightNo: Int?,
    @Json(name = "group")
    val group: Int?,
    @Json(name = "type_betting")
    val typeBetting: String,
    @Json(name = "amount")
    val amount: Long,
    @Json(name = "payout")
    val payout: Double,
    @Json(name = "cast")
    val cast: Long?,
    @Json(name = "win_lose")
    val winLose: Boolean?,
    @Json(name = "amount_win")
    val amountWin: Long?,
    @Json(name = "date")
    val date: String,
    @Json(name = "updatedAt")
    val updateAt: String?,
): BaseListItem(){
    override fun getUnique(): String = id
}

@JsonClass(generateAdapter = true)
data class StatementResponse(
    @Json(name = "code")
    val resultCode: String,
    @Json(name = "message")
    val message: MainMessage,
    @Json(name = "data")
    val data: StatementData?
)

@JsonClass(generateAdapter = true)
data class StatementData(
    @Json(name = "statement")
    val statementList: List<CfStatement>?
)

@JsonClass(generateAdapter = true)
data class CfStatement(
    @Json(name = "_id")
    val id: String,
    @Json(name = "date")
    val date: String?,
    @Json(name = "note")
    val note: String?,
    @Json(name = "note_khmer")
    val noteKhmer: String?,
    @Json(name = "amount")
    val amount: Int?,
    @Json(name = "amount_win")
    val amountWin: Int?,
    @Json(name = "trun_over")
    val trunOver: Int?,
): BaseListItem(){
    override fun getUnique(): String = id
}

@JsonClass(generateAdapter = true)
data class CreateBetResponse(
    @Json(name = "code")
    val resultCode: String,
    @Json(name = "message")
    val message: MainMessage,
    @Json(name = "data")
    val data: CreateBetData?
)

@JsonClass(generateAdapter = true)
data class CreateBetData(
    @Json(name = "account_balances")
    val accountBalances: Double?,
    @Json(name = "chanel")
    val channel: Channel?,
    @Json(name = "print")
    val print: Print?
)

@JsonClass(generateAdapter = true)
class CreateBetting(
    @Json(name = "amount")
    val amount: Int,
    @Json(name = "chicken_id")
    val chickenId: String
)

@JsonClass(generateAdapter = true)
data class Print(
    @Json(name = "fight_no")
    var fightNo: String,
    @Json(name = "date")
    var date: String,
    @Json(name = "user_name")
    var userName: String,
    @Json(name = "type_betting")
    var typeBetting: String,
    @Json(name = "amount")
    var amount: String,
    @Json(name = "payout_rate")
    var payoutRate: String,
    @Json(name = "payout")
    var payout: String,
)

