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

export class ArkInfo {
    id: number
    name: string
    label: string
    imgUrl: string
    category: string
    blueprint: string

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

export class ArkItemInfo extends ArkInfo {

    stackSize: number
    itemId: string
    className: string

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

export class ArkDinoInfo extends ArkInfo {
    nameTag: string
    entityId: string

    constructor(id: number, name: string, label: string, imgUrl: string, category: string, nameTag: string, entityId: string, blueprint: string) {
        super(id, name, label, imgUrl, category, blueprint);
        this.nameTag = nameTag;
        this.entityId = entityId;
    }
}

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 function GetDinosApi() {
    return GetDataByPath("/ark/arkDinos", {}, true) as Promise<ResponseData<ArkDinoData>>
}

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<ArkItemInfo>>
}

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

export function updateItemList(item: ArkItemInfo) {
    return PutDataByPath("/ark/arkItem", item, true) as Promise<ResponseData<ArkItemInfo>>
}

export function updateDinoList(dino: ArkDinoInfo) {
    return PutDataByPath("/ark/arkItem", dino, true) as Promise<ResponseData<ArkDinoData>>
}
