smc_cet_financials_backend/app/services/financials.apicall.helper.js
2023-09-29 16:17:57 +05:30

89 lines
2.8 KiB
JavaScript

const request = require('request');
// probe42
PROBE42_URL = process.env.PROBE42_URL
PROBE42_USER_ID = process.env.PROBE42_USER_ID
PROBE42_PASSWORD = process.env.PROBE42_PASSWORD
PROBE42_APPLICATION_NAME = process.env.PROBE42_APPLICATION_NAME
//redirection
REDIRECTION_URL = process.env.REDIRECTION_URL
REDIRECTION_USERNAME = process.env.REDIRECTION_USERNAME
REDIRECTION_PASSWORD = process.env.REDIRECTION_PASSWORD
REDIRECTION_APPLICATION_NAME = process.env.REDIRECTION_APPLICATION_NAME
function probe42ApiCall(entity_identify_number,entity_identify_number_type) {
try {
const probe_url = PROBE42_URL + "GetCompanyLlpComprehensiveDetails";
const myJSONObject = {
"UserId": PROBE42_USER_ID,
"Password": PROBE42_PASSWORD,
"ApplicationName": PROBE42_APPLICATION_NAME,
"Cin_Llpin_Or_Pan": entity_identify_number,
"Identifier_type" : entity_identify_number_type
};
// console.log(probe_url)
// console.log(myJSONObject)
return new Promise((resolve, reject) => {
request({
url: probe_url,
method: "POST",
json: true,
body: myJSONObject
}, function (error, response, body) {
if (body != undefined) {
// console.log(response.statusCode);
res = JSON.parse(body);
// console.log(res.data.company);
if (response.statusCode == 200 && res.hasOwnProperty("data") ) {
financial_data = res.data;
resolve(financial_data);
} else { resolve(false); }
} else { resolve(false); }
});
});
}
catch (error) {
console.log(error);
}
}
function redirectionApiCall(losid) {
try {
const redirection_url = REDIRECTION_URL + "getdetail";
const myJSONObject = {
"Username": REDIRECTION_USERNAME,
"Password": REDIRECTION_PASSWORD,
"ApplicationName": REDIRECTION_APPLICATION_NAME,
"LoginNo": losid
};
return new Promise((resolve, reject) => {
request({
url: redirection_url,
method: "POST",
json: true,
body: myJSONObject
}, function (error, response, body) {
if (body != undefined) {
if (body.status == "Success" && body.data.length != 0) {
resolve(body.data);
} else { resolve(false); }
} else { resolve(false); }
});
});
}
catch (error) {
console.log(error);
}
}
module.exports = {
probe42ApiCall: probe42ApiCall,
redirectionApiCall: redirectionApiCall
}