63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
import { apiRequest } from "./client.js";
|
|
|
|
/**
|
|
* @param {string} token
|
|
* @param {RequestInit} [options]
|
|
*/
|
|
function oemRequest(token, path, options = {}) {
|
|
return apiRequest(path, {
|
|
...options,
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
...options.headers,
|
|
},
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param {string} token
|
|
* @param {{ page?: number, pageSize?: number, keyword?: string }} [params]
|
|
*/
|
|
export function listOemDesktopConfigsApi(
|
|
token,
|
|
{ page = 1, pageSize = 20, keyword = "" } = {},
|
|
) {
|
|
const query = new URLSearchParams({
|
|
page: String(page),
|
|
page_size: String(pageSize),
|
|
});
|
|
const kw = keyword?.trim();
|
|
if (kw) query.set("keyword", kw);
|
|
return oemRequest(token, `/oem/desktop-configs?${query}`);
|
|
}
|
|
|
|
/**
|
|
* @param {string} token
|
|
* @param {object} payload
|
|
*/
|
|
export function createOemDesktopConfigApi(token, payload) {
|
|
return oemRequest(token, "/oem/desktop-configs", {
|
|
method: "POST",
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param {string} token
|
|
* @param {number} configId
|
|
* @param {object} payload
|
|
*/
|
|
export function updateOemDesktopConfigApi(token, configId, payload) {
|
|
return oemRequest(token, `/oem/desktop-configs/${configId}`, {
|
|
method: "PATCH",
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|
|
|
|
/** @param {string} token @param {number} configId */
|
|
export function deleteOemDesktopConfigApi(token, configId) {
|
|
return oemRequest(token, `/oem/desktop-configs/${configId}`, {
|
|
method: "DELETE",
|
|
});
|
|
}
|