Commit ecaede34 by jay

send lead while enduser sign up

1 parent 1009d8b2
...@@ -76,7 +76,7 @@ module.exports = factories.createCoreController( ...@@ -76,7 +76,7 @@ module.exports = factories.createCoreController(
console.log("ctx.request.body", ctx.request.body); console.log("ctx.request.body", ctx.request.body);
try { try {
const spretoLeadData = await strapi const spretoLeadData = await strapi
.service("api::lead.lead") .service("api::end-user.end-user")
.sendLeadToSperto(ctx.request.body.data); .sendLeadToSperto(ctx.request.body.data);
// console.log("spretoLeadData.data", spretoLeadData.data); // console.log("spretoLeadData.data", spretoLeadData.data);
ctx.request.body.data.httpRequestHeaders = JSON.stringify( ctx.request.body.data.httpRequestHeaders = JSON.stringify(
......
...@@ -7,102 +7,114 @@ const { default: axios } = require("axios"); ...@@ -7,102 +7,114 @@ const { default: axios } = require("axios");
*/ */
const { createCoreService } = require("@strapi/strapi").factories; const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService("api::end-user.end-user",
({ strapi: Strapi }) => ({
async sendLeadToSperto(data) {
console.log(">>>",data);
const headers = { "Content-Type": "application/json" };
const leadData = {
api_key: process.env.SPERTO_API_KEY,
lead_category: "W",
campaign_key: process.env.CAMPAIGN_KEY,
customer_name: data.fullName,
mobile1_isd: "",
mobile_no1: data.mobileNo,
email_id1: data.email,
otp_verified_yn: "N",
};
// console.log("lead data", leadData);
// if (data.comments) {
// leadData.comments = data.comments;
// }
if (data?.project) {
const projectData = await strapi.db
.query("api::project.project")
.findOne({
where: {
id: data?.project,
},
});
leadData.project_name = projectData.projectName;
}
module.exports = createCoreService( const spertoLeadResponse = await axios.post(
"api::end-user.end-user", "https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
({ strapi: Strapi }) => ({ leadData,
async sendOTPToSpreto(data) { { headers: headers }
const headers = { "Content-Type": "application/json" }; );
const otpDetails = { console.log("spertoLeadResponse",spertoLeadResponse);
api_key: process.env.SPERTO_API_KEY, return spertoLeadResponse;
from_name: data.from_name, },
from_mail: data.from_mail,
to: data.to,
subject: data.subject,
body: data.body,
// lead_category: "W",
// campaign_key: process.env.CAMPAIGN_KEY,
// customer_name: data.fullName,
// mobile1_isd: "",
// mobile_no1: data.mobileNumber,
// email_id1: data.email,
// otp_verified_yn: "N",
};
const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_send_mail.php",
otpDetails,
{ headers: headers }
);
const leadData = { async sendOTPToSpreto(data) {
api_key: process.env.SPERTO_API_KEY, const headers = { "Content-Type": "application/json" };
lead_category: "W", const otpDetails = {
campaign_key: process.env.CAMPAIGN_KEY, api_key: process.env.SPERTO_API_KEY,
customer_name: data.fullName, from_name: data.from_name,
mobile1_isd: "", from_mail: data.from_mail,
mobile_no1: data.mobileNo, to: data.to,
email_id1: data.email, subject: data.subject,
otp_verified_yn: "N", body: data.body,
}; // lead_category: "W",
// console.log("lead data", leadData); // campaign_key: process.env.CAMPAIGN_KEY,
if (data.comments) { // customer_name: data.fullName,
leadData.comments = data.comments; // mobile1_isd: "",
} // mobile_no1: data.mobileNumber,
if (data?.project) { // email_id1: data.email,
const projectData = await strapi.db // otp_verified_yn: "N",
.query("api::project.project") };
.findOne({ const spertoResponse = await axios.post(
where: { "https://net4hgc.sperto.co.in/_api/api_auth_send_mail.php",
id: data?.project, otpDetails,
}, { headers: headers }
}); );
leadData.project_name = projectData.projectName;
}
const spertoLeadResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
leadData,
{ headers: headers }
);
// console.log("spertoLeadResponse", spertoLeadResponse);
return spertoLeadResponse, spertoResponse; return spertoResponse;
// return ; // return ;
}, },
// ({ strapi: Strapi }) => ({async sendLeadToSperto(data) { }))
// console.log(data);
// const headers = { "Content-Type": "application/json" }; // module.exports = createCoreService(
// const leadData = { // "api::end-user.end-user",
// api_key: process.env.SPERTO_API_KEY, // ({ strapi: Strapi }) => ({
// lead_category: "W",
// campaign_key: process.env.CAMPAIGN_KEY, // // ({ strapi: Strapi }) => ({async sendLeadToSperto(data) {
// customer_name: data.fullName, // // console.log(data);
// mobile1_isd: "", // // const headers = { "Content-Type": "application/json" };
// mobile_no1: data.mobileNo, // // const leadData = {
// email_id1: data.email, // // api_key: process.env.SPERTO_API_KEY,
// otp_verified_yn: "N", // // lead_category: "W",
// }; // // campaign_key: process.env.CAMPAIGN_KEY,
// if (data.comments) { // // customer_name: data.fullName,
// leadData.comments = data.comments; // // mobile1_isd: "",
// } // // mobile_no1: data.mobileNo,
// if (data?.project) { // // email_id1: data.email,
// const projectData = await strapi.db // // otp_verified_yn: "N",
// .query("api::project.project") // // };
// .findOne({ // // if (data.comments) {
// where: { // // leadData.comments = data.comments;
// id: data?.project, // // }
// }, // // if (data?.project) {
// }); // // const projectData = await strapi.db
// leadData.project_name = projectData.projectName; // // .query("api::project.project")
// } // // .findOne({
// // where: {
// // id: data?.project,
// // },
// // });
// // leadData.project_name = projectData.projectName;
// // }
// // const spertoResponse = await axios.post(
// // "https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
// // leadData,
// // { headers: headers }
// // );
// // return spertoResponse;
// // }})
// })
// );
// const spertoResponse = await axios.post(
// "https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
// leadData,
// { headers: headers }
// );
// 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!