Commit ecaede34 by jay

send lead while enduser sign up

1 parent 1009d8b2
......@@ -76,7 +76,7 @@ module.exports = factories.createCoreController(
console.log("ctx.request.body", ctx.request.body);
try {
const spretoLeadData = await strapi
.service("api::lead.lead")
.service("api::end-user.end-user")
.sendLeadToSperto(ctx.request.body.data);
// console.log("spretoLeadData.data", spretoLeadData.data);
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
......
......@@ -7,33 +7,11 @@ const { default: axios } = require("axios");
*/
const { createCoreService } = require("@strapi/strapi").factories;
module.exports = createCoreService(
"api::end-user.end-user",
({ strapi: Strapi }) => ({
async sendOTPToSpreto(data) {
module.exports = createCoreService("api::end-user.end-user",
({ strapi: Strapi }) => ({
async sendLeadToSperto(data) {
console.log(">>>",data);
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 = {
api_key: process.env.SPERTO_API_KEY,
lead_category: "W",
......@@ -45,9 +23,9 @@ module.exports = createCoreService(
otp_verified_yn: "N",
};
// console.log("lead data", leadData);
if (data.comments) {
leadData.comments = data.comments;
}
// if (data.comments) {
// leadData.comments = data.comments;
// }
if (data?.project) {
const projectData = await strapi.db
.query("api::project.project")
......@@ -64,45 +42,79 @@ module.exports = createCoreService(
leadData,
{ headers: headers }
);
// console.log("spertoLeadResponse", spertoLeadResponse);
return spertoLeadResponse, spertoResponse;
// return ;
console.log("spertoLeadResponse",spertoLeadResponse);
return spertoLeadResponse;
},
// ({ strapi: Strapi }) => ({async sendLeadToSperto(data) {
// console.log(data);
// const headers = { "Content-Type": "application/json" };
// const leadData = {
// api_key: process.env.SPERTO_API_KEY,
async sendOTPToSpreto(data) {
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.mobileNo,
// mobile_no1: data.mobileNumber,
// 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_send_mail.php",
otpDetails,
{ headers: headers }
);
return spertoResponse;
// return ;
},
}))
// 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!