Commit 89f60242 by jay

backend referral lead issue fixed

1 parent 3e833938
...@@ -12,7 +12,7 @@ module.exports = createCoreService( ...@@ -12,7 +12,7 @@ module.exports = createCoreService(
"api::channel-partner.channel-partner", "api::channel-partner.channel-partner",
({ strapi: Strapi }) => ({ ({ strapi: Strapi }) => ({
async sendCPToSperto(data) { async sendCPToSperto(data) {
console.log(data); // console.log(data);
const headers = { "Content-Type": "application/json" }; const headers = { "Content-Type": "application/json" };
const cpData = { const cpData = {
api_key: process.env.SPERTO_API_KEY, api_key: process.env.SPERTO_API_KEY,
...@@ -39,7 +39,7 @@ module.exports = createCoreService( ...@@ -39,7 +39,7 @@ module.exports = createCoreService(
cpData, cpData,
{ headers: headers } { headers: headers }
); );
console.log("cp response", spertoResponse); // console.log("cp response", spertoResponse);
return spertoResponse; return spertoResponse;
}, },
}) })
......
...@@ -58,7 +58,7 @@ module.exports = factories.createCoreController( ...@@ -58,7 +58,7 @@ module.exports = factories.createCoreController(
} }
try { try {
console.log("inside try", user.email); // console.log("inside try", user.email);
const spretoLeadData = await strapi const spretoLeadData = await strapi
.service("api::end-user.end-user") .service("api::end-user.end-user")
.sendLeadToSperto({ ...endUser, email: user.email }, "Y"); .sendLeadToSperto({ ...endUser, email: user.email }, "Y");
...@@ -183,14 +183,14 @@ module.exports = factories.createCoreController( ...@@ -183,14 +183,14 @@ module.exports = factories.createCoreController(
} }
); );
ctx.request.body.data = { ...ctx.request.body.data, emailToSend }; ctx.request.body.data = { ...ctx.request.body.data, emailToSend };
console.log("ctx.request.body.data", ctx.request.body.data); // console.log("ctx.request.body.data", ctx.request.body.data);
// Send an email to the user. // Send an email to the user.
// await strapi.plugin("email").service("email").send(emailToSend).sendOTPToSpreto({...ctx.request.body.data,body: emailToSend }); // await strapi.plugin("email").service("email").send(emailToSend).sendOTPToSpreto({...ctx.request.body.data,body: emailToSend });
try { try {
const spretoOTP = await strapi const spretoOTP = await strapi
.service("api::end-user.end-user") .service("api::end-user.end-user")
.sendOTPToSpreto(ctx.request.body.data); .sendOTPToSpreto(ctx.request.body.data);
console.log("spretoOTP>>>>>>>>", spretoOTP); // console.log("spretoOTP>>>>>>>>", spretoOTP);
ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify( ctx.request.body.data.httpRequestEmailHeaders = JSON.stringify(
spretoOTP.spertoEmailResponse.headers spretoOTP.spertoEmailResponse.headers
); );
...@@ -306,7 +306,7 @@ module.exports = factories.createCoreController( ...@@ -306,7 +306,7 @@ module.exports = factories.createCoreController(
const finalArray = removeDuplicates(projectType); const finalArray = removeDuplicates(projectType);
// const matchingProjects = // const matchingProjects =
console.log(projectsId); // console.log(projectsId);
ctx.send({ ctx.send({
ok: true, ok: true,
...@@ -351,7 +351,7 @@ module.exports = factories.createCoreController( ...@@ -351,7 +351,7 @@ module.exports = factories.createCoreController(
return arr.filter((item, index) => arr.indexOf(item) === index); return arr.filter((item, index) => arr.indexOf(item) === index);
} }
const finalArray = removeDuplicates(porjectConfiguration).sort(); const finalArray = removeDuplicates(porjectConfiguration).sort();
console.log("matchingProjects",finalArray); // console.log("matchingProjects",finalArray);
// const matchingProjects = // const matchingProjects =
......
...@@ -11,7 +11,7 @@ module.exports = createCoreService( ...@@ -11,7 +11,7 @@ module.exports = createCoreService(
"api::end-user.end-user", "api::end-user.end-user",
({ strapi: Strapi }) => ({ ({ strapi: Strapi }) => ({
async sendLeadToSperto(data, isVerified) { async sendLeadToSperto(data, isVerified) {
console.log(">>>>>>>",data); // console.log(">>>>>>>",data);
const headers = { "Content-Type": "application/json" }; const headers = { "Content-Type": "application/json" };
const leadData = { const leadData = {
api_key: process.env.SPERTO_API_KEY, api_key: process.env.SPERTO_API_KEY,
...@@ -23,7 +23,7 @@ module.exports = createCoreService( ...@@ -23,7 +23,7 @@ module.exports = createCoreService(
email_id1: data.email, email_id1: data.email,
otp_verified_yn: isVerified, otp_verified_yn: isVerified,
}; };
console.log("lead data", leadData); // console.log("lead data", leadData);
// if (data.comments) { // if (data.comments) {
// leadData.comments = data.comments; // leadData.comments = data.comments;
// } // }
...@@ -43,7 +43,7 @@ module.exports = createCoreService( ...@@ -43,7 +43,7 @@ module.exports = createCoreService(
leadData, leadData,
{ headers: headers } { headers: headers }
); );
console.log("spertoLeadResponse", spertoLeadResponse); // console.log("spertoLeadResponse", spertoLeadResponse);
return spertoLeadResponse; return spertoLeadResponse;
}, },
......
...@@ -10,7 +10,7 @@ const { createCoreService } = require("@strapi/strapi").factories; ...@@ -10,7 +10,7 @@ const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({ module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({
async sendLeadToSperto(data) { async sendLeadToSperto(data) {
console.log(data); // console.log(data);
const headers = { "Content-Type": "application/json" }; const headers = { "Content-Type": "application/json" };
const leadData = { const leadData = {
api_key: process.env.SPERTO_API_KEY, api_key: process.env.SPERTO_API_KEY,
......
...@@ -8,14 +8,14 @@ const { createCoreController } = require("@strapi/strapi").factories; ...@@ -8,14 +8,14 @@ const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController("api::referral.referral", () => ({ module.exports = createCoreController("api::referral.referral", () => ({
async create(ctx) { async create(ctx) {
console.log("create started"); // console.log("create started");
try { try {
const spertoRefereeData = await strapi const spertoRefereeData = await strapi
.service("api::referral.referral") .service("api::referral.referral")
.sendReferee(ctx.request.body.data); .sendReferee(ctx.request.body.data);
console.log("spertoRefereeData", spertoRefereeData.data.member_id); // console.log("spertoRefereeData", spertoRefereeData.data.member_id);
const spertoReferralData = await strapi.service("api::referral.referral").sendReferral({...ctx.request.body.data, parent_id: spertoRefereeData.data.member_id}) const spertoReferralData = await strapi.service("api::referral.referral").sendReferral({...ctx.request.body.data, parent_id: spertoRefereeData.data.member_id})
// console.log("spertoReferralData", spertoReferralData)
ctx.request.body.data.httpRequestHeaders = JSON.stringify( ctx.request.body.data.httpRequestHeaders = JSON.stringify(
spertoRefereeData.headers spertoRefereeData.headers
); );
......
"use strict"; "use strict";
const { default: axios } = require("axios"); const axios = require("axios");
/** /**
* referral service * referral service
...@@ -49,13 +49,13 @@ module.exports = createCoreService( ...@@ -49,13 +49,13 @@ module.exports = createCoreService(
referralData.building = projectData.projectName; referralData.building = projectData.projectName;
} }
console.log("entered try"); // console.log("entered try");
const spertoResponse = await axios.post( const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_referral_json.php", "https://net4hgc.sperto.co.in/_api/api_auth_post_referral_json.php",
referralData, referralData,
{ headers: headers } { headers: headers }
); );
console.log("spertoResponse", spertoResponse); // console.log("spertoResponse", spertoResponse);
return spertoResponse; return spertoResponse;
}, },
...@@ -85,13 +85,13 @@ module.exports = createCoreService( ...@@ -85,13 +85,13 @@ module.exports = createCoreService(
referring_location: data.projectReferredTo, referring_location: data.projectReferredTo,
}; };
console.log("entered try"); // console.log("entered try2");
const spertoResponse = await axios.post( const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_referral_json.php", "https://net4hgc.sperto.co.in/_api/api_auth_post_referral_json.php",
refereelData, refereelData,
{ headers: headers } { headers: headers }
); );
console.log("spertoResponse", spertoResponse); // console.log("spertoResponse2", spertoResponse);
return spertoResponse; return spertoResponse;
}, },
}) })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!