diff --git a/constants/index.ts b/constants/index.ts index 027f60a7..912bc3a8 100644 --- a/constants/index.ts +++ b/constants/index.ts @@ -385,6 +385,26 @@ export const IGMApiSequence = { LSP_ON_ISSUE_STATUS: 'lsp_on_issue_status', } +export const IGM2Flows ={ + FLOW_1: 'FLOW_1', + FLOW_2: 'FLOW_2', + FLOW_3: 'FLOW_3', +} +export const IGM2Sequence = { + "ISSUE_1": "issue_1", + "ON_ISSUE_1": "on_issue_1", + "ON_ISSUE_2": "on_issue_2", + "ISSUE_2": "issue_2", + "ON_ISSUE_3": "on_issue_3", + "ON_ISSUE_4": "on_issue_4", + "ISSUE_3": "issue_3", + "ON_ISSUE_5": "on_issue_5", + "ON_ISSUE_6": "on_issue_6", + "ISSUE_4": "issue_4", + "ON_ISSUE_7": "on_issue_7", + "ISSUE_5": "issue_5", +} + export const RSFapiSequence = { RECEIVER_RECON: 'receiver_recon', ON_RECEIVER_RECON: 'on_receiver_recon', diff --git a/controller/validate/helper.ts b/controller/validate/helper.ts index 688b9e2e..ae04213c 100644 --- a/controller/validate/helper.ts +++ b/controller/validate/helper.ts @@ -2,7 +2,7 @@ import _ from 'lodash' import { sign, hash } from '../../shared/crypto' import { logger } from '../../shared/logger' import { DOMAIN, ERROR_MESSAGE } from '../../shared/types' -import { IGMvalidateLogs, validateLogs, RSFvalidateLogs, RSFvalidateLogsV2 } from '../../shared/validateLogs' +import { IGMvalidateLogs, validateLogs, RSFvalidateLogs, RSFvalidateLogsV2, IGMvalidateLogs2 } from '../../shared/validateLogs' import { validateLogsForFIS12 } from '../../shared/Actions/FIS12Actions' import { validateLogsForMobility } from '../../shared/Actions/mobilityActions' import { validateLogsForMetro } from '../../shared/Actions/metroActions' @@ -190,13 +190,29 @@ const validateIGM = async (payload: string, version: string) => { } break + case '2.0.0': + response = IGMvalidateLogs2(payload) + + if (_.isEmpty(response)) { + success = true + message = ERROR_MESSAGE.LOG_VERIFICATION_SUCCESSFUL + } + + break + default: message = ERROR_MESSAGE.LOG_VERIFICATION_INVALID_VERSION logger.warn('Invalid Version!!') } + + return { response, success, message } } + + + + const validateRSF = async (payload: string, version: string) => { logger.info('Entering validateRSF function') let response diff --git a/controller/validate/index.ts b/controller/validate/index.ts index efa02a29..fc015cc5 100644 --- a/controller/validate/index.ts +++ b/controller/validate/index.ts @@ -56,7 +56,7 @@ const controller = { const { response, success, message } = await helper.validateIGM(payload, version) result = { response, success, message } break - case DOMAIN.RSF: + case DOMAIN.RSF: { const { response, success, message } = await helper.validateRSF(payload, version) result = { response, success, message } diff --git a/shared/validateLogs.ts b/shared/validateLogs.ts index 8ba23b4d..73348138 100644 --- a/shared/validateLogs.ts +++ b/shared/validateLogs.ts @@ -1,7 +1,7 @@ import _ from 'lodash' import { dropDB, setValue } from '../shared/dao' import { logger } from './logger' -import { ApiSequence, retailDomains, IGMApiSequence, RSFapiSequence, RSF_v2_apiSequence } from '../constants' +import { ApiSequence, retailDomains, IGMApiSequence,IGM2Sequence, RSFapiSequence, RSF_v2_apiSequence } from '../constants' import { validateSchema, isObjectEmpty } from '../utils' import { checkOnsearchFullCatalogRefresh } from '../utils/Retail/RET11_onSearch/onSearch' import { checkSelect } from '../utils/Retail/Select/select' @@ -49,6 +49,8 @@ import checkRsfReport from '../utils/RSF/RSF_v2/report' import checkRsfOnReport from '../utils/RSF/RSF_v2/on_report' import checkRsfRecon from '../utils/RSF/RSF_v2/recon' import checkRsfOnRecon from '../utils/RSF/RSF_v2/on_recon' +import checkIssueV2 from 'utils/igm/igm2/issue' +import checkOnIssueV2 from 'utils/igm/igm2/on_issue' export const validateLogs = async (data: any, domain: string, flow: string) => { const msgIdSet = new Set() @@ -408,6 +410,89 @@ export const IGMvalidateLogs = (data: any) => { } } +export const IGMvalidateLogs2 = (data: any) => { + let logReport: any = {} + + + try { + dropDB() + } catch (error) { + logger.error('!!Error while removing LMDB', error) + } + + try { + if (data[IGM2Sequence.ISSUE_1]) { + const issue_1 = checkIssueV2(data[IGM2Sequence.ISSUE_1]) + + if (!_.isEmpty(issue_1)) { + logReport = { ...logReport, [IGM2Sequence.ISSUE_1]: issue_1 } + } + } + + if (data[IGM2Sequence.ON_ISSUE_1]) { + const on_issue_1 = checkOnIssueV2(data[IGM2Sequence.ON_ISSUE_1],IGM2Sequence.ON_ISSUE_1) + + if (!_.isEmpty(on_issue_1)) { + logReport = { ...logReport, [IGM2Sequence.ON_ISSUE_1]: on_issue_1 } + } + } + + if(data[IGM2Sequence.ON_ISSUE_2]){ + const on_issue_2 = checkOnIssueV2(data[IGM2Sequence.ON_ISSUE_2],IGM2Sequence.ON_ISSUE_2 ) + + if (!_.isEmpty(on_issue_2)) { + logReport = { ...logReport, [IGM2Sequence.ON_ISSUE_1]: on_issue_2 } + } + } + + if(data[IGM2Sequence.ISSUE_2]){ + const on_issue_2 = checkOnIssueV2(data[IGM2Sequence.ON_ISSUE_2],IGM2Sequence.ISSUE_2 ) + + if (!_.isEmpty(on_issue_2)) { + logReport = { ...logReport, [IGM2Sequence.ON_ISSUE_1]: on_issue_2 } + } + } + + if (data[IGM2Sequence.ON_ISSUE_3]) { + const on_issue_3 = checkOnIssueV2(data[IGM2Sequence.ON_ISSUE_3],IGM2Sequence.ON_ISSUE_3) + + if (!_.isEmpty(on_issue_3)) { + logReport = { ...logReport, [IGM2Sequence.ON_ISSUE_3]: on_issue_3 } + } + } + + if(data[IGM2Sequence.ON_ISSUE_4]){ + const ON_ISSUE_4 = checkOnIssueV2(data[IGM2Sequence.ON_ISSUE_4],IGM2Sequence.ISSUE_4 ) + + if (!_.isEmpty(ON_ISSUE_4)) { + logReport = { ...logReport, [IGM2Sequence.ON_ISSUE_4]: ON_ISSUE_4} + } + } + + if(data[IGM2Sequence.ISSUE_3]){ + const ISSUE_3 = checkOnIssueV2(data[IGM2Sequence.ON_ISSUE_3],IGM2Sequence.ISSUE_3 ) + + if (!_.isEmpty(ISSUE_3)) { + logReport = { ...logReport, [IGM2Sequence.ON_ISSUE_1]: ISSUE_3 } + } + } + + if(data[IGM2Sequence.ON_ISSUE_5]){ + const on_issue_5 = checkOnIssueV2(data[IGM2Sequence.ON_ISSUE_5],IGM2Sequence.ON_ISSUE_5 ) + + if (!_.isEmpty(on_issue_5)) { + logReport = { ...logReport, [IGM2Sequence.ON_ISSUE_5]: on_issue_5 } + } + } + + logger.info(logReport, 'Report Generated Successfully!!') + return logReport + } catch (error: any) { + logger.error(error.message) + return error.message + } +} + export const RSFvalidateLogs = (data: any) => { let logReport: any = {} diff --git a/utils/igm/igm2/issue.ts b/utils/igm/igm2/issue.ts new file mode 100644 index 00000000..520abfd7 --- /dev/null +++ b/utils/igm/igm2/issue.ts @@ -0,0 +1,296 @@ +// import _ from 'lodash'; +// import { setValue } from '../../../shared/dao'; +// import { checkContext, isObjectEmpty } from '../../../utils/index'; +// import constants from '../../../constants/index'; +// import { validateSchema } from '../../../utils/index'; +// import { logger } from '../../../shared/logger'; +// import issue_subcategory from '../../issue_subcategories'; +// import { +// checkOrganizationNameandDomain, +// compareContextTimeStampAndUpdatedAt, +// compareCreatedAtAndUpdationTime, +// compareUpdatedAtAndContextTimeStamp, +// } from '../igmHelpers'; + +// const checkIssueV2 = (data: any) => { +// const issueObj: any = {}; +// let res: any = {}; + +// if (!data || isObjectEmpty(data)) { +// return { [constants.RET_ISSUE]: 'JSON cannot be empty' }; +// } + +// try { +// const issue: any = data; + +// try { +// logger.info(`Validating Schema for ${constants.ISSUE_1} API`); +// const vs = validateSchema('igm', constants.ISSUE_1, issue); +// if (vs !== 'error') { +// Object.assign(issueObj, vs); +// } +// } catch (error: any) { +// logger.error(`Schema validation error for /${constants.ISSUE_1}, ${error.stack}`); +// } + +// try { +// logger.info(`Checking context for ${constants.ISSUE_1} API`); +// res = checkContext(issue.context, constants.RET_ISSUE); +// if (!res.valid) { +// Object.assign(issueObj, res.ERRORS); +// } +// } catch (error: any) { +// logger.error(`Error checking context for /${constants.ISSUE_1}, ${error.stack}`); +// } + +// try { +// logger.info(`Storing necessary context values for /${constants.ISSUE_1}`); +// setValue('igmTxnId', issue.context.transaction_id); +// setValue('igmTmpstmp', issue.context.timestamp); +// setValue('igmCoreVersion', issue.context.core_version); +// setValue('igmDomain', issue.context.domain); +// setValue('igmIssueMsgId', issue.context.message_id); +// setValue('seller_bpp_id', issue.context.bpp_id); +// setValue('seller_bpp_uri', issue.context.bpp_uri); + +// if (issue.message) { +// setValue('igmIssueType', issue.message.issue.level); +// } +// } catch (error: any) { +// logger.error(`Error storing context values for /${constants.RET_ISSUE}, ${error.stack}`); +// } + +// try { +// logger.info(`Validating issue category and subcategory for /${constants.RET_ISSUE}`); +// if (!issue.message.issue.description || !issue.message.issue.description.code) { +// issueObj.ctgrySubCategory = 'Missing or invalid issue description code'; +// } +// } catch (error: any) { +// logger.error(`Error validating issue category and subcategory, ${error.stack}`); +// } + +// checkOrganizationNameandDomain({ +// endpoint: constants.RET_ISSUE, +// actionPayload: issue.message.issue.actors, +// contextSubscriberId: issue.context.bap_id, +// contextDomain: issue.context.domain, +// issueReportObj: issueObj, +// IdType: 'BAP', +// }); + +// compareUpdatedAtAndContextTimeStamp({ +// endpoint: constants.RET_ISSUE, +// actionPayload: issue.message.issue.actions, +// messageUpdatedAt: issue.message.issue.updated_at, +// issueReportObj: issueObj, +// }); + +// compareCreatedAtAndUpdationTime({ +// endpoint: constants.RET_ISSUE, +// created_at: issue.message.issue.created_at, +// contextTimeStamp: issue.context.timestamp, +// messageUpdatedAt: issue.message.issue.updated_at, +// domain: issue.context.domain, +// issueReportObj: issueObj, +// }); + +// compareContextTimeStampAndUpdatedAt({ +// endpoint: constants.RET_ISSUE, +// contextTimeStamp: issue.context.timestamp, +// issue_updated_at: issue.message.issue.updated_at, +// issueReportObj: issueObj, +// }); + +// try { +// logger.info(`Checking for mandatory images in issue description`); +// if (!issue.message.issue.description.images || !issue.message.issue.description.images.length) { +// issueObj.mndtryImages = 'Issue description images are mandatory'; +// } +// } catch (error: any) { +// logger.error(`Error checking mandatory images, ${error.stack}`); +// } + +// try { +// logger.info(`Validating phone numbers for /${constants.ISSUE_1}`); +// const complainantPhone = issue.message.issue.actors.find((actor: any) => actor.id === issue.message.issue.complainant_id)?.info.contact.phone; +// if (!_.inRange(Number(complainantPhone), 1000000000, 99999999999)) { +// issueObj.Phn = `Invalid phone number in complainant info`; +// } +// setValue('igmPhn', complainantPhone); +// } catch (error: any) { +// logger.error(`Error validating phone number, ${error.stack}`); +// } + +// setValue('igmCreatedAt', issue.message.issue.created_at); +// return issueObj; +// } catch (err: any) { +// logger.error(`Unexpected error in /${constants.ISSUE_1} API`, err); +// } +// }; + +// export default checkIssueV2; +import _ from 'lodash' +import { setValue } from '../../../shared/dao' +import { checkContext, isObjectEmpty } from '../../../utils/index' +import constants, { IGMApiSequence } from '../../../constants/index' +import { validateSchema } from '../../../utils/index' +import { logger } from '../../../shared/logger' +import issue_subcategory from '../../issue_subcategories' +// import messages from '../../utils/messages_constants' +import { + checkOrganizationNameandDomain, + compareContextTimeStampAndUpdatedAt, + compareCreatedAtAndUpdationTime, + compareUpdatedAtAndContextTimeStamp, +} from '../igmHelpers' + +const checkIssue = (data: any) => { + const issueObj: any = {} + let res: any = {} + + if (!data || isObjectEmpty(data)) { + return { [IGMApiSequence.RET_ISSUE]: 'JSON cannot be empty' } + } + + try { + const issue: any = data + + try { + logger.info(`Validating Schema for ${constants.RET_ISSUE} API`) + const vs = validateSchema('igm', constants.RET_ISSUE, issue) + if (vs != 'error') { + Object.assign(issueObj, vs) + } + } catch (error: any) { + logger.error(`!!Error occurred while performing schema validation for /${constants.RET_ISSUE}, ${error.stack}`) + } + try { + logger.info(`Checking context for ${constants.RET_ISSUE} API`) //checking context + res = checkContext(issue.context, constants.RET_ISSUE) + if (!res.valid) { + Object.assign(issueObj, res.ERRORS) + } + } catch (error: any) { + logger.error(`Some error occurred while checking /${constants.RET_ISSUE} context, ${error.stack}`) + } + + try { + logger.info( + `Storing igmTxnID igmTmpstmp igmType igmCoreVersion igmDomain igmIssueMesgId in /${constants.RET_ISSUE}`, + ) //storing IgmTxnId IgmTmpstmp igmType igmCoreVersion igmDomain + setValue('igmTxnId', issue.context.transaction_id) + setValue('igmTmpstmp', issue.context.timestamp) + setValue('igmCoreVersion', issue.context.core_version) + setValue('igmDomain', issue.context.domain) + setValue('igmIssueMsgId', issue.context.message_id) + setValue('seller_bpp_id', issue.context.bpp_id) + setValue('seller_bpp_uri', issue.context.bpp_uri) + + if (issue.message) { + setValue('igmIssueType', issue.message.issue.issue_type) + } + // msgIdSet.add(issue.context.message_id); + if (!res.valid) { + Object.assign(issueObj, res.ERRORS) + } + } catch (error: any) { + logger.error(`!!Some error occurred while checking /${constants.RET_ISSUE} context, ${error.stack}`) + } + + try { + logger.info(`Validating category and subcategory in /${constants.RET_ISSUE}`) + + if ( + (issue.message.category === 'ITEM' && + !issue_subcategory.issueItmSubCategories.includes(issue.message.sub_category)) || + (issue.message.category === 'FULFILLMENT' && + !issue_subcategory.issueFlmSubcategories.includes(issue.message.sub_category)) + ) { + issueObj.ctgrySubCategory = `Invalid sub_category ${issue.sub_category} for issue category "${issue.category}"` + } + + if (issue.message.issue.category === 'ITEM') { + if (issue.message.issue.order_details.items.length === 0) { + issueObj.items = `Items in issue.message.issue.order_details.items should not be empty when message category is ITEM` + } + } + if (issue.message.issue.category === 'FULFILLMENT') { + if (issue.message.issue.order_details.fulfillments.length === 0) { + issueObj.items = `Fulfillments in issue.message.issue.order_details.fulfillments should not be empty when message category is FULFILLMENT` + } + } + } catch (error: any) { + logger.error(`!!Error while validating category and subcategory in /${constants.RET_ISSUE}, ${error.stack}`) + } + + const complainant_actions = issue.message.issue.issue_actions.complainant_actions + + checkOrganizationNameandDomain({ + endpoint: constants.RET_ISSUE, + actionPayload: complainant_actions, + contextSubscriberId: issue.context.bap_id, + contextDomain: issue.context.domain, + issueReportObj: issueObj, + IdType: 'BAP', + }) + + compareUpdatedAtAndContextTimeStamp({ + endpoint: constants.RET_ISSUE, + actionPayload: complainant_actions, + messageUpdatedAt: issue.message.issue.updated_at, + issueReportObj: issueObj, + }) + + compareCreatedAtAndUpdationTime({ + endpoint: constants.RET_ISSUE, + created_at: issue.message.issue.created_at, + contextTimeStamp: issue.context.timestamp, + messageUpdatedAt: issue.message.issue.updated_at, + domain: issue.context.domain, + issueReportObj: issueObj, + }) + + compareContextTimeStampAndUpdatedAt({ + endpoint: constants.RET_ISSUE, + contextTimeStamp: issue.context.timestamp, + issue_updated_at: issue.message.issue.updated_at, + issueReportObj: issueObj, + }) + + try { + logger.info(`Checking conditional mandatory images for certain issue sub-categories`) + if (['ITM02', 'ITM03', 'ITM04', 'ITM05', 'FLM04'].includes(issue.sub_category)) { + const has = Object.prototype.hasOwnProperty + if (!has.call(issue.description, 'images') || !issue.description.images.length) { + issueObj.mndtryImages = `issue/description/images are mandatory for issue sub_category ${issue.sub_category}` + } + } + } catch (error: any) { + logger.error(`Error while checking conditional mandatory images for certain issue sub-categories, ${error.stack}`) + } + + try { + logger.info(`Phone Number Check for /${constants.RET_ISSUE}`) + // on_issue.message.issue.issue_actions.respondent_actions[0].updated_by.contact.phone + if (!_.inRange(issue.message.issue.complainant_info.contact.phone, 1000000000, 99999999999)) { + issueObj.Phn = `Phone Number for /${constants.RET_ISSUE} api is not in the valid Range` + } + setValue('igmPhn', issue.message.issue.complainant_info.contact.phone) + } catch (error: any) { + logger.error(`Error while checking phone number for /${constants.RET_ISSUE} api, ${error.stack}`) + } + + setValue('igmCreatedAt', issue.message.issue.created_at) + + //setValue("issueObj", issueObj); + return issueObj + } catch (err: any) { + if (err.code === 'ENOENT') { + logger.info(`!!File not found for /${constants.RET_ISSUE} API!`) + } else { + logger.error(`!!Some error occurred while checking /${constants.RET_ISSUE} API`, err) + } + } +} + +export default checkIssue diff --git a/utils/igm/igm2/on_issue.ts b/utils/igm/igm2/on_issue.ts new file mode 100644 index 00000000..b1cd8601 --- /dev/null +++ b/utils/igm/igm2/on_issue.ts @@ -0,0 +1,193 @@ +// import _ from 'lodash' +// import { setValue, getValue } from '../../../shared/dao' +// import { checkContext, isObjectEmpty } from '../../../utils/index' +// import constants, { IGMApiSequence } from '../../../constants/index' +// import { validateSchema } from '../../../utils/index' +// import { logger } from '../../../shared/logger' +// import { +// checkCreatedAtInAll, +// checkDomainInAll, +// checkOrganizationNameandDomain, +// compareContextTimeStampAndUpdatedAt, +// compareUpdatedAtAndContextTimeStamp, +// } from '.././igmHelpers' + +// const checkOnIssueV2 = (data: any,apiSequenceName: string) => { +// const onissueObj: any = {} +// let res: any = {} + +// if(apiSequenceName === "ON_ISSUE_1"){ + +// } +// if(apiSequenceName === "ON_ISSUE_2"){ + +// } +// } + +// export default checkOnIssueV2 + + +import _ from 'lodash' +import { setValue, getValue } from '../../../shared/dao' +import { checkContext, isObjectEmpty } from '../../../utils/index' +import constants, { IGMApiSequence } from '../../../constants/index' +import { validateSchema } from '../../../utils/index' +import { logger } from '../../../shared/logger' +import { + checkCreatedAtInAll, + checkDomainInAll, + checkOrganizationNameandDomain, + compareContextTimeStampAndUpdatedAt, + compareUpdatedAtAndContextTimeStamp, +} from '../igmHelpers' + +const checkOnIssue = (data: any,type: string) => { + const onissueObj: any = {} + let res: any = {} + try { + const on_issue: any = data + + if (!data || isObjectEmpty(data)) { + return { [IGMApiSequence.RET_ON_ISSUE]: 'JSON cannot be empty' } + } + + try { + logger.info(`Validating Schema for ${constants.RET_ONISSUE} API`) + const vs = validateSchema('igm', constants.RET_ONISSUE, on_issue) + if (vs != 'error') { + Object.assign(onissueObj, vs) + } + } catch (error: any) { + logger.error(`!!Error occurred while performing schema validation for /${constants.RET_ONISSUE}, ${error.stack}`) + } + + logger.info(`Checking context for ${constants.RET_ONISSUE} API`) //checking context + try { + res = checkContext(on_issue.context, constants.RET_ONISSUE) + if (!res.valid) { + Object.assign(onissueObj, res.ERRORS) + } + } catch (error: any) { + logger.error(`Some error occurred while checking /${constants.RET_ONISSUE} context, ${error.stack}`) + } + + try { + logger.info(`Comparing transaction ID of /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}`) + if (!_.isEqual(getValue('igmTxnId'), on_issue.context.transaction_id)) { + onissueObj.igmTxnId = `transaction ID mismatch in /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}` + } + } catch (error: any) { + logger.error( + `Error while comparing transaction ID in /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}, ${error.stack}`, + ) + } + + try { + logger.info(`Comparing MESSAGE ID of /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}`) + if (!_.isEqual(getValue('igmIssueMsgId'), on_issue.context.message_id)) { + onissueObj.igmIssueMsgId = `Message ID mismatch in /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}` + } + } catch (error: any) { + logger.error( + `Error while comparing Message ID in /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}, ${error.stack}`, + ) + } + + try { + logger.info(`Comparing Domain of /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}`) + if (!_.isEqual(getValue('igmDomain'), on_issue.context.domain)) { + onissueObj.igmDomain = `Domain for /${constants.RET_ISSUE} api should be equal to /${constants.RET_ONISSUE} api` + } + } catch (error: any) { + logger.error( + `Error while comparing Domain for /${constants.RET_ISSUE} and /${constants.RET_ONISSUE} api, ${error.stack}`, + ) + } + + try { + logger.info(`Comparing core version of /${constants.RET_ISSUE} and /${constants.RET_ONISSUE}`) + setValue('core_version', on_issue.context.core_version) + } catch (error: any) { + logger.error( + `Error while comparing core version for /${constants.RET_ISSUE} and /${constants.RET_ONISSUE} api, ${error.stack}`, + ) + } + + try { + logger.info(`Phone Number Check for /${constants.RET_ONISSUE}`) + + if ( + !_.inRange( + on_issue?.message?.issue?.issue_actions?.respondent_actions?.[0]?.updated_by?.contact?.phone, + 1000000000, + 99999999999, + ) + ) { + onissueObj.Phn = `Phone Number for /${constants.RET_ONISSUE} api is not in the valid Range` + } + } catch (error: any) { + logger.error(`Error while checking phone number for /${constants.RET_ONISSUE} api, ${error.stack}`) + } + + // try { + // logger.info( + // `Checking time of creation and updation for /${constants.RET_ONISSUE}` + // ); + // if (!_.lte(issue.context.timestamp, on_issue.message.issue.created_at)) { + // onissueObj.updatedTime = `Time of Creation for /${constants.RET_ONISSUE} api should be less than context timestamp`; + // } + // } catch (error:any) { + // logger.error( + // `Error while checking time of creation and updation for /${constants.RET_ONISSUE} api, ${error.stack}` + // ); + // } + setValue('igmCreatedAt', on_issue.message.issue.created_at) + + const respondent_actions = on_issue.message.issue.issue_actions.respondent_actions + + checkOrganizationNameandDomain({ + endpoint: constants.RET_ONISSUE, + actionPayload: respondent_actions, + contextSubscriberId: on_issue.context.bpp_id, + contextDomain: on_issue.context.domain, + issueReportObj: onissueObj, + IdType: 'BPP', + }) + + compareUpdatedAtAndContextTimeStamp({ + endpoint: constants.RET_ONISSUE, + actionPayload: respondent_actions, + messageUpdatedAt: on_issue.message.issue.updated_at, + issueReportObj: onissueObj, + }) + + checkCreatedAtInAll({ + endpoint: constants.RET_ONISSUE, + created_at: on_issue.message.issue.created_at, + issueReportObj: onissueObj, + }) + + checkDomainInAll({ endpoint: constants.RET_ONISSUE, domain: on_issue.context.domain, issueReportObj: onissueObj }) + + compareContextTimeStampAndUpdatedAt({ + endpoint: constants.RET_ONISSUE, + contextTimeStamp: on_issue.context.timestamp, + issue_updated_at: on_issue.message.issue.updated_at, + issueReportObj: onissueObj, + }) + + setValue('onissueObj', onissueObj) + + // setValue("onissueObj", onissueObj); + return onissueObj + } catch (err: any) { + if (err.code === 'ENOENT') { + logger.info(`!!File not found for /${constants.RET_ONISSUE} API!`) + } else { + logger.error(`!!Some error occurred while checking /${constants.RET_ONISSUE} API`, err) + } + } +} + +export default checkOnIssue +