mirror of
https://github.com/oceanprotocol/webtasks
synced 2025-01-07 20:35:30 +01:00
commit
4a9355bed3
28
README.md
28
README.md
@ -16,6 +16,8 @@
|
|||||||
- [Get Categories](#get-categories)
|
- [Get Categories](#get-categories)
|
||||||
- [YouTube](#youtube)
|
- [YouTube](#youtube)
|
||||||
- [MailChimp](#mailchimp)
|
- [MailChimp](#mailchimp)
|
||||||
|
- [Meetup](#meetup)
|
||||||
|
- [`GET /`](#get-)
|
||||||
- [Zoho](#zoho)
|
- [Zoho](#zoho)
|
||||||
- [Campaigns API](#campaigns-api)
|
- [Campaigns API](#campaigns-api)
|
||||||
- [CRM API](#crm-api)
|
- [CRM API](#crm-api)
|
||||||
@ -177,6 +179,32 @@ All errors from MailChimp (when `"status"` is a number) are simply passed throug
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Meetup
|
||||||
|
|
||||||
|
**`webtask-meetup.js`**: Task to get information from Meetup.
|
||||||
|
|
||||||
|
#### `GET /`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
http://localhost:8080/meetup
|
||||||
|
|
||||||
|
# when published on webtask.io
|
||||||
|
https://TASK_URL/TASK_NAME/meetup
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response**
|
||||||
|
|
||||||
|
Field `groups` holds passed through array of objects with all groups. See https://www.meetup.com/meetup_api/docs/pro/:urlname/groups/
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"groups": [{
|
||||||
|
...
|
||||||
|
}],
|
||||||
|
"members": 40238
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Zoho
|
### Zoho
|
||||||
|
|
||||||
**`webtask-zoho.js`**: Generic task to subscribe users into lists on Zoho Campaigns & Zoho CRM.
|
**`webtask-zoho.js`**: Generic task to subscribe users into lists on Zoho Campaigns & Zoho CRM.
|
||||||
|
11
package.json
11
package.json
@ -3,15 +3,14 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "wt serve webtask-medium.js",
|
"start": "wt serve webtask-meetup.js",
|
||||||
"test": "eslint ./*.js"
|
"test": "eslint ./*.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"body-parser": "^1.18.3",
|
"cors": "^2.8.5",
|
||||||
"cors": "^2.8.4",
|
"express": "^4.17.1",
|
||||||
"express": "^4.16.4",
|
"ms": "^2.1.2",
|
||||||
"ms": "^2.1.1",
|
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"webtask-tools": "^3.4.0"
|
"webtask-tools": "^3.4.0"
|
||||||
},
|
},
|
||||||
|
51
webtask-meetup.js
Normal file
51
webtask-meetup.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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))
|
||||||
|
|
||||||
|
const baseUrl = 'https://api.meetup.com'
|
||||||
|
|
||||||
|
server.get('/', (req, res) => {
|
||||||
|
const { MEETUP_API_KEY } = req.webtaskContext.secrets
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
url: `${baseUrl}/pro/data-economy/groups?key=${MEETUP_API_KEY}`
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
request.get(options, (error, response, body) => {
|
||||||
|
if (error || response.statusCode !== 200) res.send(error)
|
||||||
|
|
||||||
|
const data = JSON.parse(body)
|
||||||
|
let members = []
|
||||||
|
|
||||||
|
for (const item of data) {
|
||||||
|
members.push(item.member_count)
|
||||||
|
}
|
||||||
|
|
||||||
|
members = members.reduce((a, b) => a + b, 0)
|
||||||
|
res.send({ groups: data, members })
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
res.send(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = Webtask.fromExpress(server)
|
Loading…
Reference in New Issue
Block a user