haveapi 0.21.1 → 0.22.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e72ad9fd9ee5a7d0ada6b5985e28f51d6fe65423b290aae824f6ff55a067145
4
- data.tar.gz: c6c35096b29c02199c3dd4ae46d2ee8ec6920e2f5d5436596e4cde1a133c80cf
3
+ metadata.gz: 3d886505aa1e12970c014a30cd9b51aecb7b97218c62d4b86069c397d2979a69
4
+ data.tar.gz: 4c33b3e2c9fd695737163e00bb1dfe04799356a06591a8cecb6b1d27e675975b
5
5
  SHA512:
6
- metadata.gz: 722c8af5849aef6fe6dbbf48d53bb159c66a9dcd4decafcc4ba20a5f6fee441dbe0eb2d08a2f91283dd900869e1e36632281fcabc038a0ad8ed83dbc9255e053
7
- data.tar.gz: b26b675cb2ce63c3d7f2723f3084bb7e7289d4ee896dfbdcf875ed841adedc9feb991b3ee76715586fc79d8b21657e537c446e2284aab24dd94361dfbbd78383
6
+ metadata.gz: 41837c1ac3eba812bf548cc00edb86f7ff7d9b6af63acbf07ba475027a099300f7a7c2109682e2108dd501b8a51d381625b1f308bee4b580ee49644894d97b57
7
+ data.tar.gz: 6b1b487e12e28912230a37c327de0863056931203574e5fd0d35096c61d3dbf5018af7846d2cee9116c53f442adb799497f1b803b9609599076b0fd065287f95
data/haveapi.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_runtime_dependency 'activesupport', '>= 7.1'
18
18
  s.add_runtime_dependency 'github-markdown'
19
- s.add_runtime_dependency 'haveapi-client', '~> 0.21.1'
19
+ s.add_runtime_dependency 'haveapi-client', '~> 0.22.1'
20
20
  s.add_runtime_dependency 'json'
21
21
  s.add_runtime_dependency 'mail'
22
22
  s.add_runtime_dependency 'nesty', '~> 1.0'
@@ -80,7 +80,7 @@ module HaveAPI::ClientExamples
80
80
  out << "# reply is an instance of HaveAPI::Client::ResourceInstance\n"
81
81
 
82
82
  (sample[:response] || {}).each do |pn, pv|
83
- param = action[:output][:parameters][k]
83
+ param = action[:output][:parameters][pn]
84
84
 
85
85
  if param[:type] == 'Resource'
86
86
  out << "# reply.#{pn} = HaveAPI::Client::ResourceInstance("
@@ -1,4 +1,4 @@
1
1
  module HaveAPI
2
2
  PROTOCOL_VERSION = '2.0'.freeze
3
- VERSION = '0.21.1'.freeze
3
+ VERSION = '0.22.1'.freeze
4
4
  end
