mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 14:55:44 +00:00
feat(FE-323): create ClosingApiService
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
import { BaseApiService } from '@/services/api/base';
|
||||||
|
import {
|
||||||
|
Closing,
|
||||||
|
ClosingGeneralInformation,
|
||||||
|
ClosingIncomingSapronak,
|
||||||
|
ClosingOutgoingSapronak,
|
||||||
|
} from '@/types/api/closing';
|
||||||
|
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||||
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
|
|
||||||
|
export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||||
|
constructor(basePath: string) {
|
||||||
|
super(basePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAllIncomingSapronakFetcher(
|
||||||
|
endpoint: string
|
||||||
|
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
||||||
|
return await httpClientFetcher<BaseApiResponse<ClosingIncomingSapronak[]>>(
|
||||||
|
endpoint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAllOutgoingSapronakFetcher(
|
||||||
|
endpoint: string
|
||||||
|
): Promise<BaseApiResponse<ClosingOutgoingSapronak[]>> {
|
||||||
|
return await httpClientFetcher<BaseApiResponse<ClosingOutgoingSapronak[]>>(
|
||||||
|
endpoint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getGeneralInfo(id: number) {
|
||||||
|
try {
|
||||||
|
const getGeneralInfoPath = `${this.basePath}/${id}`;
|
||||||
|
const getGeneralInfoRes =
|
||||||
|
await httpClient<BaseApiResponse<ClosingGeneralInformation>>(
|
||||||
|
getGeneralInfoPath
|
||||||
|
);
|
||||||
|
|
||||||
|
return getGeneralInfoRes;
|
||||||
|
} catch (error) {
|
||||||
|
if (
|
||||||
|
axios.isAxiosError<BaseApiResponse<ClosingGeneralInformation>>(error)
|
||||||
|
) {
|
||||||
|
return error.response?.data;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ClosingApi = new ClosingApiService('/closings');
|
||||||
Reference in New Issue
Block a user