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,33 +7,11 @@ const { default: axios } = require("axios"); ...@@ -7,33 +7,11 @@ 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",
module.exports = createCoreService( ({ strapi: Strapi }) => ({
"api::end-user.end-user", async sendLeadToSperto(data) {
({ strapi: Strapi }) => ({ console.log(">>>",data);
async sendOTPToSpreto(data) {
const headers = { "Content-Type": "application/json" }; const headers = { "Content-Type": "application/json" };
const otpDetails = {
api_key: process.env.SPERTO_API_KEY,
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 = { const leadData = {
api_key: process.env.SPERTO_API_KEY, api_key: process.env.SPERTO_API_KEY,
lead_category: "W", lead_category: "W",
...@@ -45,9 +23,9 @@ module.exports = createCoreService( ...@@ -45,9 +23,9 @@ module.exports = createCoreService(
otp_verified_yn: "N", otp_verified_yn: "N",
}; };
// console.log("lead data", leadData); // console.log("lead data", leadData);
if (data.comments) { // if (data.comments) {
leadData.comments = data.comments; // leadData.comments = data.comments;
} // }
if (data?.project) { if (data?.project) {
const projectData = await strapi.db const projectData = await strapi.db
.query("api::project.project") .query("api::project.project")
...@@ -64,45 +42,79 @@ module.exports = createCoreService( ...@@ -64,45 +42,79 @@ module.exports = createCoreService(
leadData, leadData,
{ headers: headers } { headers: headers }
); );
// console.log("spertoLeadResponse", spertoLeadResponse); console.log("spertoLeadResponse",spertoLeadResponse);
return spertoLeadResponse;
return spertoLeadResponse, spertoResponse;
// return ;
}, },
// ({ strapi: Strapi }) => ({async sendLeadToSperto(data) {
// console.log(data); async sendOTPToSpreto(data) {
// const headers = { "Content-Type": "application/json" }; const headers = { "Content-Type": "application/json" };
// const leadData = { const otpDetails = {
// api_key: process.env.SPERTO_API_KEY, api_key: process.env.SPERTO_API_KEY,
from_name: data.from_name,
from_mail: data.from_mail,
to: data.to,
subject: data.subject,
body: data.body,
// lead_category: "W", // lead_category: "W",
// campaign_key: process.env.CAMPAIGN_KEY, // campaign_key: process.env.CAMPAIGN_KEY,
// customer_name: data.fullName, // customer_name: data.fullName,
// mobile1_isd: "", // mobile1_isd: "",
// mobile_no1: data.mobileNo, // mobile_no1: data.mobileNumber,
// email_id1: data.email, // email_id1: data.email,
// otp_verified_yn: "N", // otp_verified_yn: "N",
// }; };
// if (data.comments) { const spertoResponse = await axios.post(
// leadData.comments = data.comments; "https://net4hgc.sperto.co.in/_api/api_auth_send_mail.php",
// } otpDetails,
// if (data?.project) { { headers: headers }
// const projectData = await strapi.db );
// .query("api::project.project")
// .findOne({
// where: {
// id: data?.project, return spertoResponse;
// }, // return ;
// });
// leadData.project_name = projectData.projectName; },
// } }))
// module.exports = createCoreService(
// "api::end-user.end-user",
// ({ strapi: Strapi }) => ({
// // ({ 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",
// // };
// // 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;
// // }
// // 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!