Skip to content

Instantly share code, notes, and snippets.

@messick
Last active December 15, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save messick/5255714 to your computer and use it in GitHub Desktop.
Save messick/5255714 to your computer and use it in GitHub Desktop.

QuckLeft Rube Goldberg Hackfest

API Endpoints

/api/events
/api/runs
/api/teams

CURL Examples

The general workflow goes as follows:

  • Create a team - get your token
  • For each time you test, create a run using your team token - get a run token
  • For each step in your machine, report your progress using your run token
  • When you're done, report that you're done using your run token
  • Rinse and repeat!

tl;dr - Create a new run every time you run your machine!

CURL Examples

Get a Token

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"team":{"name":"Team 1"}}' http://rube-goldberg.herokuapp.com/api/teams

This will give the JSON response of: {"result":"success","team_token":"faff5dd68de774c6aaceacba33eb48"}

Start a Run

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"team_token":"faff5dd68de774c6aaceacba33eb48"}' http://rube-goldberg.herokuapp.com/api/runs

This will give the JSON response of: {"result":"success","run_token":"142b86150dc4d346709bc5bb261e69"}

Show Progress

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"run_token":"142b86150dc4d346709bc5bb261e69","event":{"event_type":"progress","title":"Twitter","description":"Sending Tweet: \"You rock @quickleft!\""}}' http://rube-goldberg.herokuapp.com/api/events

This will give the JSON response of: {"result":"success"}

End Your Run

You need to complete your run once things are over and done with. It's basically the same as sending a progress event, but you need to use an event_type of end.

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"run_token":"142b86150dc4d346709bc5bb261e69","event":{"event_type":"end","title":"Twitter","description":"Sending Tweet: \"You rock @quickleft!\""}}' http://rube-goldberg.herokuapp.com/api/events

This will give the JSON response of: {"result":"success"}

Any of the endponts will return a response of {"result":"failure"} plus an errors hash if there are any problems.

Nick Messick (@messick)
Alex McPherson (@alexmcpherson)
Bob Bonifield (@bbonifield)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment