Commit 1a8a62c1 by jay

utm

1 parent ef7597d3
...@@ -10,11 +10,13 @@ module.exports = createCoreController("api::lead.lead", () => ({ ...@@ -10,11 +10,13 @@ module.exports = createCoreController("api::lead.lead", () => ({
async sendLeads(ctx) {}, async sendLeads(ctx) {},
async create(ctx) { async create(ctx) {
console.log(">>>>", ctx);
try { try {
const spretoLeadData = await strapi const spretoLeadData = await strapi
.service("api::lead.lead") .service("api::lead.lead")
.sendLeadToSperto(ctx.request.body.data); .sendLeadToSperto(ctx.request.body.data);
console.log("spretoLeadData", spretoLeadData);
ctx.request.body.data.httpRequestHeaders = JSON.stringify( ctx.request.body.data.httpRequestHeaders = JSON.stringify(
spretoLeadData.headers spretoLeadData.headers
); );
...@@ -24,7 +26,7 @@ module.exports = createCoreController("api::lead.lead", () => ({ ...@@ -24,7 +26,7 @@ module.exports = createCoreController("api::lead.lead", () => ({
ctx.request.body.data.httpResposneBody = JSON.stringify( ctx.request.body.data.httpResposneBody = JSON.stringify(
spretoLeadData.data spretoLeadData.data
); );
ctx.request.body.data.thirdPartyApiError=false; ctx.request.body.data.thirdPartyApiError = false;
} catch (error) { } catch (error) {
ctx.request.body.data.httpRequestHeaders = JSON.stringify( ctx.request.body.data.httpRequestHeaders = JSON.stringify(
error.config.headers error.config.headers
...@@ -33,7 +35,7 @@ module.exports = createCoreController("api::lead.lead", () => ({ ...@@ -33,7 +35,7 @@ module.exports = createCoreController("api::lead.lead", () => ({
ctx.request.body.data.httpRequestUrl = error.config.url; ctx.request.body.data.httpRequestUrl = error.config.url;
ctx.request.body.data.httpsRequestBody = error.config.data; ctx.request.body.data.httpsRequestBody = error.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(error.message); ctx.request.body.data.httpResposneBody = JSON.stringify(error.message);
ctx.request.body.data.thirdPartyApiError=true; ctx.request.body.data.thirdPartyApiError = true;
} }
const leadData = await super.create(ctx); const leadData = await super.create(ctx);
......
...@@ -21,6 +21,9 @@ module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({ ...@@ -21,6 +21,9 @@ module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({
mobile_no1: data.mobileNumber, mobile_no1: data.mobileNumber,
email_id1: data.email, email_id1: data.email,
otp_verified_yn: "N", otp_verified_yn: "N",
page_url: data.UTMLink ? data.UTMLink : "",
utm_medium: data.utm_medium ? data.utm_medium : "",
utm_source: data.utm_source ? data.utm_source : ""
}; };
if (data.comments) { if (data.comments) {
leadData.comments = data.comments; leadData.comments = data.comments;
...@@ -35,13 +38,21 @@ module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({ ...@@ -35,13 +38,21 @@ module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({
}); });
leadData.project_name = projectData.projectName; leadData.project_name = projectData.projectName;
} }
// if (data.UTMLink) {
// leadData = {...leadData, page_url: data.UTMLink}
// }
// if (data.utm_medium) {
// leadData = {...leadData, utm_medium: data.utm_medium}
// }
// if (data.utm_source) {
// leadData = {...leadData, utm_source: data.utm_source}
// }
const spertoResponse = await axios.post( const spertoResponse = await axios.post(
"https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php", "https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php",
leadData, leadData,
{ headers: headers } { headers: headers }
); );
console.log("spertoResponse",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!