import { baseBX24 } from "./base/BX24";
import { getAuth } from "./types/getAuth";

export class Bx24Hook extends baseBX24{
    declare url:string;

    constructor(url:string){
        super();
        this.AUTH_EXPIRES=new Date().getTime()+365*24*60*60*1000;
        this.url=url;
    }

    refreshAuth(cb?: ((params: any) => void) | undefined): void {
        this.logger.log('Dont use refresh auth for Bx24Hook');
        if (cb) cb(this.getAuth());
    }

    refreshAuthAsync(): Promise<getAuth> {
        return new Promise(reject=>{
            this.logger.log('Dont use refresh auth for Bx24Hook');
            reject({
                access_token:'',
                domain:this.url,
                expires_in:0,
                member_id:'',
                refresh_token:''
            });
        });
    }

    runCallback(e: MessageEvent<any>): void {
        this.logger.log('Dont use runCallback for Bx24Hook', e);
    }

    sendMessage(cmd: string, params: any, cb?: ((params: any) => void) | undefined): void {
        this.logger.log('Dont use sendMessage for Bx24Hook', [cmd, params, cb]);
    }
}