//
//  RateTool.swift
//  Toolboxes
//
//  Created by 研发2组 on 2025/12/4.
//

import SwiftUI
import Foundation
import Alamofire

class RateTool:NSObject{
    //检查网络
    static func check(complation: @escaping (Bool) -> ()){
        
        NetworkReachabilityManager.default?.startListening(onUpdatePerforming: { status in
            if status == .reachable(.cellular) || status == .reachable(.ethernetOrWiFi){
                complation(true)
            }
            else {
                complation(false)
            }
        })
    }

  
    static func fetchConfig(complation: @escaping (Bool) -> ()){
        let client = AlamofireClient()
        client.config { config in
            if let appconfig = config , appconfig.isSuccess {
                // 检查pub数组中是否有event为"app_evaluate"且chance为"1"的项
                let hasEvaluate = appconfig.pub.contains { item in
                    item.event == "app_evaluate" && item.chance == "1"
                }
                complation(hasEvaluate)
           
            }
        }
    }
}
