Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.
/ resthooks Public archive

A RESTHooks.org reference implementation in Ruby / Rails.

Notifications You must be signed in to change notification settings

net-engine/resthooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTHooks

Stop polling

http://resthooks.herokuapp.com/

Create resources

All requests must contain HTTP_AUTHORIZATION header with "Token token="USER-TOKEN-PREVIOUSLY-PROVIDED""

There are two main resources. They are called Beers and burgers, and both have a deliciousness field.

Create beers and burgers

All examples will use beers. For burgers, please replace beers and use burgers instead.

You can create beers by posting to /api/v1/beers with the following payload:

{
  "beer": {
    "deliciousness": 3
  }
}
Example using curl
curl "http://localhost/api/v1/beers" \
  -H 'Accept: application/json' -H 'Content-type: application/json' \
  -H "Authorization: Token token=TOKEN-HERE" \
  -X POST \
  -d '{
        "beer": {
          "deliciousness": 3
        }
      }'

Update beers and burgers

You can update them by putting to /api/v1/beers/ID with the following payload:

{
  "beer": {
    "deliciousness": 4
  }
}
Example using curl
curl "http://localhost/api/v1/beers/1" \
  -H 'Accept: application/json' -H 'Content-type: application/json' \
  -H "Authorization: Token token=TOKEN-HERE" \
  -X PUT \
  -d '{
        "beer": {
          "deliciousness": 4
        }
      }'

Using the resthooks for your service

So now you've got beers and burgers, your service can be subscribed to receive updates when they get modified/created/destroyed.

You need to post to /api/v1/resource_subscriptions (user token in header)

{
  "resource_subscription": {
    "post_url": "https://example.com/some_hook?user_id=123",
    "authentication": null,
    "version": 1,
    "resource": "beer"
  }
}
Example using curl
curl "http://localhost/api/v1/resource_subscriptions
  -H 'Accept: application/json' -H 'Content-type: application/json' \
  -H "Authorization: Token token=TOKEN-HERE" \
  -X PUT \
  -d '{
    "resource_subscription": {
      "post_url": "https://example.com/some_hook?user_id=123",
      "authentication": null,
      "version": 1,
      "resource": "beer"
    }
  }'

LICENSE

MIT 2013.

About

A RESTHooks.org reference implementation in Ruby / Rails.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published