Files
TeyvatGuide/src/web/request/getGachaLog.ts
2024-07-02 23:08:54 +08:00

40 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file web/request/getGachaLog.ts
* @description 获取抽卡记录请求函数
* @since Beta v0.5.0
*/
import TGHttp from "../../utils/TGHttp.js";
/**
* @description 获取抽卡记录
* @since Beta v0.5.0
* @param {string} authkey authkey
* @param {string} gachaType 抽卡类型
* @param {string} endId 结束 id默认为 0
* @returns {Promise<TGApp.Game.Gacha.GachaItem[] | TGApp.BBS.Response.Base>} 抽卡记录
*/
export async function getGachaLog(
authkey: string,
gachaType: string,
endId: string = "0",
): Promise<TGApp.Game.Gacha.GachaItem[] | TGApp.BBS.Response.Base> {
const url = "https://public-operation-hk4e.mihoyo.com/gacha_info/api/getGachaLog";
const params = {
lang: "zh-cn",
auth_appid: "webview_gacha",
authkey,
authkey_ver: "1",
sign_type: "2",
gacha_type: gachaType,
size: "20",
end_id: endId,
};
const resp = await TGHttp<TGApp.Game.Gacha.GachaLogResponse | TGApp.BBS.Response.Base>(url, {
method: "GET",
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data.list;
}