51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
import { apiRequest } from "./client.js";
|
|
|
|
/**
|
|
* @param {string} token
|
|
* @param {RequestInit} [options]
|
|
*/
|
|
function agentRequest(token, path, options = {}) {
|
|
return apiRequest(path, {
|
|
...options,
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
...options.headers,
|
|
},
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param {string} token
|
|
* @param {{
|
|
* page?: number,
|
|
* pageSize?: number,
|
|
* status?: string,
|
|
* username?: string,
|
|
* }} [params]
|
|
*/
|
|
export function listAgentCardKeysApi(
|
|
token,
|
|
{ page = 1, pageSize = 20, status = "all", username } = {},
|
|
) {
|
|
const query = new URLSearchParams({
|
|
page: String(page),
|
|
page_size: String(pageSize),
|
|
status,
|
|
});
|
|
const trimmed = username?.trim();
|
|
if (trimmed) query.set("username", trimmed);
|
|
return agentRequest(token, `/agent/card-keys?${query}`);
|
|
}
|
|
|
|
/**
|
|
* @param {string} token
|
|
* @param {number} cardId
|
|
* @param {{ agent_remark?: string | null }} payload
|
|
*/
|
|
export function updateAgentCardKeyApi(token, cardId, payload) {
|
|
return agentRequest(token, `/agent/card-keys/${cardId}`, {
|
|
method: "PATCH",
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|