import {GetDataByPath, PostDataByPath, ResponseData} from "./api";

export class ArkItemInfo {
    id: string
    name: string
    label: string
    imgUrl: string
    category: string
    stackSize: number
    itemId: string
    className: string
    blueprint: string

    constructor(id: string, name: string, label: string, imgUrl: string, category: string, stackSize: number, itemId: string, className: string, blueprint: string) {
        this.id = id;
        this.name = name;
        this.label = label;
        this.imgUrl = imgUrl;
        this.category = category;
        this.stackSize = stackSize;
        this.itemId = itemId;
        this.className = className;
        this.blueprint = blueprint;
    }
}

export class ArkItemData {
    list: ArkItemInfo[]
    total: number
    pageNum: number
    pageSize: number

    constructor(list: ArkItemInfo[], total: number, pageNum: number, pageSize: number) {
        this.list = list;
        this.total = total;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }
}

export function GetItemsApi() {
    return GetDataByPath("/ark/arkItems", {}, true) as Promise<ResponseData<ArkItemData>>
}

export class ReqArkItem {
    pageNum: number
    pageSize: number
    name: string
    category: string
    label: string
    allLike: string

    constructor(pageNum: number, pageSize: number, name: string, category: string, label: string, allLike: string) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.name = name;
        this.category = category;
        this.label = label;
        this.allLike = allLike;
    }
}

export function PostItemList(item: ReqArkItem, pageNum: number, pageSize: number) {
    item.pageNum = pageNum;
    item.pageSize = pageSize;
    return PostDataByPath("/ark/arkItems", item, true) as Promise<ResponseData<ArkItemData>>
}