import { NotificationResponse } from '@/models/api/NotificationResponse' import { NotificationsFilter } from '@/models/Filters' import { Notification } from '@/models/Notification' import { NotificationCreate } from '@/models/NotificationCreate' import { NotificationUpdate } from '@/models/NotificationUpdate' import { mapper } from '@/services/Mapper' import { WorkspaceApi } from '@/services/WorkspaceApi' export class WorkspaceNotificationsApi extends WorkspaceApi { protected override routePrefix = '/flow_run_notification_policies' public async getNotification(notificationId: string): Promise { const { data } = await this.get(`/${notificationId}`) return mapper.map('NotificationResponse', data, 'Notification') } public async createNotification(notification: NotificationCreate): Promise { const { data } = await this.post('/', mapper.map('NotificationCreate', notification, 'NotificationCreateRequest')) return mapper.map('NotificationResponse', data, 'Notification') } public async getNotifications(filter: NotificationsFilter = {}): Promise { const request = mapper.map('NotificationsFilter', filter, 'NotificationsFilterRequest') const { data } = await this.post('/filter', request) return mapper.map('NotificationResponse', data, 'Notification') } public updateNotification(notificationId: string, notification: NotificationUpdate): Promise { return this.patch(`/${notificationId}`, mapper.map('NotificationUpdate', notification, 'NotificationUpdateRequest')) } public deleteNotification(notificationId: string): Promise { return this.delete(`/${notificationId}`) } }