hookd-client 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -3
- data/lib/hookd/client.rb +22 -7
- data/lib/hookd/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eade8cb3959a4a3792d6bf6c7db1cc9ea04fe6d1890ff895fe9400e823d720bf
|
4
|
+
data.tar.gz: b49e156b95cac1a65897f3dfc8f85f55e96e8de9181885b9399357e1c8dbcc96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc01eb61437a52f4ed20cec5a9af0b4c408427da54fe87e8186163254f41105a6026970bb96bb32a886761fdb12bc329e99aa38a77f6d2f498573fbb0511b16
|
7
|
+
data.tar.gz: 3f40e48b70f0ac245125382fc9ff5150f4fdfdae1439b8436bf22ce31e852bea9f36d033014f94d4dc61b66c91eea18d26dc8e9ccb13371462069d13977f0b37
|
data/README.md
CHANGED
@@ -63,18 +63,31 @@ The client requires two configuration parameters:
|
|
63
63
|
|
64
64
|
Main client class for interacting with the Hookd server.
|
65
65
|
|
66
|
-
##### `#register`
|
66
|
+
##### `#register(count: nil)`
|
67
67
|
|
68
|
-
Register
|
68
|
+
Register one or more hooks and get DNS/HTTP endpoints.
|
69
69
|
|
70
|
+
**Single hook (default):**
|
70
71
|
```ruby
|
71
72
|
hook = client.register
|
72
73
|
# => #<Hookd::Hook id="abc123" dns="abc123.hookd.example.com" ...>
|
73
74
|
```
|
74
75
|
|
75
|
-
|
76
|
+
**Multiple hooks:**
|
77
|
+
```ruby
|
78
|
+
hooks = client.register(count: 5)
|
79
|
+
# => [#<Hookd::Hook id="abc123" ...>, #<Hookd::Hook id="def456" ...>, ...]
|
80
|
+
```
|
81
|
+
|
82
|
+
Parameters:
|
83
|
+
- `count` (Integer, optional) - Number of hooks to create (default: 1)
|
84
|
+
|
85
|
+
Returns:
|
86
|
+
- `Hookd::Hook` object when `count` is 1 or not specified
|
87
|
+
- Array of `Hookd::Hook` objects when `count` > 1
|
76
88
|
|
77
89
|
Raises:
|
90
|
+
- `ArgumentError` - Invalid count parameter
|
78
91
|
- `Hookd::AuthenticationError` - Authentication failed
|
79
92
|
- `Hookd::ServerError` - Server error (5xx)
|
80
93
|
- `Hookd::ConnectionError` - Connection failed
|
data/lib/hookd/client.rb
CHANGED
@@ -15,14 +15,29 @@ module Hookd
|
|
15
15
|
@uri = URI.parse(server)
|
16
16
|
end
|
17
17
|
|
18
|
-
# Register
|
19
|
-
# @
|
18
|
+
# Register one or more hooks
|
19
|
+
# @param count [Integer, nil] number of hooks to register (default: 1)
|
20
|
+
# @return [Hookd::Hook, Array<Hookd::Hook>] single hook or array of hooks
|
20
21
|
# @raise [Hookd::AuthenticationError] if authentication fails
|
21
22
|
# @raise [Hookd::ServerError] if server returns 5xx
|
22
23
|
# @raise [Hookd::ConnectionError] if connection fails
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
# @raise [ArgumentError] if count is invalid
|
25
|
+
def register(count: nil)
|
26
|
+
body = count.nil? ? nil : { count: count }
|
27
|
+
|
28
|
+
if count && (!count.is_a?(Integer) || count < 1)
|
29
|
+
raise ArgumentError, 'count must be a positive integer'
|
30
|
+
end
|
31
|
+
|
32
|
+
response = post('/register', body)
|
33
|
+
|
34
|
+
# Single hook response (backward compatible)
|
35
|
+
return Hook.from_hash(response) if response.key?('id')
|
36
|
+
|
37
|
+
# Multiple hooks response
|
38
|
+
return [] if response['hooks'].nil? || response['hooks'].empty?
|
39
|
+
|
40
|
+
response['hooks'].map { |h| Hook.from_hash(h) }
|
26
41
|
end
|
27
42
|
|
28
43
|
# Poll for interactions on a hook
|
@@ -57,13 +72,13 @@ module Hookd
|
|
57
72
|
|
58
73
|
def get(path)
|
59
74
|
request = Net::HTTP::Get.new(path)
|
60
|
-
request['
|
75
|
+
request['X-API-Key'] = token
|
61
76
|
execute_request(request)
|
62
77
|
end
|
63
78
|
|
64
79
|
def post(path, body = nil)
|
65
80
|
request = Net::HTTP::Post.new(path)
|
66
|
-
request['
|
81
|
+
request['X-API-Key'] = token
|
67
82
|
request['Content-Type'] = 'application/json'
|
68
83
|
request.body = body.to_json if body
|
69
84
|
execute_request(request)
|
data/lib/hookd/version.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hookd-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Joshua MARTINELLE
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
@@ -24,12 +24,12 @@ files:
|
|
24
24
|
- lib/hookd/hook.rb
|
25
25
|
- lib/hookd/interaction.rb
|
26
26
|
- lib/hookd/version.rb
|
27
|
-
homepage: https://github.com/JoshuaMart/
|
27
|
+
homepage: https://github.com/JoshuaMart/Hookd
|
28
28
|
licenses:
|
29
29
|
- MIT
|
30
30
|
metadata:
|
31
|
-
homepage_uri: https://github.com/JoshuaMart/
|
32
|
-
source_code_uri: https://github.com/
|
31
|
+
homepage_uri: https://github.com/JoshuaMart/Hookd
|
32
|
+
source_code_uri: https://github.com/JoshuaMart/Hookd
|
33
33
|
rubygems_mfa_required: 'true'
|
34
34
|
rdoc_options: []
|
35
35
|
require_paths:
|