From c301770545269eff9fd6b0aabadafda345b3014f Mon Sep 17 00:00:00 2001 From: ajay-beehyv Date: Wed, 21 Sep 2022 13:40:41 +0530 Subject: [PATCH] HLM-638 | Code reafctoring 3 --- .../src/controllers/certificate.controller.js | 6 +++--- .../src/utils/certification.utils.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/vc-certification-service/src/controllers/certificate.controller.js b/backend/vc-certification-service/src/controllers/certificate.controller.js index 2f6cad3d2..b53400da4 100644 --- a/backend/vc-certification-service/src/controllers/certificate.controller.js +++ b/backend/vc-certification-service/src/controllers/certificate.controller.js @@ -4,7 +4,7 @@ const sunbirdRegistryService = require('../services/sunbird.service') const certifyConstants = require('../configs/constants'); const {validationResult} = require('express-validator'); const validationService = require('../services/validation.service'); -const {truncateShard, checkIfArray} = require("../utils/certification.utils"); +const {truncateShard, extractFromArray} = require("../utils/certification.utils"); const REVOKED = "REVOKED"; const SUSPENDED = "SUSPENDED"; @@ -162,8 +162,8 @@ async function verifyCertificate (req,res){ signedCredentials : certificate, } try{ - const certificateEntityType = checkIfArray(checkIfArray(certificate.evidence).type); - const certificateId = checkIfArray(certificate.evidence).certificateId; + const certificateEntityType = extractFromArray(extractFromArray(certificate.evidence).type); + const certificateId = extractFromArray(certificate.evidence).certificateId; console.log({certificateEntityType: certificateEntityType, certificateId:certificateId }); const verifyResp = await sunbirdRegistryService.verifyCertificate(body) diff --git a/backend/vc-certification-service/src/utils/certification.utils.js b/backend/vc-certification-service/src/utils/certification.utils.js index bbf88e67d..c2b2ab5ae 100644 --- a/backend/vc-certification-service/src/utils/certification.utils.js +++ b/backend/vc-certification-service/src/utils/certification.utils.js @@ -1,7 +1,7 @@ const truncateShard = (osId) => { return osId?.substring(2); } -const checkIfArray = (object) => { +const extractFromArray = (object) => { if (object) { object = Array.isArray(object) ? object[0] : object; } else { @@ -11,5 +11,5 @@ const checkIfArray = (object) => { } module.exports = { truncateShard, - checkIfArray + extractFromArray } \ No newline at end of file