forked from EstrellaXD/Auto_Bangumi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.ts
More file actions
53 lines (47 loc) · 1.15 KB
/
notification.ts
File metadata and controls
53 lines (47 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import type { NotificationProviderConfig, NotificationType } from '#/config';
import type { TupleToUnion } from '#/utils';
export interface TestProviderRequest {
provider_index: number;
}
export interface TestProviderConfigRequest {
type: TupleToUnion<NotificationType>;
enabled?: boolean;
token?: string;
chat_id?: string;
webhook_url?: string;
server_url?: string;
device_key?: string;
user_key?: string;
api_token?: string;
template?: string;
url?: string;
message_type?: string;
}
export interface TestResponse {
success: boolean;
message: string;
message_zh: string;
message_en: string;
}
export const apiNotification = {
/**
* Test a configured provider by index
*/
async testProvider(request: TestProviderRequest) {
const { data } = await axios.post<TestResponse>(
'api/v1/notification/test',
request
);
return { data };
},
/**
* Test an unsaved provider configuration
*/
async testProviderConfig(request: TestProviderConfigRequest) {
const { data } = await axios.post<TestResponse>(
'api/v1/notification/test-config',
request
);
return { data };
},
};