1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2024-11-27 12:52:58 +01:00
🐬🦄 Webtasks doing automatic things for us via webtask.io
Go to file
2018-10-31 13:08:32 +01:00
.editorconfig drop da base ☃️ 2018-03-20 18:12:48 +01:00
.eslintrc switch to eslint-config-oceanprotocol 2018-06-27 20:55:02 +02:00
.gitignore prototype CRM endpoint 2018-06-21 17:54:41 +02:00
.travis.yml rewrite all the things 2018-03-20 18:34:32 +01:00
LICENSE drop da base ☃️ 2018-03-20 18:12:48 +01:00
package.json add videos querying by channel ID 2018-10-31 13:08:32 +01:00
README.md add videos querying by channel ID 2018-10-31 13:08:32 +01:00
webtask-bounties.js rewrite bounty task 2018-10-24 09:07:27 +02:00
webtask-mailchimp.js fix exisiting users detection 2018-10-30 12:52:37 +01:00
webtask-medium.js limit Medium image sizes 2018-10-17 11:45:03 +02:00
webtask-youtube.js add videos querying by channel ID 2018-10-31 13:08:32 +01:00
webtask-zoho.js switch to eslint-config-oceanprotocol 2018-06-27 20:55:02 +02:00

banner

webtasks

🐬 Ocean Protocol's webtasks doing automatic things for us via webtask.io

giphy

Build Status js oceanprotocol Greenkeeper badge

Table of Contents


Tasks

Medium

webtask-medium.js: Generic task to fetch and reconstruct items from any medium publication.

Requires the Medium username appended at the end of the url:

http://localhost:8080/:medium_username

# when published on webtask.io
https://TASK_URL/TASK_NAME/:medium_username

YouTube

webtask-youtube.js: Generic task to fetch and reconstruct items from any YouTube account. YouTube API key is provided via secret environment variable YOUTUBE_API_KEY setup in web editor of webtask.io.

  • /playlist/:playlistId: returns all videos in the given playlist.
  • /channel/:channelId: returns latest 10 videos in the given channel, sorted by date.

Construct your GET request urls like so:

http://localhost:8080/playlist/:youtube_playlist_id
http://localhost:8080/channel/:youtube_channel_id

# when published on webtask.io
https://TASK_URL/TASK_NAME/playlist/:youtube_playlist_id
https://TASK_URL/TASK_NAME/channel/:youtube_channel_id

Response

For all endpoints, response is reconstructed in the same format:

[{
    "id": "8EMowpNlWPE",
    "title": "Fang Gong, Researcher - Bringing Privacy to Ocean Protocol",
    "description": "At Ocean Protocol, we unlock data for AI and use TCRs to maintain a registry of high-quality data sets through voting. Privacy is essential to protecting the ...",
    "imageUrl": "https://i.ytimg.com/vi/8EMowpNlWPE/mqdefault.jpg",
    "videoUrl": "https://www.youtube.com/watch?v=8EMowpNlWPE"
},
{
    ...
}]

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:

http://localhost:8080/

# when published on webtask.io
https://TASK_URL/TASK_NAME/

Response

Response is structured by network and returns the count of open bounties:

{
  "gitcoin": 1,
  "bountiesNetwork": 2
}

MailChimp

webtask-mailchimp.js: Task to add a new newsletter subscriber.

Construct your POST /newsletter request url like so, e.g. locally:

http://localhost:8080/newsletter/jelly@mcjellyfish.com

# when published on webtask.io
https://TASK_URL/TASK_NAME/newsletter/jelly@mcjellyfish.com

Response

When subscription is successful:

{ "status": "created" }

When subscriber already exists:

{ "status": "exists" }

All errors from MailChimp (when "status" is a number) are simply passed through and follow the MailChimp API error responses, e.g.:

{
  "type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
  "title": "Forgotten Email Not Subscribed",
  "status": 400,
  "detail": "matthias@bigchaindb.com was permanently deleted and cannot be re-imported. The contact must re-subscribe to get back on the list.",
  "instance": "06171156-4bca-4b6c-a84f-aa3690a82798"
}

Zoho

webtask-zoho.js: Generic task to subscribe users into lists on Zoho Campaigns & Zoho CRM.

Credentials are provided via secret environment variables, 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:

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:

http://localhost:8080/crm/:data

# when published on webtask.io
https://TASK_URL/TASK_NAME/crm/:data

Development

npm install wt-cli -g
npm start

And go to localhost:8080

Deployment

All tasks are running serverless on webtask.io where you can login with your GitHub account. Then interact with it locally with the wt-cli:

npm install wt-cli -g
wt init YOUR_GITHUB_EMAIL

wt create webtask-medium.js --name medium

# make sure it's there and get url
wt ls

Authors

License

Copyright 2018 Ocean Protocol Foundation Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.