"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getItem = exports.searchItem = void 0;
const axios_1 = __importDefault(require("axios"));
/* 注：之前直接把物品名填进去还没事，改完以后就开始抽风，不得不自己写serializer= = */
const axios = axios_1.default.create({
    paramsSerializer: (params) => {
        const paramsArray = [];
        for (const i in params)
            paramsArray.push({ key: i, value: params[i] });
        return paramsArray.map(i => `${i.key}=${encodeURI(i.value)}`).join("&");
    }
});
async function searchItem(item, options = {}, locale = "zh") {
    const result = await axios.request({
        method: "GET",
        baseURL: (locale === "zh") ? "https://cafemaker.wakingsands.com/" : "https://xivapi.com/",
        url: `/search`,
        params: {
            ...options,
            string: item
        }
    });
    return result.data;
}
exports.searchItem = searchItem;
async function getItem(id, locale = "zh") {
    const result = await axios.request({
        method: "GET",
        baseURL: (locale === "zh") ? "https://cafemaker.wakingsands.com/" : "https://xivapi.com/",
        url: `/Item/${id}`
    });
    return result.data;
}
exports.getItem = getItem;
