1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2024-11-23 18:41:30 +01:00

add bounties webtask

This commit is contained in:
Matthias Kretschmann 2018-10-16 13:38:08 +02:00
parent d76fb48264
commit 92d80ab42f
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 71 additions and 5 deletions

View File

@ -14,6 +14,7 @@
- [Tasks](#tasks)
- [Medium](#medium)
- [YouTube](#youtube)
- [Bounties](#Bounties)
- [Zoho](#zoho)
- [Campaigns API](#campaigns-api)
- [CRM API](#crm-api)
@ -52,6 +53,32 @@ http://localhost:8080/:youtube_playlist_id
https://TASK_URL/TASK_NAME/:youtube_playlist_id
```
### Bounties
**`webtask-bounties.js`**: Task to fetch open bounties on Gitcoin and Bounties.network in one request. Task creates a unified response from fetching both networks.
Construct your `/` request url like so, e.g. locally:
```bash
http://localhost:8080/
# when published on webtask.io
https://TASK_URL/TASK_NAME/
```
Response is structured by network and fills it with whatever comes back from respective API:
```json
{
"gitcoin": [
{...}
],
"bountiesNetwork": [
{...}
]
}
```
### Zoho
**`webtask-zoho.js`**: Generic task to subscribe users into lists on Zoho Campaigns & Zoho CRM.

View File

@ -3,23 +3,23 @@
"version": "0.1.0",
"private": true,
"scripts": {
"start": "wt serve webtask-zoho.js",
"start": "wt serve webtask-bounties.js",
"test": "eslint ./*.js"
},
"dependencies": {
"body-parser": "^1.18.3",
"cors": "^2.8.4",
"express": "^4.16.3",
"express": "^4.16.4",
"request": "^2.88.0",
"webtask-tools": "^3.4.0"
},
"devDependencies": {
"eslint": "^5.4.0",
"eslint-config-oceanprotocol": "^1.1.1",
"eslint": "^5.7.0",
"eslint-config-oceanprotocol": "^1.2.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-standard": "^4.0.0"
}

39
webtask-bounties.js Normal file
View File

@ -0,0 +1,39 @@
'use strict' // eslint-disable-line
const express = require('express')
const request = require('request')
const webtask = require('webtask-tools')
const app = express()
// Just chained callbacks in lack of proper async/await support on webtask.io
app.get('/', (req, res) => {
// Gitcoin bounties
request('https://gitcoin.co/api/v0.1/bounties/', (error, response, body) => {
if (error) return error
const gitcoinBody = JSON.parse(body) // returns only open bounties by default
const gitcoin = gitcoinBody.filter(
// filter the response manually, no way atm to do that as API query
item => item.funding_organisation.includes('Ocean Protocol')
)
let holder = {}
holder.gitcoin = gitcoin
// Bounties.network bounties
request('https://new.api.bounties.network/bounty/?search=ocean%20protocol&bountyStage=1', (error, response, body) => {
if (error) return
const bountiesNetwork = JSON.parse(body)
holder.bountiesNetwork = bountiesNetwork.results
// Send final response
res.send(holder)
})
})
})
module.exports = webtask.fromExpress(app)