Merge pull request #16 from oceanprotocol/feature/bounties

add bounties webtask
This commit is contained in:
Matthias Kretschmann 2018-10-16 13:56:47 +02:00 committed by GitHub
commit 5ffe1653d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 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"
}

38
webtask-bounties.js Normal file
View File

@ -0,0 +1,38 @@
'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)