Skip to content

Commit

Permalink
updating api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
esatterwhite committed Jan 10, 2017
1 parent 7244862 commit 12600fe
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
27 changes: 25 additions & 2 deletions lib/server/api/post_timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ module.exports = {
* @apiParam {String} callback.method The method of delivery the tranport should use
* @apiParam {String} callback.uri A full uri the transport should send data to
* @apiHeader (Response Headers) {String} location URI of the created timer which can be used to modify or cancel the timer
* @apiHeader (Response Headers) {String} [x-skyring-reason] An err message if an error occured
* @apiHeaderExample {text} Headers Example:
* HTTP/1.1 201 CREATED
* LOCATION: /timer/489ea3df-c583-4325-8fb0-0f1ec8301bd9
* Location: /timer/489ea3df-c583-4325-8fb0-0f1ec8301bd9
* Date: Fri, 23 Dec 2016 00:19:13 GMT
* Connection: keep-alive
* Content-Length: 0
Expand Down Expand Up @@ -91,7 +92,7 @@ module.exports = {
* req.end();
* @apiExample {python} python:
* import json
* from urlib.request import Request, urlopen
* from urllib.request import Request, urlopen
* data = {
* 'timeout': 5000
* , 'data': {'foo':'bar'}
Expand All @@ -105,4 +106,26 @@ module.exports = {
* res = urlopen(req)
* print(res.status)
* print(res.headers['location'])
* @apiExample {ruby} ruby:
*
* require 'json'
* require 'net/http'
* require 'uri'
*
* uri = URI.parse('http://localhost:3003/timer')
* payload = {
* timeout: 3000,
* data: "hello world",
* callback: {
* method: 'post',
* transport: 'http',
* uri: 'http://localhost:4000'
* }
* }
*
* http = Net::HTTP.new(uri.host, uri.port)
* request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type': 'application/json'})
* request.body = payload.to_json
* response = http.request(request)
* print response.code
**/
40 changes: 40 additions & 0 deletions lib/server/api/put_timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module.exports = {
* @apiParam {String} callback.transport The delivery transport to use when executing the timer
* @apiParam {String} callback.method The method of delivery the tranport should use
* @apiParam {String} callback.uri A full uri the transport should send data to
* @apiHeader (Response Headers) {String} location URI of the created timer which can be used to modify or cancel the timer
* @apiHeader (Response Headers) {String} [x-skyring-reason] An err message if an error occured
* @apiExample {curl} curl:
* curl -XPUT -H "Content-Type: application/json" http://localhost:3000/timer/8c66a779-9c74-4e30-b5e8-f32d60909d45 -d '{
* "timeout": 3000,
Expand Down Expand Up @@ -83,4 +85,42 @@ module.exports = {
* })
* req.write(data);
* req.end();
* @apiExample {python} python:
* import json
* from urllib.request import Request, urlopen
* data = {
* 'timeout': 5000
* , 'data': {'foo':'bar'}
* , 'callback': {
* 'transport': 'http'
* , 'method': 'post'
* , 'uri': 'http://mydomain.name/timer/callback'
* }
* }
* req = Request(url='http://localhost:3000/timer/8c66a779-9c74-4e30-b5e8-f32d60909d45', data=bytes(json.dumps(data),'ascii'), method='PUT')
* res = urlopen(req)
* print(res.status)
* print(res.headers['location'])
* @apiExample {ruby} ruby:
*
* require 'json'
* require 'net/http'
* require 'uri'
*
* uri = URI.parse('http://localhost:3003/timer/8c66a779-9c74-4e30-b5e8-f32d60909d45')
* payload = {
* timeout: 3000,
* data: "hello world",
* callback: {
* method: 'post',
* transport: 'http',
* uri: 'http://localhost:4000'
* }
* }
*
* http = Net::HTTP.new(uri.host, uri.port)
* request = Net::HTTP::Put.new(uri.request_uri, {'Content-Type': 'application/json'})
* request.body = payload.to_json
* response = http.request(request)
* print response.code
**/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "node ./test.js",
"coverage": "istanbul cover _mocha -- -R spec --recursive test/",
"postcoverage": "cat ./coverage/lcov.info | ./node_modules/.bin/codeclimate-test-reporter",
"docs": "jsdoc -c jsdoc.json",
"docs": "jsdoc -c jsdoc.json && apidoc -i lib/server -o docs/api",
"start": "npm run compose:up",
"stop": "npm run compose:down",
"test:ci": "docker-compose -f compose/test.yml up --abort-on-container-exit --build",
Expand Down Expand Up @@ -44,6 +44,7 @@
"uuid": "^3.0.1"
},
"devDependencies": {
"apidoc": "^0.16.1",
"async": "^2.1.4",
"codeclimate-test-reporter": "^0.4.0",
"ink-docstrap": "^1.3.0",
Expand Down

0 comments on commit 12600fe

Please sign in to comment.