From 4e5fdfe309166fd066536c79d41c0a3daf8d2497 Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 4 Mar 2024 08:57:59 +0100 Subject: [PATCH] feat: return additional information in the profile reduced --- package.json | 2 +- .../dto/get-user-profile-restricted.dto.ts | 12 +++++++++++- src/user-profiles/user-profile.controller.spec.ts | 6 +++++- src/user-profiles/user-profile.controller.ts | 6 +++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 868f25b..4520b3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "marketplace_api", - "version": "0.8.1", + "version": "0.8.2", "description": "The API allowing to manage Nevermined Marketplace common functionalities", "main": "main.ts", "scripts": { diff --git a/src/user-profiles/dto/get-user-profile-restricted.dto.ts b/src/user-profiles/dto/get-user-profile-restricted.dto.ts index cfa6bf4..274ecd1 100644 --- a/src/user-profiles/dto/get-user-profile-restricted.dto.ts +++ b/src/user-profiles/dto/get-user-profile-restricted.dto.ts @@ -1,5 +1,7 @@ import { ApiProperty } from '@nestjs/swagger' -import { IsString } from 'class-validator' +import { IsString, ValidateNested } from 'class-validator' +import { AdditionalInformation } from './additional-information.dto' +import { Type } from 'class-transformer' export class RestrictedUserProfileDto { @ApiProperty({ @@ -15,4 +17,12 @@ export class RestrictedUserProfileDto { }) @IsString() nickname: string + + @ApiProperty({ + example: AdditionalInformation, + description: 'List of additional key-value attributes with additional information', + }) + @ValidateNested() + @Type(() => AdditionalInformation) + additionalInformation: AdditionalInformation } diff --git a/src/user-profiles/user-profile.controller.spec.ts b/src/user-profiles/user-profile.controller.spec.ts index 5b22b7c..d5dfda7 100644 --- a/src/user-profiles/user-profile.controller.spec.ts +++ b/src/user-profiles/user-profile.controller.spec.ts @@ -116,7 +116,11 @@ describe('UserProfileController', () => { expect( await userProfileController.getUserProfileByAddress(userProfile.addresses[0]), - ).toStrictEqual({ userId: userProfile.userId, nickname: userProfile.nickname }) + ).toStrictEqual({ + userId: userProfile.userId, + nickname: userProfile.nickname, + additionalInformation: userProfile.additionalInformation, + }) }) it('should thorw error when no user profile is found by the address given', async () => { diff --git a/src/user-profiles/user-profile.controller.ts b/src/user-profiles/user-profile.controller.ts index afd0d26..b3f7446 100644 --- a/src/user-profiles/user-profile.controller.ts +++ b/src/user-profiles/user-profile.controller.ts @@ -130,7 +130,11 @@ export class UserProfileController { const userProfile = GetUserProfileDto.fromSource(userProfileSource) - return { userId: userProfile.userId, nickname: userProfile.nickname } + return { + userId: userProfile.userId, + nickname: userProfile.nickname, + additionalInformation: userProfile.additionalInformation, + } } @Put(':userId')