package com.isidroid.network.response

import com.google.gson.annotations.SerializedName

data class ApiResponse<T>(
    @SerializedName("data") var data: T? = null,
    @SerializedName("statistics") var statistics: Statistics? = null,
    @SerializedName("total") var total: Int? = null,
    @SerializedName("error") var error: ErrorResponse? = null,
    @SerializedName("meta") var meta: Pager? = null
) {
    val hasMore
        get() = (meta?.currentPage ?: 0) < (meta?.maxPage ?: 0)

    data class Statistics(@SerializedName("count_new_appointment") var newAppointment: Int? = null)

    data class ErrorResponse(
        @SerializedName("code") val code: String,
        @SerializedName("message") val message: String
    )

    data class Pager(
        @SerializedName("current_page") var currentPage: Int = 0,
        @SerializedName("last_page") var maxPage: Int = 0,
        @SerializedName("per_page") var currentPerPage: Int = 0,
        @SerializedName("total") var total: Int = 0
    )
}
