summary refs log tree commit diff
path: root/readme.md
blob: 8f5b874e87f44c9f6b3258b6f5d17cb631bcb819 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Net::HTTP::API::Spec

## SYNOPSIS

## DESCRIPTION

## Spec

### API information

  * api_base_url   : URL of the API base
  * api_format     : format of the API
  * api_format_mode: how the format information is sent to the API:
    * append      : the format will be added to the path (eg: /search.json)
    * content-type: the format will be set in the headers of the request (eg: Content-Type)

### API method declaration

  * path:           (required) path of the API method (start after the API base url, start with a /)
  * method:         (required) which HTTP method to use (GET/POST/PUT/DELETE)
  * description:    (optional) a description of what the method do
  * strict:         (optional) should the control of the arguments be strict (yes by default)
  * authentication: (optional) does this method require authentication ? (no by default)
  * expected:       (optional) list of possible HTTP code accepted for this request (eg: [200, 201])
  * params:         (optional) list of parameters that will be used for the request
  * params_in_url:  (optional) should the parameters of the request be sent in the URL instead of body (for POST and PUT request)
  * required:       (optional) list of required parameters
  * documetation:   (optional) documentation for this method

### example: GitHub

    {
      "declare" : {
        "api_base_url" : "http://github.com/api/v2/",
        "api_format_mode" : "content-type",
        "api_format" : "json"
      },
      "methods" : {
        "user_information" : {
           "params" : [
              "username",
              "format"
           ],
           "required" : [
              "username",
              "format"
           ],
           "path" : "/:format/user/show/:username",
           "method" : "GET"
        },
        "user_following" : {
           "params" : [
              "user"
           ],
           "required" : [
              "user"
           ],
           "path" : "/user/show/:user/followers",
           "method" : "GET"
        }
      }
    }