2025-02-08 11:52:25 +08:00
|
|
|
import { mainApi } from '../instances';
|
|
|
|
import { serverFetch } from '@/api/createServerInstance';
|
2025-03-11 04:39:18 +08:00
|
|
|
import type { GetMetricParams, ListMetricsParams, UpdateMetricParams } from './interfaces';
|
2025-03-11 03:58:50 +08:00
|
|
|
import type {
|
|
|
|
BusterMetric,
|
|
|
|
BusterMetricData,
|
|
|
|
BusterMetricListItem
|
|
|
|
} from '@/api/asset_interfaces/metric';
|
2025-02-08 11:52:25 +08:00
|
|
|
|
|
|
|
export const getMetric = async ({ id, password }: GetMetricParams) => {
|
|
|
|
return mainApi
|
2025-03-12 07:01:39 +08:00
|
|
|
.get<BusterMetric>(`/metrics/${id}`, {
|
2025-03-19 03:04:21 +08:00
|
|
|
params: { ...(password && { password }) }
|
2025-02-08 11:52:25 +08:00
|
|
|
})
|
|
|
|
.then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getMetric_server = async ({ id, password }: GetMetricParams) => {
|
2025-03-12 07:01:39 +08:00
|
|
|
return await serverFetch<BusterMetric>(`/metrics/${id}`, {
|
|
|
|
params: { ...(password && { password }) }
|
2025-02-08 11:52:25 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2025-03-12 07:01:39 +08:00
|
|
|
export const getMetricData = async ({ id }: { id: string }) => {
|
|
|
|
return mainApi.get<BusterMetricData>(`/metrics/${id}/data`).then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
2025-02-08 11:52:25 +08:00
|
|
|
export const listMetrics = async (params: ListMetricsParams) => {
|
2025-03-12 23:21:54 +08:00
|
|
|
return mainApi.get<BusterMetricListItem[]>('/metrics', { params }).then((res) => res.data);
|
2025-02-08 11:52:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const listMetrics_server = async (params: ListMetricsParams) => {
|
2025-03-12 23:21:54 +08:00
|
|
|
return await serverFetch<BusterMetricListItem[]>('/metrics', { params });
|
2025-02-08 11:52:25 +08:00
|
|
|
};
|
2025-03-11 03:58:50 +08:00
|
|
|
|
2025-03-11 04:39:18 +08:00
|
|
|
export const updateMetric = async (params: UpdateMetricParams) => {
|
2025-03-15 04:04:10 +08:00
|
|
|
return mainApi.put<BusterMetric>(`/metrics/${params.id}`, params).then((res) => res.data);
|
2025-03-11 04:39:18 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const deleteMetrics = async (params: { ids: string[] }) => {
|
2025-03-11 23:38:49 +08:00
|
|
|
return mainApi.delete<null>(`/metrics/delete`, { params }).then((res) => res.data);
|
2025-03-11 04:39:18 +08:00
|
|
|
};
|
|
|
|
|
2025-03-11 23:38:49 +08:00
|
|
|
export const duplicateMetric = async (params: {
|
2025-03-11 04:39:18 +08:00
|
|
|
id: string;
|
|
|
|
message_id: string;
|
|
|
|
share_with_same_people: boolean;
|
|
|
|
}) => {
|
2025-03-19 12:29:46 +08:00
|
|
|
return mainApi.post<BusterMetric>(`/metrics/duplicate`, params).then((res) => res.data);
|
2025-03-11 04:39:18 +08:00
|
|
|
};
|