Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
strapi-setup-file
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit ecaede34
authored
2022-11-22 14:48:19 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
send lead while enduser sign up
1 parent
1009d8b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
94 deletions
src/api/end-user/controllers/end-user.js
src/api/end-user/services/end-user.js
src/api/end-user/controllers/end-user.js
View file @
ecaede3
...
...
@@ -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
(
...
...
src/api/end-user/services/end-user.js
View file @
ecaede3
...
...
@@ -7,102 +7,114 @@ const { default: axios } = require("axios");
*/
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
(
"api::end-user.end-user"
,
({
strapi
:
Strapi
})
=>
({
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.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
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
;
},
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
;
}
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.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
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 ;
return
spertoResponse
;
// return ;
},
// ({ 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;
// }
},
}))
// 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;
// }})
})
);
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment