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

export namespace MyCardRequest {

	export interface ListData {
		last: {
			[id: string]: [type: string, productId: string];
		};
		items: {
			[id: string]: [ID: number, price: number];
		};
		ingame: {
			type: string;
			items: [ID: number, ItemCode: string, price: number][];
		};
		point: string[];
		freeMyCard: any[];
		mobile: any[];
		webAtm: any[];
		creditCard: any[];
		telecom: any[];
	}

	/**儲值品項清單  */
	export class MyCardList extends NetRequest<any, ListData> {
		get Method(): string {
			return "my_card.info";
		}
		constructor() {
			super();
		}
	}

	// =======================================================================================
	export interface TxnSend {
		id: number;
		paymentType?: string;
		itemCode?: string;
		/* 道具ID */
		use?: number;
	}
	export type TxnGet = string;

	/** MyCard 創建  */
	export class Txn extends NetRequest<TxnSend, TxnGet> {
		get Method(): string {
			return "my_card.txn";
		}
		constructor(id: number, paymentType: string, itemCode: string, use: number) {
			super();
			this.Data = JSON.parse("{}");
			this.Data["id"] = id;
			if (paymentType !== null) {
				this.Data["paymentType"] = paymentType;
			}
			if (itemCode !== null) {
				this.Data["itemCode"] = itemCode;
			}
			if (use !== 0) {
				this.Data["use"] = use;
			}
		}
	}
	// =======================================================================================
}