Skip to content

Commit

Permalink
feat: fetch ecosystem sent invitations (#123)
Browse files Browse the repository at this point in the history
* worked on the eslint issues

Signed-off-by: Nishad <[email protected]>

* worked on GET API sent invitation list to join ecosystem

Signed-off-by: Nishad <[email protected]>

* Solved promise issue in ecosystem repository

Signed-off-by: Nishad <[email protected]>

* Created interface for send invitation payload

Signed-off-by: Nishad <[email protected]>

---------

Signed-off-by: Nishad <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
nishad-ayanworks authored and KulkarniShashank committed Sep 11, 2024
1 parent 4b48b2d commit 9c2f00e
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Transform, Type } from 'class-transformer';
import { toNumber } from '@credebl/common/cast.helper';

import { ApiProperty } from '@nestjs/swagger';
import { IsOptional } from 'class-validator';

export class GetAllEcosystemInvitationsDto {
@ApiProperty({ required: false, default: 1 })
@IsOptional()
@Type(() => Number)
@Transform(({ value }) => toNumber(value))
pageNumber = 1;

@ApiProperty({ required: false })
@IsOptional()
@Type(() => String)
search = '';

@ApiProperty({ required: false })
@IsOptional()
@Type(() => Number)
@Transform(({ value }) => toNumber(value))
pageSize = 10;

}
38 changes: 38 additions & 0 deletions apps/api-gateway/src/ecosystem/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,43 @@ export class EcosystemController {

}

@Get('/:ecosystemId/invitations')
@ApiOperation({ summary: 'Get all sent invitations', description: 'Get all sent invitations' })
@ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto })
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
@ApiQuery({
name: 'pageNumber',
type: Number,
required: false
})
@ApiQuery({
name: 'pageSize',
type: Number,
required: false
})
@ApiQuery({
name: 'search',
type: String,
required: false
})
async getInvitationsByEcosystemId(
@Param('ecosystemId') ecosystemId: string,
@Query() getAllInvitationsDto: GetAllEcosystemInvitationsDto,
@User() user: user,
@Res() res: Response): Promise<Response> {

const getInvitationById = await this.ecosystemService.getInvitationsByEcosystemId(ecosystemId, getAllInvitationsDto, String(user.id));

const finalResponse: IResponseType = {
statusCode: HttpStatus.OK,
message: ResponseMessages.organisation.success.getInvitation,
data: getInvitationById.response
};
return res.status(HttpStatus.OK).json(finalResponse);

}


/**
*
Expand Down Expand Up @@ -201,4 +238,5 @@ export class EcosystemController {
};
return res.status(HttpStatus.CREATED).json(finalResponse);
}

}
10 changes: 10 additions & 0 deletions apps/api-gateway/src/ecosystem/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export class EcosystemService extends BaseService {
const payload = { bulkInvitationDto, userId };
return this.sendNats(this.serviceProxy, 'send-ecosystem-invitation', payload);
}

async getInvitationsByEcosystemId(
ecosystemId: string,
getAllInvitationsDto: GetAllEcosystemInvitationsDto,
userId: string
): Promise<{ response: object }> {
const { pageNumber, pageSize, search } = getAllInvitationsDto;
const payload = { ecosystemId, pageNumber, pageSize, search, userId };
return this.sendNats(this.serviceProxy, 'get-sent-invitations-ecosystemId', payload);
}


}
9 changes: 9 additions & 0 deletions apps/ecosystem/interfaces/invitations.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


export interface FetchInvitationsPayload {
ecosystemId: string;
userId: string,
pageNumber: number;
pageSize: number;
search: string
}
1 change: 0 additions & 1 deletion apps/ecosystem/src/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,4 @@ export class EcosystemService {
return isEmailSent;
}


}

0 comments on commit 9c2f00e

Please sign in to comment.