package com.jiooption.trading.network.models

import com.google.gson.annotations.SerializedName

/**
 * Generic API response wrapper
 */
data class ApiResponse<T>(
    @SerializedName("success") val success: Boolean,
    @SerializedName("message") val message: String? = null,
    @SerializedName("error") val error: String? = null,
    @SerializedName("data") val data: T? = null
)

/**
 * User data from login/register
 */
data class UserData(
    @SerializedName("id") val id: Int,
    @SerializedName("user_id") val userId: String? = null,
    @SerializedName("name") val name: String,
    @SerializedName("email") val email: String,
    @SerializedName("phone") val phone: String? = null,
    @SerializedName("status") val status: String? = null,
    @SerializedName("kyc_status") val kycStatus: String? = null,
    @SerializedName("referral_code") val referralCode: String? = null
)

/**
 * Balance response
 */
data class BalanceResponse(
    @SerializedName("success") val success: Boolean,
    @SerializedName("balance") val balance: Double = 0.0,
    @SerializedName("bonus_balance") val bonusBalance: Double = 0.0,
    @SerializedName("demo_balance") val demoBalance: Double = 10000.0,
    @SerializedName("pending_withdrawals") val pendingWithdrawals: Double = 0.0,
    @SerializedName("total_trades") val totalTrades: Int = 0,
    @SerializedName("total_won") val totalWon: Int = 0,
    @SerializedName("total_lost") val totalLost: Int = 0,
    @SerializedName("error") val error: String? = null
)

/**
 * Trade data
 */
data class TradeData(
    @SerializedName("id") val id: Int? = null,
    @SerializedName("trade_id") val tradeId: String? = null,
    @SerializedName("asset") val asset: String? = null,
    @SerializedName("amount") val amount: Double? = null,
    @SerializedName("direction") val direction: String? = null,
    @SerializedName("duration") val duration: Int? = null,
    @SerializedName("entry_price") val entryPrice: Double? = null,
    @SerializedName("exit_price") val exitPrice: Double? = null,
    @SerializedName("result") val result: String? = null,
    @SerializedName("profit") val profit: Double? = null,
    @SerializedName("payout_percent") val payoutPercent: Double? = null,
    @SerializedName("is_demo") val isDemo: Int? = null,
    @SerializedName("status") val status: String? = null,
    @SerializedName("created_at") val createdAt: String? = null,
    @SerializedName("closed_at") val closedAt: String? = null
)

/**
 * Deposit data
 */
data class DepositData(
    @SerializedName("deposit_id") val depositId: Int? = null,
    @SerializedName("amount") val amount: Double? = null,
    @SerializedName("order_id") val orderId: String? = null,
    @SerializedName("status") val status: String? = null,
    @SerializedName("method") val method: String? = null,
    @SerializedName("created_at") val createdAt: String? = null
)

/**
 * Payment data
 */
data class PaymentData(
    @SerializedName("payment_id") val paymentId: String? = null,
    @SerializedName("amount") val amount: Double? = null,
    @SerializedName("status") val status: String? = null,
    @SerializedName("upi_id") val upiId: String? = null,
    @SerializedName("qr_code") val qrCode: String? = null
)

/**
 * Google Play purchase verification request
 */
data class GooglePlayVerifyRequest(
    @SerializedName("purchaseToken") val purchaseToken: String,
    @SerializedName("productId") val productId: String,
    @SerializedName("orderId") val orderId: String
)

/**
 * Device registration request
 */
data class DeviceRegisterRequest(
    @SerializedName("device_token") val deviceToken: String,
    @SerializedName("device_type") val deviceType: String = "android",
    @SerializedName("device_model") val deviceModel: String? = null,
    @SerializedName("app_version") val appVersion: String? = null,
    @SerializedName("os_version") val osVersion: String? = null
)

/**
 * Device unregistration request
 */
data class DeviceUnregisterRequest(
    @SerializedName("device_token") val deviceToken: String
)

/**
 * Mark notification read request
 */
data class MarkReadRequest(
    @SerializedName("notification_id") val notificationId: Int? = null,
    @SerializedName("mark_all") val markAll: Boolean = false
)

/**
 * App configuration response
 */
data class AppConfigResponse(
    @SerializedName("success") val success: Boolean,
    @SerializedName("app_name") val appName: String? = null,
    @SerializedName("site_url") val siteUrl: String? = null,
    @SerializedName("currency") val currency: CurrencyConfig? = null,
    @SerializedName("trading") val trading: TradingConfig? = null,
    @SerializedName("deposit") val deposit: DepositConfig? = null,
    @SerializedName("features") val features: FeaturesConfig? = null,
    @SerializedName("app_version") val appVersion: AppVersionConfig? = null,
    @SerializedName("maintenance") val maintenance: MaintenanceConfig? = null
)

data class CurrencyConfig(
    @SerializedName("symbol") val symbol: String = "₹",
    @SerializedName("code") val code: String = "INR"
)

data class TradingConfig(
    @SerializedName("min_amount") val minAmount: Double = 10.0,
    @SerializedName("max_amount") val maxAmount: Double = 50000.0,
    @SerializedName("demo_balance") val demoBalance: Double = 10000.0
)

data class DepositConfig(
    @SerializedName("min_amount") val minAmount: Double = 100.0,
    @SerializedName("max_amount") val maxAmount: Double = 100000.0,
    @SerializedName("methods") val methods: List<String> = listOf("google_play", "upi")
)

data class FeaturesConfig(
    @SerializedName("google_play_billing") val googlePlayBilling: Boolean = true,
    @SerializedName("upi_payment") val upiPayment: Boolean = true,
    @SerializedName("biometric_login") val biometricLogin: Boolean = true,
    @SerializedName("push_notifications") val pushNotifications: Boolean = true,
    @SerializedName("demo_trading") val demoTrading: Boolean = true,
    @SerializedName("kyc_required") val kycRequired: Boolean = true
)

data class AppVersionConfig(
    @SerializedName("latest") val latest: String = "1.0.0",
    @SerializedName("min_required") val minRequired: String = "1.0.0",
    @SerializedName("update_url") val updateUrl: String? = null
)

data class MaintenanceConfig(
    @SerializedName("enabled") val enabled: Boolean = false,
    @SerializedName("message") val message: String = ""
)

/**
 * Notifications response
 */
data class NotificationsResponse(
    @SerializedName("success") val success: Boolean,
    @SerializedName("message") val message: String? = null,
    @SerializedName("notifications") val notifications: List<NotificationData> = emptyList(),
    @SerializedName("total") val total: Int = 0,
    @SerializedName("unread") val unread: Int = 0,
    @SerializedName("page") val page: Int = 1,
    @SerializedName("pages") val pages: Int = 1
)

data class NotificationData(
    @SerializedName("id") val id: Int,
    @SerializedName("title") val title: String,
    @SerializedName("body") val body: String,
    @SerializedName("type") val type: String,
    @SerializedName("is_read") val isRead: Int = 0,
    @SerializedName("time_ago") val timeAgo: String? = null,
    @SerializedName("created_at") val createdAt: String? = null
)
