40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import type { PageResponse } from "@/shared/model";
|
|
|
|
import type {
|
|
BusinessSendRequest,
|
|
BusinessSendResponse,
|
|
NtftalkService,
|
|
NtftalkTemplate,
|
|
NtftalkTemplateSearchDto,
|
|
TemplateVariablesResponse,
|
|
} from "../model/ntftalk-interface";
|
|
|
|
const { TEMP, ATA_SEND } = ENDPOINT.NTFTALK_SERVICE;
|
|
|
|
async function findTemplatePage(
|
|
params: NtftalkTemplateSearchDto,
|
|
): Promise<PageResponse<NtftalkTemplate>> {
|
|
const response = await client.get<PageResponse<NtftalkTemplate>>(TEMP, { params });
|
|
return response.data;
|
|
}
|
|
|
|
async function findTemplateVariables(templateCode: string): Promise<TemplateVariablesResponse> {
|
|
const response = await client.get<TemplateVariablesResponse>(
|
|
`${ATA_SEND}/template-variables/${templateCode}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
async function sendBusiness(body: BusinessSendRequest): Promise<BusinessSendResponse> {
|
|
const response = await client.post<BusinessSendResponse>(`${ATA_SEND}/business`, body);
|
|
return response.data;
|
|
}
|
|
|
|
export const ntftalkService = {
|
|
findTemplatePage,
|
|
findTemplateVariables,
|
|
sendBusiness,
|
|
} satisfies NtftalkService;
|