data/shell.nix CHANGED
@@ -6,7 +6,7 @@ in stdenv.mkDerivation rec {
6
6
  name = "haveapi";
7
7
 
8
8
  buildInputs = with pkgs;[
9
- ruby
9
+ ruby_3_2
10
10
  git
11
11
  openssl
12
12
  ];
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haveapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.1
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.21.1
47
+ version: 0.22.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.21.1
54
+ version: 0.22.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -204,13 +204,8 @@ files:
204
204
  - LICENSE.txt
205
205
  - README.md
206
206
  - Rakefile
207
- - doc/Hooks.md
208
- - doc/create-client.md
209
207
  - doc/hooks.erb
210
208
  - doc/index.md
211
- - doc/json-schema.html
212
- - doc/protocol.md
213
- - doc/protocol.png
214
209
  - haveapi.gemspec
215
210
  - lib/haveapi.rb
216
211
  - lib/haveapi/action.rb
data/doc/Hooks.md DELETED
@@ -1,81 +0,0 @@
1
-
2
- # Hooks
3
-
4
- ##HaveAPI::Server
5
-
6
- ### post_authenticated
7
- <table>
8
- <tr>
9
- <td style="vertical-align: top;">Description:</td>
10
- <td>Called after the user was authenticated</td>
11
- </tr>
12
- <tr>
13
- <td style="vertical-align: top;">Context:</td>
14
- <td>current</td>
15
- </tr>
16
- <tr>
17
- <td style="vertical-align: top;">Arguments:</td>
18
- <td><dl><dt>current_user</dt><dd>object returned by the authentication backend</dd></dl></td>
19
- </tr>
20
- <tr>
21
- <td style="vertical-align: top;">Initial value:</td>
22
- <td>none</td>
23
- </tr>
24
- <tr>
25
- <td style="vertical-align: top;">Return value:</td>
26
- <td>none</td>
27
- </tr>
28
- </table>
29
-
30
- ### description_exception
31
- <table>
32
- <tr>
33
- <td style="vertical-align: top;">Description:</td>
34
- <td>Called when an exception occurs when building self-description</td>
35
- </tr>
36
- <tr>
37
- <td style="vertical-align: top;">Context:</td>
38
- <td>current</td>
39
- </tr>
40
- <tr>
41
- <td style="vertical-align: top;">Arguments:</td>
42
- <td><dl><dt>context</dt><dd>HaveAPI::Context</dd><dt>exception</dt><dd>exception instance</dd></dl></td>
43
- </tr>
44
- <tr>
45
- <td style="vertical-align: top;">Initial value:</td>
46
- <td>none</td>
47
- </tr>
48
- <tr>
49
- <td style="vertical-align: top;">Return value:</td>
50
- <td><dl><dt>http_status</dt><dd>HTTP status code to send to client</dd><dt>message</dt><dd>error message sent to the client</dd></dl></td>
51
- </tr>
52
- </table>
53
-
54
-
55
- ##HaveAPI::Action
56
-
57
- ### exec_exception
58
- <table>
59
- <tr>
60
- <td style="vertical-align: top;">Description:</td>
61
- <td>Called when unhandled exceptions occurs during Action.exec</td>
62
- </tr>
63
- <tr>
64
- <td style="vertical-align: top;">Context:</td>
65
- <td>current</td>
66
- </tr>
67
- <tr>
68
- <td style="vertical-align: top;">Arguments:</td>
69
- <td><dl><dt>action</dt><dd>HaveAPI::Action instance</dd><dt>exception</dt><dd>exception instance</dd></dl></td>
70
- </tr>
71
- <tr>
72
- <td style="vertical-align: top;">Initial value:</td>
73
- <td>none</td>
74
- </tr>
75
- <tr>
76
- <td style="vertical-align: top;">Return value:</td>
77
- <td><dl><dt>status</dt><dd>true or false, indicating whether error should be reported</dd><dt>message</dt><dd>error message sent to the user</dd></dl></td>
78
- </tr>
79
- </table>
80
-
81
-
data/doc/create-client.md DELETED
@@ -1,107 +0,0 @@
1
- # Client definition
2
- It is necessary to differentiate between clients for HaveAPI based APIs
3
- and clients to work with your API instance. This document describes
4
- the former. If you only want to use your API, you should check a list
5
- of available clients and pick the one in the right language. Only when
6
- there isn't a client already available in the language you want, then
7
- continue reading.
8
-
9
- # Design rules
10
- The client must completely depend on the API description:
11
-
12
- - it has no assumptions and API-specific code,
13
- - it does not know any resources, actions and parameters,
14
- - everything the client knows must be found out from the API description.
15
-
16
- All clients should use a similar paradigm, so that it is possible to use
17
- clients in different languages in the same way, as far as the language syntax
18
- allows. Clients bundled with HaveAPI may serve as a model. A client should
19
- use all the advantages and coding styles of the language it is written
20
- in (e.g. use objects in object oriented languages).
21
-
22
- A model paradigm (in no particular language):
23
-
24
- // Create client instance
25
- api = new HaveAPI.Client("https://your.api.tld")
26
-
27
- // Authenticate
28
- api.authenticate("basic", {"user": "yourname", "password": "yourpassword"})
29
-
30
- // Access resources and actions
31
- api.<resource>.<action>( { <parameters> } )
32
- api.user.new({"name": "Very Name", "password": "donottellanyone"})
33
- api.user.list()
34
- api.nested.resource.deep.list()
35
-
36
- // Pass IDs to resources
37
- api.nested(1).resource(2).deep.list()
38
-
39
- // Object-like access
40
- user = api.user.show(1)
41
- user.id
42
- user.name
43
- user.destroy()
44
-
45
- // Logout
46
- api.logout()
47
-
48
- # Necessary features to implement
49
- A client should implement all of the listed features in order to be useful.
50
-
51
- ## Resource tree
52
- The client gives access to all listed resources and their actions.
53
-
54
- In scripting languages, resources and actions are usually defined as dynamic
55
- properties/objects/methods, depending on the language.
56
-
57
- ## Input/output parameters
58
- Allow sending input parameters and accessing the response.
59
-
60
- ## Input/output formats
61
- A client must send appropriate HTTP header `Accept`. As only JSON is by now built-in
62
- in HaveAPI, it should send `application/json`.
63
-
64
- ## Authentication
65
- All authentication methods that are built-in the HaveAPI should be supported
66
- if possible. The client should choose suitable authentication method
67
- for its purpose and allow the developer to select the authentication method
68
- if it makes sense to do so.
69
-
70
- It is a good practise to implement authentication methods as plugins,
71
- so that developers may add custom authentication providers easily.
72
-
73
- ## Object-like access
74
- A client must interpret the API response according to action output layout.
75
- Layouts `object` and `object_list` should be handled as object instances,
76
- if the language allows it.
77
-
78
- Object instances represent the object fetched from the database. Received
79
- parameters are accessed via object attributes/properties. Actions are defined
80
- as instance methods. Objects may have associations to other resources which
81
- must be made available and be easy to access.
82
-
83
- # Supplemental features
84
- Following features are supplemental. It is good to support them,
85
- but is not necessary.
86
-
87
- ## Client-side validations
88
- Client may make use of described validators and validate the input before
89
- sending it to the API, to lessen the API load and make it more user-friendly.
90
-
91
- However, as the input is validated on the server anyway, it does not have
92
- to be implemented.
93
-
94
- ## Metadata channel
95
- Metadata channel is currently used to specify what associated resources should
96
- be prefetched and whether an object list should contain total number of items.
97
-
98
- Metadata is nothing more than a hash in input parameters under key `_meta`.
99
-
100
- ## Blocking actions
101
- Useful for APIs with long-running actions. Clients can check state of such actions
102
- using resource `ActionState`. Because this resource is automatically present in all
103
- APIs that use blocking actions, client libraries expose this resource to the developer
104
- just as any other resource in the API.
105
-
106
- However, you may wish to integrate it in your client and provide ways for the action
107
- call to block/accept callbacks.