import { NetRequestSD } from "@/Engine/CatanEngine/NetManagerV2/NetRequestSD";
import { NetRequest } from "../../Engine/CatanEngine/NetManagerV2/NetRequest";

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

// =======================================================================================
interface CreateResquest {
	p: number;
	d: string;
}
/** 直接玩(訪客給SERVER創帳號) */
export class AccountCreateRequest extends NetRequest<CreateResquest, CommonAccountResponse> {
	get Method(): string {
		return "account.create";
	}
	/*constructor() {
		super();
		this.Data = {
			p: Config.GetRunDevice(),
			d: LocalStorageData.Instance.ComboDeviceID,
		};
	}*/
}
// =======================================================================================
interface LoginRequest {
	// p: number;
	// d: string;
	// fcm_token: string;
	id: number;
	pw: string;
	pl: number;
	// ver: string;
}
interface LoginResponse {
	pr: string;
	cu: string;
}
/** 通用登入 */
export class AccountLoginRequest extends NetRequest<LoginRequest, LoginResponse> {
	get Method(): string {
		return "account.login";
	}
	constructor(account: string, password: string, partner: string) {
		super();
		this.Data = {
			id: +account,
			pw: password,
			pl: 3
		};
		if (partner) {
			this.Data["pn"] = partner;
		}
	}
}
interface SDLoginRequest {
	token: string;
}
export class SDAccountLoginRequest extends NetRequestSD<SDLoginRequest, LoginResponse> {
	get Method(): string {
		return "account.login";
	}
	constructor(token: string) {
		super();
		this.Data = {
			token: token,
		};
	}
}

// =======================================================================================
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<string, CommonAccountResponse> {
	get Method(): string {
		return "register.account_login";
	}
	constructor(account: string) {
		super();
		this.Data = account;
	}
}
// =======================================================================================
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 class PhoneCheck extends NetRequest<PhoneCodeRequest, string> {
	get Method(): string {
		return "register.phone_check";
	}
	constructor(p: string) {
		super();
		this.Data = {
			p: p
		};
	}
}
/** 電話驗證 */
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,
		};
	}
}

export interface ChangePasswordInfo {
	a: string;
	opw: string;
	pw: string;
}

/** 修改密碼 */
export class ChangePassword extends NetRequest<ChangePasswordInfo, null> {
	get Method(): string {
		return "register.account_change";
	}
	constructor(account: string, prePassword: string, password: string) {
		super();
		this.Data = {
			a: account,
			opw: prePassword,
			pw: password
		};
	}
}

// =======================================================================================
export interface LineBindResponse {
	n: string;
}

export class LineBind extends NetRequest<string, LineBindResponse> {
	get Method(): string {
		return "register.line_bind";
	}
	constructor(token: string) {
		super();
		this.Data = token;
	}
}
/** LINE登入(回傳SERVER帳號) */
export class LineLoginRequest extends NetRequest<string, CommonAccountResponse> {
	get Method(): string {
		return "register.line_login";
	}
	constructor(token: string) {
		super();
		this.Data = token;
	}
}
// =======================================================================================