forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-service.ts
More file actions
41 lines (37 loc) · 1.1 KB
/
Copy pathuser-service.ts
File metadata and controls
41 lines (37 loc) · 1.1 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
import { apiClient, extractApiErrorMessage } from '@/lib/api-client';
export interface UpdateNotificationPreferences {
pushNotificationsEnabled: boolean;
}
export interface UpdatePreferencesResponse {
success: boolean;
}
export const UserService = {
/**
* Update the authenticated user's notification preferences.
* Backed by PATCH /users/preferences.
*/
async updateNotificationPreferences(
dto: UpdateNotificationPreferences,
): Promise<UpdatePreferencesResponse> {
try {
const response = await apiClient.patch<UpdatePreferencesResponse>(
'/users/preferences',
dto,
);
return response.data;
} catch (error) {
throw new Error(extractApiErrorMessage(error));
}
},
/** Load the authenticated user's notification preferences. */
async getNotificationPreferences(): Promise<UpdateNotificationPreferences> {
try {
const response = await apiClient.get<UpdateNotificationPreferences>(
'/users/preferences',
);
return response.data;
} catch (error) {
throw new Error(extractApiErrorMessage(error));
}
},
};