1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2025-01-08 13:02:53 +01:00
This commit is contained in:
Matthias Kretschmann 2018-06-21 18:09:22 +02:00
parent 230c8ccf73
commit c95bac34a0
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -11,11 +11,20 @@ server.listen(4430)
server.use(bodyParser.json()) server.use(bodyParser.json())
// //
// Zoho API urls // Zoho APIs
// //
const apiUrlZohoCampaigns = 'https://campaigns.zoho.com/api/' const apiUrlZohoCampaigns = 'https://campaigns.zoho.com/api/'
const apiUrlZohoCRM = 'https://www.zohoapis.com/crm/v2/' const apiUrlZohoCRM = 'https://www.zohoapis.com/crm/v2/'
const sendRequest = (options, res) => {
request(options, (error, response, body) => {
if (error) res.send(error)
res.send(body)
res.sendStatus(200)
})
}
// //
// Subscribe to newsletter via Zoho Campaigns API // Subscribe to newsletter via Zoho Campaigns API
// https://www.zoho.com/campaigns/newhelp/api/contact-subscribe.html // https://www.zoho.com/campaigns/newhelp/api/contact-subscribe.html
@ -27,15 +36,7 @@ server.get('/newsletter/:data', (req, res) => {
const options = { const options = {
url: `${apiUrlZohoCampaigns}json/listsubscribe?authtoken=${ZOHO_CAMPAIGNS_TOKEN}&scope=CampaignsAPI&resfmt=JSON&listkey=${ZOHO_CAMPAIGNS_LIST_KEY}&contactinfo=${data}` // eslint-disable-line max-len url: `${apiUrlZohoCampaigns}json/listsubscribe?authtoken=${ZOHO_CAMPAIGNS_TOKEN}&scope=CampaignsAPI&resfmt=JSON&listkey=${ZOHO_CAMPAIGNS_LIST_KEY}&contactinfo=${data}` // eslint-disable-line max-len
} }
sendRequest(options, res)
request(options, (error, response, body) => {
if (error) {
res.send(error)
}
res.send(body)
res.sendStatus(200)
})
}) })
// //
@ -52,15 +53,7 @@ server.get('/crm/:data', (req, res) => {
method: 'POST', method: 'POST',
formData: data formData: data
} }
sendRequest(options, res)
request(options, (error, response, body) => {
if (error) {
res.send(error)
}
res.send(body)
res.sendStatus(200)
})
}) })
module.exports = Webtask.fromExpress(server) module.exports = Webtask.fromExpress(server)