48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import {
|
|
upCodeFormSchema,
|
|
type UpCodeService,
|
|
type UpCodeList,
|
|
type UpCodeDetail,
|
|
type UpCodeParams,
|
|
type UpCodeFormData,
|
|
} from "../model/upcode-interface";
|
|
|
|
export class UpCodeApiService implements UpCodeService {
|
|
public async getUpCodeList(params?: UpCodeParams): Promise<UpCodeList> {
|
|
const response = await client.get<UpCodeList>(
|
|
`${ENDPOINT.CMS_SERVICE.UP_CODE}`,
|
|
{ params },
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async upCodeDetail(upCd: string): Promise<UpCodeDetail> {
|
|
const response = await client.get<UpCodeDetail>(
|
|
`${ENDPOINT.CMS_SERVICE.UP_CODE}/${upCd}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async createUpCode(data: UpCodeFormData): Promise<void> {
|
|
const validatedData = upCodeFormSchema.parse(data);
|
|
const response = await client.post<void>(
|
|
`${ENDPOINT.CMS_SERVICE.UP_CODE}`,
|
|
validatedData,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async updateUpCode(upCd: string, data: UpCodeFormData): Promise<void> {
|
|
const validatedData = upCodeFormSchema.parse(data);
|
|
const response = await client.put<void>(
|
|
`${ENDPOINT.CMS_SERVICE.UP_CODE}/${upCd}`,
|
|
validatedData,
|
|
);
|
|
return response.data;
|
|
}
|
|
}
|
|
|
|
export const UpCodeApi = new UpCodeApiService();
|