import { NetManager } from "../libs/tw/manager/NetManager";


export class NetPromise {
    private static instance: NetPromise;

    public static get ins(): NetPromise {
        if (!this.instance) {
            this.instance = new NetPromise();
        }
        return this.instance;
    }

    constructor() {}

    /**
     * 查询宠物信息
     */
    getPetInfoKuwo(){
		return new Promise((resolve,reject)=>{
			NetManager.ins.getPetInfoKuwo((success)=>{
				if(!success){
                    reject(success)
				}
				resolve(success)
			},window["CFG"].activityId)
		})
    }

    /**
     * 宠物交互
     * @param petId 
     * @param type 
     */
    petInteractionKuwo(petId,type){
        return new Promise((resolve,reject)=>{
            NetManager.ins.petInteractionKuwo((success)=>{
                if(!success){
                    reject(success)
                }
                resolve(success)
            },petId,type,window["signId"])
        })
    }

    /**
     * 查询签到信息
     * @param signActivityId 
     */
    getSignInfo(signActivityId){
        return new Promise((resolve,reject)=>{
            NetManager.ins.getSignInfo((success)=>{
                if(!success){
                    reject(success)
                }
                resolve(success)
            },signActivityId)
        })
    }

    /**
     * 签到
     * @param signActivityId 
     */
    doSign(signActivityId){
        return new Promise((resolve,reject)=>{
            NetManager.ins.doSign((success)=>{
                if(!success){
                    reject(success)
                }
                resolve(success)
            },signActivityId)
        })
    }

     /**
     * 获取任务
     * @param signActivityId 
     */
    getTaskInfoKuwo(eduSignId,petId){
        return new Promise((resolve,reject)=>{
            NetManager.ins.getTaskInfoKuwo((success)=>{
                if(!success){
                    reject(success)
                }
                resolve(success)
            },eduSignId,petId)
        })
    }
}