Files
18xchat/assets/Scripts/chat18x/payment/PaymentApi.ts
T

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-08-19 18:32:09 +08:00
/**
* 和服务器交互的API接口
*
*/
import { ApiClient } from "../network/client/ApiClient";
import type { Endpoint } from "../network/client/endpoints";
import type { ApiResponse } from "../network/client/types";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
export class PaymentApi {
private static _I: PaymentApi | null = null;
static get I() { return this._I ?? (this._I = new PaymentApi()); }
private constructor(private api = ApiClient.I) {}
// 下单
2025-08-26 16:41:28 +08:00
createOrder(req: proto.cs.ICSCreateOrderReq): Promise<ApiResponse<proto.cs.ICSCreateOrderRes>> {
let epData: Endpoint<proto.cs.ICSCreateOrderReq, proto.cs.ICSCreateOrderRes> = {
path: "api/logic/createOrder",
2025-08-19 18:32:09 +08:00
method: "POST",
codec: "json",
needsAuth: true,
};
return this.api.call(epData, req);
}
// 查询订单
2025-08-26 16:41:28 +08:00
queryOrder(req: proto.cs.ICSQueryOrderReq): Promise<ApiResponse<proto.cs.ICSQueryOrderRes>> {
let epData: Endpoint<proto.cs.ICSQueryOrderReq, proto.cs.ICSQueryOrderRes> = {
path: "api/logic/queryOrder",
2025-08-19 18:32:09 +08:00
method: "POST",
codec: "json",
needsAuth: true,
};
2025-08-26 16:41:28 +08:00
return this.api.call(epData, req);
2025-08-19 18:32:09 +08:00
}
}