cleanup, remove unused tasks

* closes #9
This commit is contained in:
Matthias Kretschmann 2019-08-20 17:00:43 +02:00
parent 2c5bd901a8
commit 0f5d0ce752
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 0 additions and 139 deletions

View File

@ -18,9 +18,6 @@
- [MailChimp](#mailchimp)
- [Meetup](#meetup)
- [`GET /`](#get-)
- [Zoho](#zoho)
- [Campaigns API](#campaigns-api)
- [CRM API](#crm-api)
- [Development](#development)
- [Deployment](#deployment)
- [Authors](#authors)
@ -205,54 +202,6 @@ Field `groups` holds passed through array of objects with all groups. See https:
}
```
### Zoho
**`webtask-zoho.js`**: Generic task to subscribe users into lists on Zoho Campaigns & Zoho CRM.
Credentials are provided via [secret environment variables](https://webtask.io/docs/issue_parameters), setup in web editor of webtask.io:
* `ZOHO_CAMPAIGNS_TOKEN`
* `ZOHO_CAMPAIGNS_LIST_KEY`
* `ZOHO_CRM_TOKEN`
#### Campaigns API
* `/newsletter/:data`: subscribes the given email address to the newsletter list on Zoho Campaigns.
The data needs to be in `json` format in the following pattern:
```
{Contact Email:info@oceanprotocol.com}
```
Construct your request url like so, e.g. locally:
```bash
http://localhost:8080/newsletter/:data
# when published on webtask.io
https://TASK_URL/TASK_NAME/newsletter/:data
```
#### CRM API
* `/crm/:data`: subscribes the given email address to the newsletter list on Zoho Campaigns.
The data needs to be in `json` format in the following pattern:
```
{First Name:Jellyfish, Last Name:McJellyfish, Contact Email:info@oceanprotocol.com}
```
Construct your request url like so, e.g. locally:
```bash
http://localhost:8080/crm/:data
# when published on webtask.io
https://TASK_URL/TASK_NAME/crm/:data
```
## Development
```bash

View File

@ -1,88 +0,0 @@
const express = require('express')
const Webtask = require('webtask-tools')
const cors = require('cors')
const bodyParser = require('body-parser')
const request = require('request')
const server = express()
server.listen(4430)
server.use(bodyParser.json())
//
// Allow requests from these domains only
//
const corsOptions = {
origin: ['https://oceanprotocol.com', /\.oceanprotocol\.com$/],
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
}
server.use(cors(corsOptions))
//
// Zoho APIs
//
const apiUrlZohoCampaigns = 'https://campaigns.zoho.com/api/'
const apiUrlZohoCRM = 'https://www.zohoapis.com/crm/v2/'
const sendRequest = (options, res) => {
request(options, (error, response, body) => {
if (error) res.send(error)
// just pass through whatever we get from the APIs
// as the response
res.send(body)
})
}
server.get('/', (req, res) => {
res.send(`
<h3>Please provide one of these endpoints:</h3>
- <code>/newsletter/:data</code><br />
- <code>/crm/:data</code>
`)
})
//
// Subscribe to newsletter via Zoho Campaigns API
// https://www.zoho.com/campaigns/newhelp/api/contact-subscribe.html
//
server.get('/newsletter', (req, res) => {
res.send(`
<h3>Please pass your data in the following format</h3>
- <code>/newsletter/{Contact Email:info@oceanprotocol.com}</code><br />
`)
})
server.get('/newsletter/:data', (req, res) => {
const { ZOHO_CAMPAIGNS_TOKEN, ZOHO_CAMPAIGNS_LIST_KEY } = req.webtaskContext.secrets
const { data } = req.params
const options = {
url: `${apiUrlZohoCampaigns}json/listsubscribe?authtoken=${ZOHO_CAMPAIGNS_TOKEN}&scope=CampaignsAPI&resfmt=JSON&listkey=${ZOHO_CAMPAIGNS_LIST_KEY}&contactinfo=${decodeURIComponent(data)}`
}
sendRequest(options, res)
})
//
// Create a new lead via Zoho CRM API
// https://www.zoho.com/crm/help/api/v2/#create-specify-records
//
server.get('/crm', (req, res) => {
res.send(`<h3>Please pass your data in the following format</h3>
- <code>/crm/{First Name:First Name, Last Name:Last Name,Contact Email:info@oceanprotocol.com}</code>`)
})
server.get('/crm/:data', (req, res) => {
const { ZOHO_CRM_TOKEN } = req.webtaskContext.secrets
const { data } = req.params
const options = {
url: `${apiUrlZohoCRM}Leads`,
headers: { Authorization: `Zoho-oauthtoken ${ZOHO_CRM_TOKEN}` },
method: 'POST',
formData: data
}
sendRequest(options, res)
})
module.exports = Webtask.fromExpress(server)