import { mainApi } from '../instances'; import { serverFetch } from '@/api/createServerInstance'; import type { GetMetricParams, ListMetricsParams, UpdateMetricParams } from './interfaces'; import type { BusterMetric, BusterMetricData, BusterMetricListItem } from '@/api/asset_interfaces/metric'; export const getMetric = async ({ id, password }: GetMetricParams) => { return mainApi .get(`/metrics/get`, { params: { id, ...(password && { password }) } }) .then((res) => res.data); }; export const getMetric_server = async ({ id, password }: GetMetricParams) => { return await serverFetch(`/metrics/get`, { params: { id, ...(password && { password }) } }); }; export const listMetrics = async (params: ListMetricsParams) => { return mainApi.get('/metrics/list', { params }).then((res) => res.data); }; export const listMetrics_server = async (params: ListMetricsParams) => { return await serverFetch('/metrics/list', { params }); }; export const getMetricData = async ({ id }: { id: string }) => { return mainApi.get(`/metrics/${id}/data`).then((res) => res.data); }; export const updateMetric = async (params: UpdateMetricParams) => { return mainApi .put(`/metrics/update/${params.id}`, { params }) .then((res) => res.data); }; export const deleteMetrics = async (params: { ids: string[] }) => { return mainApi.delete(`/metrics/delete`, { params }).then((res) => res.data); }; export const duplicateMetric = async (params: { id: string; message_id: string; share_with_same_people: boolean; }) => { return mainApi.post(`/metrics/duplicate`, { params }).then((res) => res.data); };