import { NetRequest } from "../../Engine/CatanEngine/NetManagerV2/NetRequest";
import BusinessTypeSetting from "../BusinessTypeSetting";
import Config from "../Config";

// =======================================================================================
/** 通用回傳SERVER創的帳號 */
interface CommonAccountResponse {
    a: string;
    pw: string;
}

// =======================================================================================
interface CreateResquest {
    p: number;
}
/** 直接玩(訪客給SERVER創帳號) */
export class AccountCreateRequest extends NetRequest<CreateResquest, CommonAccountResponse> {
    get Method(): string {
        return "account.create";
    }
    constructor() {
        super();
        this.Data = {
            p: Config.GetRunDevice(),
        };
    }
}
// =======================================================================================
interface LoginResquest {
    p: number;
    device_info: string[];
    fcm_token: string;
    a: string;
    pw: string;
    ver: string;
}
interface LoginResponse {
    pr: string;
    cu: string;
}
/** 通用登入 */
export class AccountLoginRequest extends NetRequest<LoginResquest, LoginResponse> {
    get Method(): string {
        return "account.login";
    }
    constructor(account: string, password: string) {
        super();
        this.Data = {
            p: Config.GetRunDevice(),
            device_info: ["Windows", "Windows"],
            fcm_token: "",
            a: account,
            pw: password,
            ver: BusinessTypeSetting.COMPILE_VERSION
        };
    }
}
// =======================================================================================
interface CustomResquest {
    a: string;
    pw: string;
}
/** 自定帳號榜定 */
export class CustomBindRequest extends NetRequest<CustomResquest, null> {
    get Method(): string {
        return "register.account_bind";
    }
    constructor(account: string, password: string) {
        super();
        this.Data = {
            a: account,
            pw: password,
        };
    }
}
/** 自定帳號登入(回傳SERVER帳號) */
export class CustomLoginRequest extends NetRequest<CustomResquest, CommonAccountResponse> {
    get Method(): string {
        return "register.account_login";
    }
    constructor(account: string, password: string) {
        super();
        this.Data = {
            a: account,
            pw: password,
        };
    }
}
// =======================================================================================
interface FBResquest {
    t: string;
}
/** FB綁定 */
export class FBBindRequest extends NetRequest<FBResquest, null> {
    get Method(): string {
        return "register.fb_bind";
    }
    constructor(token: string) {
        super();
        this.Data = {
            t: token,
        };
    }
}
/** FB登入(回傳SERVER帳號) */
export class FBLoginRequest extends NetRequest<FBResquest, CommonAccountResponse> {
    get Method(): string {
        return "register.fb_login";
    }
    constructor(token: string) {
        super();
        this.Data = {
            t: token,
        };
    }
}
// =======================================================================================
interface GoogleResquest {
    c: string;
}
/** GOOGLE綁定 */
export class GoogleBindRequest extends NetRequest<GoogleResquest, null> {
    get Method(): string {
        return "register.google_bind";
    }
    constructor(token: string) {
        super();
        this.Data = {
            c: token,
        };
    }
}
/** GOOGLE登入(回傳SERVER帳號) */
export class GoogleLoginRequest extends NetRequest<GoogleResquest, CommonAccountResponse> {
    get Method(): string {
        return "register.google_login";
    }
    constructor(token: string) {
        super();
        this.Data = {
            c: token,
        };
    }
}
// =======================================================================================
interface AppleResquest {
    c: string;
}
/** APPEL綁定 */
export class AppleBindRequest extends NetRequest<AppleResquest, null> {
    get Method(): string {
        return "register.apple_bind";
    }
    constructor(token: string) {
        super();
        this.Data = {
            c: token,
        };
    }
}
/** APPLE登入(回傳SERVER帳號) */
export class AppleLoginRequest extends NetRequest<AppleResquest, CommonAccountResponse> {
    get Method(): string {
        return "register.apple_login";
    }
    constructor(token: string) {
        super();
        this.Data = {
            c: token,
        };
    }
}
// =======================================================================================
/** 電話驗證 */
export interface PhoneCodeRequest {
    p: string;
}

export class PhoneGet extends NetRequest<PhoneCodeRequest, string> {
    get Method(): string {
        return "register.phone_code";
    }
    constructor(p: string) {
        super();
        this.Data = {
            p: p
        };
    }
}

export interface PhoneBindRequest {
    c: string;
}

export class PhoneBind extends NetRequest<PhoneBindRequest, string> {
    get Method(): string {
        return "register.phone_bind";
    }
    constructor(c: string) {
        super();
        this.Data = {
            c: c
        };
    }
}

// =======================================================================================
/** 旗標更新 */
export class FlagOpenAdd extends NetRequest<number, string> {
    get Method(): string {
        return "flag.open_add";
    }
    constructor(type: number) {
        super();
        this.Data = type;
    }
}

// ========================================================================================
export interface ForgotInfo {
    a: string;
    p: string;
}

/** 忘記密碼 */
export class ForgotPassword extends NetRequest<ForgotInfo, null> {
    get Method(): string {
        return "register.account_forget";
    }
    constructor(account: string, phone: string) {
        super();
        this.Data = {
            a: account,
            p: phone,
        };
    }
}