Skip to content

Commit

Permalink
HLM-638 | Code reafctoring 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-beehyv committed Sep 21, 2022
1 parent c1853d0 commit c301770
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -11,5 +11,5 @@ const checkIfArray = (object) => {
}
module.exports = {
truncateShard,
checkIfArray
extractFromArray
}

0 comments on commit c301770

Please sign in to comment.