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 f086ee3d
authored
2022-11-03 17:16:46 +0530
by
kashif ansari
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
spreto added for lead
1 parent
a0f93740
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
6 deletions
package-lock.json
package.json
src/api/lead/content-types/lead/schema.json
src/api/lead/controllers/lead.js
src/api/lead/services/lead.js
yarn.lock
package-lock.json
View file @
f086ee3
This diff is collapsed.
Click to expand it.
package.json
View file @
f086ee3
...
...
@@ -15,6 +15,7 @@
"@strapi/provider-email-nodemailer"
:
"^4.3.8"
,
"@strapi/provider-upload-aws-s3"
:
"^4.3.9"
,
"@strapi/strapi"
:
"4.3.6"
,
"axios"
:
"^1.1.3"
,
"better-sqlite3"
:
"7.4.6"
,
"pg"
:
"^8.8.0"
,
"strapi-plugin-ckeditor5"
:
"^2.1.1-rc.1"
...
...
src/api/lead/content-types/lead/schema.json
View file @
f086ee3
...
...
@@ -28,6 +28,21 @@
"type"
:
"relation"
,
"relation"
:
"oneToOne"
,
"target"
:
"api::project.project"
},
"httpsRequestBody"
:
{
"type"
:
"text"
},
"httpRequestHeaders"
:
{
"type"
:
"text"
},
"httpRequestUrl"
:
{
"type"
:
"string"
},
"httpRequestMethod"
:
{
"type"
:
"string"
},
"httpResposneBody"
:
{
"type"
:
"text"
}
}
}
src/api/lead/controllers/lead.js
View file @
f086ee3
'use strict'
;
"use strict"
;
/**
* lead controller
*/
const
{
createCoreController
}
=
require
(
'@strapi/strapi'
).
factories
;
const
{
createCoreController
}
=
require
(
"@strapi/strapi"
).
factories
;
module
.
exports
=
createCoreController
(
'api::lead.lead'
);
module
.
exports
=
createCoreController
(
"api::lead.lead"
,
()
=>
({
async
sendLeads
(
ctx
)
{},
async
create
(
ctx
)
{
try
{
const
spretoLeadData
=
await
strapi
.
service
(
"api::lead.lead"
)
.
sendLeadToSperto
(
ctx
.
request
.
body
.
data
);
ctx
.
request
.
body
.
data
.
httpRequestHeaders
=
JSON
.
stringify
(
spretoLeadData
.
headers
);
ctx
.
request
.
body
.
data
.
httpRequestMethod
=
spretoLeadData
.
config
.
method
;
ctx
.
request
.
body
.
data
.
httpRequestUrl
=
spretoLeadData
.
config
.
url
;
ctx
.
request
.
body
.
data
.
httpsRequestBody
=
spretoLeadData
.
config
.
data
;
ctx
.
request
.
body
.
data
.
httpResposneBody
=
JSON
.
stringify
(
spretoLeadData
.
data
);
}
catch
(
error
)
{
ctx
.
request
.
body
.
data
.
httpRequestHeaders
=
JSON
.
stringify
(
error
.
config
.
headers
);
ctx
.
request
.
body
.
data
.
httpRequestMethod
=
error
.
config
.
method
;
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
);
}
const
leadData
=
await
super
.
create
(
ctx
);
return
ctx
.
send
({
leadData
,
});
},
}));
src/api/lead/services/lead.js
View file @
f086ee3
'use strict'
;
"use strict"
;
const
axios
=
require
(
"axios"
);
/**
* lead service
*/
const
{
createCoreService
}
=
require
(
'@strapi/strapi'
).
factories
;
const
{
createCoreService
}
=
require
(
"@strapi/strapi"
).
factories
;
module
.
exports
=
createCoreService
(
"api::lead.lead"
,
({
strapi
:
Strapi
})
=>
({
async
sendLeadToSperto
(
data
)
{
const
headers
=
{
"Content-Type"
:
"application/json"
};
const
leadData
=
{
api_key
:
"REALATTE-16072021-HVV14-KKJD4-GTCNJ"
,
lead_category
:
"W"
,
campaign_key
:
""
,
customer_name
:
data
.
fullName
,
mobile1_isd
:
data
.
mobileNumber
,
mobile_no1
:
data
.
mobileNumber
,
email_id1
:
data
.
email
,
};
module
.
exports
=
createCoreService
(
'api::lead.lead'
);
const
abc
=
await
axios
.
post
(
"https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php"
,
leadData
,
{
headers
:
headers
}
);
return
abc
;
},
}));
yarn.lock
View file @
f086ee3
This diff is collapsed.
Click to expand it.
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