mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 08:25:43 +00:00
api
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { api as apiClient } from '../auth/http';
|
||||
|
||||
import { URL_CONSTANTS } from '@/constants/URLS';
|
||||
import type {
|
||||
GenerateInterchangeDocumentPayload,
|
||||
InterchangeDocument,
|
||||
InterchangeDocumentFilter,
|
||||
} from '@/types/interchangeDocument';
|
||||
|
||||
const cleanParams = (params: object) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(params).filter(([, value]) => value !== undefined && value !== '' && value !== null),
|
||||
);
|
||||
|
||||
export const interchangeDocumentsService = {
|
||||
list: (filter?: InterchangeDocumentFilter) =>
|
||||
apiClient.get<InterchangeDocument[]>(URL_CONSTANTS.INTERCHANGE_DOCUMENTS.BASE, {
|
||||
params: cleanParams(filter ?? {}),
|
||||
}),
|
||||
getById: (id: string) =>
|
||||
apiClient.get<InterchangeDocument>(URL_CONSTANTS.INTERCHANGE_DOCUMENTS.BY_ID(id)),
|
||||
generateFromSchedule: (payload: GenerateInterchangeDocumentPayload) =>
|
||||
apiClient.post<InterchangeDocument>(
|
||||
URL_CONSTANTS.INTERCHANGE_DOCUMENTS.GENERATE_FROM_SCHEDULE,
|
||||
payload,
|
||||
),
|
||||
acknowledge: (id: string, payload: { acknowledgedBy: string; remarks?: string }) =>
|
||||
apiClient.patch<InterchangeDocument>(URL_CONSTANTS.INTERCHANGE_DOCUMENTS.ACKNOWLEDGE(id), payload),
|
||||
dispute: (id: string, payload: { remarks: string }) =>
|
||||
apiClient.patch<InterchangeDocument>(URL_CONSTANTS.INTERCHANGE_DOCUMENTS.DISPUTE(id), payload),
|
||||
cancel: (id: string) =>
|
||||
apiClient.patch<InterchangeDocument>(URL_CONSTANTS.INTERCHANGE_DOCUMENTS.CANCEL(id), {}),
|
||||
};
|
||||
Reference in New Issue
Block a user