From 35767fe675e5fe7bef1c9e9dd23dcb95a2e49aaa Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 7 Apr 2021 15:16:33 +0300 Subject: [PATCH] profile http api updates --- .../src/lib/api/userController.service.ts | 62 +++++++++++++++++-- libs/red-ui-http/src/lib/model/models.ts | 1 + .../src/lib/model/updateMyProfileRequest.ts | 26 ++++++++ .../src/lib/model/updateProfileRequest.ts | 4 ++ 4 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 libs/red-ui-http/src/lib/model/updateMyProfileRequest.ts diff --git a/libs/red-ui-http/src/lib/api/userController.service.ts b/libs/red-ui-http/src/lib/api/userController.service.ts index d4ce37155..ddbde3e1b 100644 --- a/libs/red-ui-http/src/lib/api/userController.service.ts +++ b/libs/red-ui-http/src/lib/api/userController.service.ts @@ -24,6 +24,7 @@ import { UserSearchResponse } from '../model/userSearchResponse'; import { BASE_PATH } from '../variables'; import { Configuration } from '../configuration'; +import { UpdateMyProfileRequest } from '../model/updateMyProfileRequest'; @Injectable() export class UserControllerService { @@ -379,10 +380,10 @@ export class UserControllerService { * @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 updateProfile(body: UpdateProfileRequest, observe?: 'body', reportProgress?: boolean): Observable; - public updateProfile(body: UpdateProfileRequest, observe?: 'response', reportProgress?: boolean): Observable>; - public updateProfile(body: UpdateProfileRequest, observe?: 'events', reportProgress?: boolean): Observable>; - public updateProfile(body: UpdateProfileRequest, observe: any = 'body', reportProgress: boolean = false): Observable { + public updateMyProfile(body: UpdateMyProfileRequest, observe?: 'body', reportProgress?: boolean): Observable; + public updateMyProfile(body: UpdateMyProfileRequest, observe?: 'response', reportProgress?: boolean): Observable>; + public updateMyProfile(body: UpdateMyProfileRequest, observe?: 'events', reportProgress?: boolean): Observable>; + public updateMyProfile(body: UpdateMyProfileRequest, observe: any = 'body', reportProgress: boolean = false): Observable { if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling updateProfile.'); } @@ -409,7 +410,58 @@ export class UserControllerService { headers = headers.set('Content-Type', httpContentTypeSelected); } - return this.httpClient.request('post', `${this.basePath}/user/profile`, { + return this.httpClient.request('post', `${this.basePath}/user/my-profile`, { + body: body, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } + + /** + * Update a users profile. Invoked by admin. + * None + * @param body updateProfileRequest + * @param userId userId + * @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 updateProfile(body: UpdateProfileRequest, userId: string, observe?: 'body', reportProgress?: boolean): Observable; + public updateProfile(body: UpdateProfileRequest, userId: string, observe?: 'response', reportProgress?: boolean): Observable>; + public updateProfile(body: UpdateProfileRequest, userId: string, observe?: 'events', reportProgress?: boolean): Observable>; + public updateProfile(body: UpdateProfileRequest, userId: string, observe: any = 'body', reportProgress: boolean = false): Observable { + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updateProfile1.'); + } + + if (userId === null || userId === undefined) { + throw new Error('Required parameter userId was null or undefined when calling updateProfile1.'); + } + + 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}/user/profile/${encodeURIComponent(String(userId))}`, { body: body, withCredentials: this.configuration.withCredentials, headers: headers, diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index cf8fd8aa0..d54a6f14c 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -70,3 +70,4 @@ export * from './sMTPConfigurationModel'; export * from './userSearchRequest'; export * from './userSearchResponse'; export * from './updateProfileRequest'; +export * from './updateMyProfileRequest'; diff --git a/libs/red-ui-http/src/lib/model/updateMyProfileRequest.ts b/libs/red-ui-http/src/lib/model/updateMyProfileRequest.ts new file mode 100644 index 000000000..9a5c499c4 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/updateMyProfileRequest.ts @@ -0,0 +1,26 @@ +/** + * 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 UpdateMyProfileRequest { + /** + * Email of user. + */ + email?: string; + /** + * First name of user. + */ + firstName?: string; + /** + * Last name of user. + */ + lastName?: string; +} diff --git a/libs/red-ui-http/src/lib/model/updateProfileRequest.ts b/libs/red-ui-http/src/lib/model/updateProfileRequest.ts index 7d6e6bd94..284ec1bbd 100644 --- a/libs/red-ui-http/src/lib/model/updateProfileRequest.ts +++ b/libs/red-ui-http/src/lib/model/updateProfileRequest.ts @@ -23,4 +23,8 @@ export interface UpdateProfileRequest { * Last name of user. */ lastName?: string; + /** + * Roles. + */ + roles?: Array; }