import Foundation

struct ProductionReleaseStatus: Decodable {
    struct Compatibility: Decodable {
        let update_available: Bool?
        let force_update: Bool?
    }
    struct Stores: Decodable { let app_store: String? }
    let launch_status: String
    let rollout_percent: Int
    let compatibility: Compatibility
    let stores: Stores
}

extension APIClient {
    func productionReleaseStatus(currentVersion: String) async throws -> ProductionReleaseStatus {
        let (data, _) = try await request(path: "/mobile/release-status?platform=ios&version=\(currentVersion)")
        struct Envelope<T: Decodable>: Decodable { let data: T }
        return try JSONDecoder().decode(Envelope<ProductionReleaseStatus>.self, from: data).data
    }
}
