From 196b1e3be211585b73382407275de6a0fb5ef6c6 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Thu, 12 Aug 2021 10:24:38 +0300 Subject: [PATCH] Added NotificationA PI --- README.md | 2 +- .../notifications/notifications.component.ts | 3 +- libs/red-ui-http/src/lib/api.module.ts | 4 +- libs/red-ui-http/src/lib/api/api.ts | 6 +- .../lib/api/notificationController.service.ts | 303 ++++++++++++++++++ .../red-ui-http/src/lib/model/notification.ts | 23 ++ .../src/lib/model/notificationResponse.ts | 16 + 7 files changed, 353 insertions(+), 4 deletions(-) create mode 100644 libs/red-ui-http/src/lib/api/notificationController.service.ts create mode 100644 libs/red-ui-http/src/lib/model/notification.ts create mode 100644 libs/red-ui-http/src/lib/model/notificationResponse.ts diff --git a/README.md b/README.md index 49fa5d365..28ce2da2a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ To re-generate http rune swagger YOu need swagger-codegen installed `brew install swagger-codegen` ``` -BASE=https://dev-06.iqser.cloud/ +BASE=https://red-staging.iqser.cloud/ URL="$BASE"redaction-gateway-v1/v2/api-docs?group=redaction-gateway-v1 rm -Rf /tmp/swagger mkdir -p /tmp/swagger diff --git a/apps/red-ui/src/app/components/notifications/notifications.component.ts b/apps/red-ui/src/app/components/notifications/notifications.component.ts index bc00b2827..76f98a1da 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.ts +++ b/apps/red-ui/src/app/components/notifications/notifications.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import * as moment from 'moment'; import { TranslateService } from '@ngx-translate/core'; +import { NotificationControllerService } from '@redaction/red-ui-http'; interface Notification { message: string; @@ -27,7 +28,7 @@ export class NotificationsComponent { ]; groupedNotifications: { dateString: string; notifications: Notification[] }[] = []; - constructor(private _translateService: TranslateService) { + constructor(private _translateService: TranslateService, private _notificationControllerService: NotificationControllerService) { this._groupNotifications(); } diff --git a/libs/red-ui-http/src/lib/api.module.ts b/libs/red-ui-http/src/lib/api.module.ts index 58c8de3fb..8962f8f4a 100644 --- a/libs/red-ui-http/src/lib/api.module.ts +++ b/libs/red-ui-http/src/lib/api.module.ts @@ -29,6 +29,7 @@ import { VersionsControllerService } from './api/versionsController.service'; import { ViewedPagesControllerService } from './api/viewedPagesController.service'; import { WatermarkControllerService } from './api/watermarkController.service'; import { SearchControllerService } from './api/searchController.service'; +import { NotificationControllerService } from './api/notificationController.service'; @NgModule({ imports: [], @@ -61,7 +62,8 @@ import { SearchControllerService } from './api/searchController.service'; VersionsControllerService, ViewedPagesControllerService, WatermarkControllerService, - SearchControllerService + SearchControllerService, + NotificationControllerService ] }) export class ApiModule { diff --git a/libs/red-ui-http/src/lib/api/api.ts b/libs/red-ui-http/src/lib/api/api.ts index c633876c4..976be4cb9 100644 --- a/libs/red-ui-http/src/lib/api/api.ts +++ b/libs/red-ui-http/src/lib/api/api.ts @@ -26,6 +26,7 @@ import { UploadControllerService } from './uploadController.service'; import { GeneralSettingsControllerService } from './generalSettingsController.service'; import { DossierAttributesControllerService } from './dossierAttributesController.service'; import { SearchControllerService } from './searchController.service'; +import { NotificationControllerService } from './notificationController.service'; export * from './auditController.service'; @@ -83,6 +84,8 @@ export * from './dossierAttributesController.service'; export * from './searchController.service'; +export * from './notificationController.service'; + export const APIS = [ AuditControllerService, DebugControllerService, @@ -111,5 +114,6 @@ export const APIS = [ UploadControllerService, GeneralSettingsControllerService, DossierAttributesControllerService, - SearchControllerService + SearchControllerService, + NotificationControllerService ]; diff --git a/libs/red-ui-http/src/lib/api/notificationController.service.ts b/libs/red-ui-http/src/lib/api/notificationController.service.ts new file mode 100644 index 000000000..591f1383a --- /dev/null +++ b/libs/red-ui-http/src/lib/api/notificationController.service.ts @@ -0,0 +1,303 @@ +/** + * API Documentation for Redaction Gateway + * Description for redaction + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ /* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; +import { CustomHttpUrlEncodingCodec } from '../encoder'; + +import { Observable } from 'rxjs'; + +import { NotificationResponse } from '../model/notificationResponse'; + +import { BASE_PATH } from '../variables'; +import { Configuration } from '../configuration'; + +@Injectable() +export class NotificationControllerService { + protected basePath = ''; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + + constructor( + protected httpClient: HttpClient, + @Optional() @Inject(BASE_PATH) basePath: string, + @Optional() configuration: Configuration + ) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + this.basePath = basePath || configuration.basePath || this.basePath; + } + } + + /** + * @param consumes string[] mime-types + * @return true: consumes contains 'multipart/form-data', false: otherwise + */ + private canConsumeForm(consumes: string[]): boolean { + const form = 'multipart/form-data'; + for (const consume of consumes) { + if (form === consume) { + return true; + } + } + return false; + } + + /** + * Delete notifications + * None + * @param body notificationIds + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public deleteNotifications(body: Array, observe?: 'body', reportProgress?: boolean): Observable; + public deleteNotifications(body: Array, observe?: 'response', reportProgress?: boolean): Observable>; + public deleteNotifications(body: Array, observe?: 'events', reportProgress?: boolean): Observable>; + public deleteNotifications(body: Array, observe: any = 'body', reportProgress: boolean = false): Observable { + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling deleteNotifications.'); + } + + let headers = this.defaultHeaders; + + // authentication (RED-OAUTH) required + if (this.configuration.accessToken) { + const accessToken = + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + // to determine the Accept header + const httpHeaderAccepts: string[] = []; + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + // to determine the Content-Type header + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + headers = headers.set('Content-Type', httpContentTypeSelected); + } + + return this.httpClient.request('post', `${this.basePath}/notification/delete`, { + body: body, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } + + /** + * Retrieves notifications for the current user + * None + * @param includeSeen includeSeen + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getNotifications(includeSeen: boolean, observe?: 'body', reportProgress?: boolean): Observable; + public getNotifications( + includeSeen: boolean, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public getNotifications( + includeSeen: boolean, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public getNotifications(includeSeen: boolean, observe: any = 'body', reportProgress: boolean = false): Observable { + if (includeSeen === null || includeSeen === undefined) { + throw new Error('Required parameter includeSeen was null or undefined when calling getNotifications.'); + } + + let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); + if (includeSeen !== undefined && includeSeen !== null) { + queryParameters = queryParameters.set('includeSeen', includeSeen); + } + + let headers = this.defaultHeaders; + + // authentication (RED-OAUTH) required + if (this.configuration.accessToken) { + const accessToken = + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + // to determine the Accept header + const httpHeaderAccepts: string[] = ['application/json']; + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + return this.httpClient.request('get', `${this.basePath}/notification`, { + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } + + /** + * Mark a notifications as read or unread + * None + * @param body notificationIds + * @param setRead setRead + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public toggleNotificationRead(body: Array, setRead: boolean, observe?: 'body', reportProgress?: boolean): Observable; + public toggleNotificationRead( + body: Array, + setRead: boolean, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public toggleNotificationRead( + body: Array, + setRead: boolean, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public toggleNotificationRead( + body: Array, + setRead: boolean, + observe: any = 'body', + reportProgress: boolean = false + ): Observable { + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling toggleNotificationRead.'); + } + + if (setRead === null || setRead === undefined) { + throw new Error('Required parameter setRead was null or undefined when calling toggleNotificationRead.'); + } + + let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); + if (setRead !== undefined && setRead !== null) { + queryParameters = queryParameters.set('setRead', setRead); + } + + let headers = this.defaultHeaders; + + // authentication (RED-OAUTH) required + if (this.configuration.accessToken) { + const accessToken = + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + // to determine the Accept header + const httpHeaderAccepts: string[] = []; + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + // to determine the Content-Type header + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + headers = headers.set('Content-Type', httpContentTypeSelected); + } + + return this.httpClient.request('post', `${this.basePath}/notification/toggle-read`, { + body: body, + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } + + /** + * Mark a notifications as seen or unseen + * None + * @param body notificationIds + * @param setSeen setSeen + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public toggleNotificationSeen(body: Array, setSeen: boolean, observe?: 'body', reportProgress?: boolean): Observable; + public toggleNotificationSeen( + body: Array, + setSeen: boolean, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public toggleNotificationSeen( + body: Array, + setSeen: boolean, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public toggleNotificationSeen( + body: Array, + setSeen: boolean, + observe: any = 'body', + reportProgress: boolean = false + ): Observable { + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling toggleNotificationSeen.'); + } + + if (setSeen === null || setSeen === undefined) { + throw new Error('Required parameter setSeen was null or undefined when calling toggleNotificationSeen.'); + } + + let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); + if (setSeen !== undefined && setSeen !== null) { + queryParameters = queryParameters.set('setSeen', setSeen); + } + + let headers = this.defaultHeaders; + + // authentication (RED-OAUTH) required + if (this.configuration.accessToken) { + const accessToken = + typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + // to determine the Accept header + const httpHeaderAccepts: string[] = []; + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + // to determine the Content-Type header + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + headers = headers.set('Content-Type', httpContentTypeSelected); + } + + return this.httpClient.request('post', `${this.basePath}/notification/toggle-seen`, { + body: body, + params: queryParameters, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } +} diff --git a/libs/red-ui-http/src/lib/model/notification.ts b/libs/red-ui-http/src/lib/model/notification.ts new file mode 100644 index 000000000..db999aeb3 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/notification.ts @@ -0,0 +1,23 @@ +/** + * API Documentation for Redaction Gateway + * Description for redaction + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +export interface Notification { + creationDate?: string; + issuerId?: string; + notificationId?: string; + notificationType?: string; + readDate?: string; + seenDate?: string; + softDeleted?: string; + target?: any; + userId?: string; +} diff --git a/libs/red-ui-http/src/lib/model/notificationResponse.ts b/libs/red-ui-http/src/lib/model/notificationResponse.ts new file mode 100644 index 000000000..ceaa65eb9 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/notificationResponse.ts @@ -0,0 +1,16 @@ +/** + * API Documentation for Redaction Gateway + * Description for redaction + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +import { Notification } from './notification'; + +export interface NotificationResponse { + notifications?: Array; +}