11111
This commit is contained in:
50
src/api/agentCardKeys.js
Normal file
50
src/api/agentCardKeys.js
Normal file
@@ -0,0 +1,50 @@
|
||||
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),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user