Skip to content

Commit

Permalink
refactor: decline endorsement transaction API response
Browse files Browse the repository at this point in the history
Signed-off-by: sanjay-k1910 <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
sanjay-k1910 authored and KulkarniShashank committed Sep 11, 2024
1 parent 6b05525 commit d7bb2dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions apps/api-gateway/src/ecosystem/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,13 @@ export class EcosystemController {
@Param('orgId') orgId: string,
@Res() res: Response
): Promise<object> {
await this.ecosystemService.declineEndorsementRequestByLead(ecosystemId, endorsementId, orgId);
const response = await this.ecosystemService.declineEndorsementRequestByLead(ecosystemId, endorsementId, orgId);
const finalResponse: IResponse = {
statusCode: 200,
message: ResponseMessages.ecosystem.success.DeclineEndorsementTransaction
statusCode: HttpStatus.OK,
message: ResponseMessages.ecosystem.success.DeclineEndorsementTransaction,
data: response
};
return res.status(200).json(finalResponse);
return res.status(HttpStatus.OK).json(finalResponse);
}


Expand Down
2 changes: 1 addition & 1 deletion apps/api-gateway/src/ecosystem/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ export class EcosystemService extends BaseService {
orgId: string
): Promise<{ response: object }> {
const payload = { ecosystemId, endorsementId, orgId };
return this.sendNats(this.serviceProxy, 'decline-endorsement-transaction', payload);
return this.sendNatsMessage(this.serviceProxy, 'decline-endorsement-transaction', payload);
}
}
3 changes: 2 additions & 1 deletion apps/ecosystem/src/ecosystem.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,8 @@ async findEcosystemMembers(
}
}

async updateEndorsementRequestStatus(ecosystemId: string, endorsementId: string): Promise<object> {
// eslint-disable-next-line camelcase
async updateEndorsementRequestStatus(ecosystemId: string, endorsementId: string): Promise<endorsement_transaction> {
try {

const endorsementTransaction = await this.prisma.endorsement_transaction.findUnique({
Expand Down
7 changes: 6 additions & 1 deletion apps/ecosystem/src/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,12 @@ export class EcosystemService {

async declineEndorsementRequestByLead(ecosystemId: string, endorsementId: string): Promise<object> {
try {
return await this.ecosystemRepository.updateEndorsementRequestStatus(ecosystemId, endorsementId);
const declineResponse = await this.ecosystemRepository.updateEndorsementRequestStatus(ecosystemId, endorsementId);

// To return selective response
this.removeEndorsementTransactionFields(declineResponse);

return declineResponse;
} catch (error) {
this.logger.error(`error in decline endorsement request: ${error}`);
throw new RpcException(error.response ? error.response : error);
Expand Down

0 comments on commit d7bb2dd

Please sign in to comment.