Skip to content

Commit

Permalink
feat: return additional information in the profile reduced
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizgar91 committed Mar 4, 2024
1 parent 69f90ff commit 4e5fdfe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
12 changes: 11 additions & 1 deletion src/user-profiles/dto/get-user-profile-restricted.dto.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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
}
6 changes: 5 additions & 1 deletion src/user-profiles/user-profile.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
6 changes: 5 additions & 1 deletion src/user-profiles/user-profile.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 4e5fdfe

Please sign in to comment.