feat: add Telegram notification settings UI
This commit is contained in:
70
apps/web-antd/src/api/core/telegram.ts
Normal file
70
apps/web-antd/src/api/core/telegram.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace TelegramApi {
|
||||
export interface NotificationConfig {
|
||||
id: number;
|
||||
name: string;
|
||||
botToken: string;
|
||||
chatId: string;
|
||||
notificationTypes: string[];
|
||||
isEnabled: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface CreateNotificationConfigParams {
|
||||
name: string;
|
||||
botToken: string;
|
||||
chatId: string;
|
||||
notificationTypes?: string[];
|
||||
isEnabled?: boolean;
|
||||
}
|
||||
|
||||
export interface UpdateNotificationConfigParams {
|
||||
name?: string;
|
||||
botToken?: string;
|
||||
chatId?: string;
|
||||
notificationTypes?: string[];
|
||||
isEnabled?: boolean;
|
||||
}
|
||||
|
||||
export interface TestNotificationConfigParams {
|
||||
botToken: string;
|
||||
chatId: string;
|
||||
}
|
||||
}
|
||||
|
||||
export function getTelegramNotificationConfigs() {
|
||||
return requestClient.get<TelegramApi.NotificationConfig[]>(
|
||||
'/telegram/notifications',
|
||||
);
|
||||
}
|
||||
|
||||
export function createTelegramNotificationConfig(
|
||||
data: TelegramApi.CreateNotificationConfigParams,
|
||||
) {
|
||||
return requestClient.post<TelegramApi.NotificationConfig>(
|
||||
'/telegram/notifications',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export function updateTelegramNotificationConfig(
|
||||
id: number,
|
||||
data: TelegramApi.UpdateNotificationConfigParams,
|
||||
) {
|
||||
return requestClient.put<TelegramApi.NotificationConfig>(
|
||||
`/telegram/notifications/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteTelegramNotificationConfig(id: number) {
|
||||
return requestClient.delete<{ id: number }>(`/telegram/notifications/${id}`);
|
||||
}
|
||||
|
||||
export function testTelegramNotificationConfig(
|
||||
data: TelegramApi.TestNotificationConfigParams,
|
||||
) {
|
||||
return requestClient.post<{ message: string }>('/telegram/test', data);
|
||||
}
|
||||
Reference in New Issue
Block a user