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/${id}`, { params: { ...(password && { password }) } }) .then((res) => res.data); }; export const getMetric_server = async ({ id, password }: GetMetricParams) => { return await serverFetch(`/metrics/${id}`, { params: { ...(password && { password }) } }); }; export const getMetricData = async ({ id }: { id: string }) => { return mainApi.get(`/metrics/${id}/data`).then((res) => res.data); }; export const listMetrics = async (params: ListMetricsParams) => { return mainApi.get('/metrics', { params }).then((res) => res.data); }; export const listMetrics_server = async (params: ListMetricsParams) => { return await serverFetch('/metrics', { params }); }; export const updateMetric = async (params: UpdateMetricParams) => { return mainApi.put(`/metrics/${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); };