Skip to content

Commit

Permalink
fix: question answer protocol (#541)
Browse files Browse the repository at this point in the history
* feat:added question answer protocol

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

* fear:added question answer webhook

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

* feat:add question answer protocol inside platform

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

* fix:removed extra cost variables

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

* fix:removed tenant id from API

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

* Merge branch 'fix:removed DTO

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

---------

Signed-off-by: pallavicoder <[email protected]>
Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
pallavighule authored and bhavanakarwade committed Feb 27, 2024
1 parent 2d3c593 commit 2e62ad5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 22 deletions.
11 changes: 4 additions & 7 deletions apps/api-gateway/src/connection/connection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,17 @@ export class ConnectionController {

@Get('orgs/:orgId/question-answer/question/:tenantId')
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER, OrgRoles.HOLDER, OrgRoles.SUPER_ADMIN, OrgRoles.PLATFORM_ADMIN)
@ApiOperation({
summary: `Get question-answer record`,
description: `Get question-answer record`
})
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
async getQuestionAnswersRecord(
@Param('tenantId') tenantId: string,
@Param('orgId') orgId: string,
@Res() res: Response
): Promise<Response> {
const record = await this.connectionService.getQuestionAnswersRecord(tenantId, orgId);
const record = await this.connectionService.getQuestionAnswersRecord(orgId);
const finalResponse: IResponse = {
statusCode: HttpStatus.OK,
message: ResponseMessages.connection.success.questionAnswerRecord,
Expand Down Expand Up @@ -161,22 +160,20 @@ export class ConnectionController {
}

@Post('/orgs/:orgId/question-answer/question/:connectionId/:tenantId')
@ApiOperation({ summary: '', description: 'question-answer/question' })
@ApiOperation({ summary: '', description: 'send question' })
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER, OrgRoles.HOLDER, OrgRoles.SUPER_ADMIN, OrgRoles.PLATFORM_ADMIN)
@ApiResponse({ status: HttpStatus.CREATED, description: 'Created', type: ApiResponseDto })
async sendQuestion(
@Param('orgId') orgId: string,
@Param('connectionId') connectionId: string,
@Param('tenantId') tenantId: string,
@Body() questionDto: QuestionDto,
@User() reqUser: IUserRequestInterface,
@Res() res: Response
): Promise<Response> {

questionDto.orgId = orgId;
questionDto.connectionId = connectionId;
questionDto.tenantId = tenantId;
const questionData = await this.connectionService.sendQuestion(questionDto);
const finalResponse: IResponse = {
statusCode: HttpStatus.CREATED,
Expand Down
5 changes: 2 additions & 3 deletions apps/api-gateway/src/connection/connection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ export class ConnectionService extends BaseService {


getQuestionAnswersRecord(
tenantId: string,
orgId: string
): Promise<object> {
const payload = { tenantId, orgId };
return this.sendNatsMessage(this.connectionServiceProxy, 'get-question-answer-record', payload);

return this.sendNatsMessage(this.connectionServiceProxy, 'get-question-answer-record', orgId);
}

receiveInvitationUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class QuestionDto {

orgId: string;
connectionId: string;
tenantId: string;
}

export class QuestionAnswerWebhookDto {
Expand Down
7 changes: 3 additions & 4 deletions apps/connection/src/connection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from './interfaces/connection.interfaces';
import { IConnectionList, ICreateConnectionUrl } from '@credebl/common/interfaces/connection.interface';
import { IConnectionDetailsById } from 'apps/api-gateway/src/interfaces/IConnectionSearch.interface';
import { IQuestionAnswerPayload, IQuestionPayload } from './interfaces/question-answer.interfaces';
import { IQuestionPayload } from './interfaces/question-answer.interfaces';

@Controller()
export class ConnectionController {
Expand Down Expand Up @@ -84,8 +84,7 @@ export class ConnectionController {
}

@MessagePattern({ cmd: 'get-question-answer-record' })
async getQuestionAnswersRecord(payload: IQuestionAnswerPayload): Promise<object> {
const { tenantId, orgId } = payload;
return this.connectionService.getQuestionAnswersRecord(tenantId, orgId);
async getQuestionAnswersRecord(orgId: string): Promise<object> {
return this.connectionService.getQuestionAnswersRecord(orgId);
}
}
4 changes: 2 additions & 2 deletions apps/connection/src/connection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class ConnectionService {
}
}

async getQuestionAnswersRecord(tenantId: string, orgId: string): Promise<object> {
async getQuestionAnswersRecord(orgId: string): Promise<object> {
try {
const agentDetails = await this.connectionRepository.getAgentEndPoint(orgId);
const orgAgentType = await this.connectionRepository.getOrgAgentType(agentDetails?.orgAgentTypeId);
Expand Down Expand Up @@ -421,7 +421,7 @@ export class ConnectionService {
label: string,
orgAgentType: string,
agentEndPoint: string,
tenantId: string,
tenantId?: string,
connectionId?: string
): Promise<string> {
try {
Expand Down
5 changes: 0 additions & 5 deletions apps/connection/src/interfaces/question-answer.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ export interface IValidResponses {
connectionId?: string;
tenantId?: string;
}

export interface IQuestionAnswerPayload {
tenantId: string;
orgId: string;
}

0 comments on commit 2e62ad5

Please sign in to comment.