Commit 1a8a62c1 by jay

utm

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