hostedhooks 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 589ce3bf7f35913ded48306ae3d4ec7a9424c9c351b773e189e0cc5fb0fae4ec
4
- data.tar.gz: f746e4e7f92460b9b087a2fdaddbaa9baf96f9648736326f17440525c89f6642
3
+ metadata.gz: 29e2feaf6c8df357b485f861be97a24e8ace7ff29d415b5e796b181b3e4d0c1c
4
+ data.tar.gz: f468b079df31c190eb62d6427f2eb0cb9e7250af64731cf7d6ec515f90808274
5
5
  SHA512:
6
- metadata.gz: 38a3988a0930be8cf7a1e17828e393a20086e13e5b90b57663dccd8a350909c6e70570664f9b58cf540c6ec18a7ddeb2f9909a4f8b57a306dd8fd81646f769af
7
- data.tar.gz: 9a4270c7d3a75b704e5681e61bc3258d7105a49d037d2b3a4e35e4474bf6492d876b4683f13ff643f89e42cb1f202806a6c261565ebab0fed878a3134f3cfbc7
6
+ metadata.gz: 60c3cc1b5ade80dc65e24cdab2a3c885165c7f23864f2550cc389e01a08a33c6431abaa130f50a96748e523864dd9c463ae5f68fbe1fc764a8b2c41b07e939c1
7
+ data.tar.gz: 54a4db0a90120926e6115c4028240eac9b94fdb6831a015e875a3a1c8cc52f8fefa1f27bec0e58eaf6dbd592b67c70356ca152b3ae1d78722cd6c98b35f8efcd
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # HostedHooks Ruby Gem
2
2
 
3
- A Ruby library for [HostedHooks](https://www.hostedhooks.com) - a Webhooks as a Service Platform
3
+ A Ruby library for [HostedHooks](https://www.hostedhooks.com), a Webhooks as a Service Platform
4
4
 
5
5
  ## Installation
6
6
 
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ### Authentication
24
24
 
25
- Initialize the gem with your API key [found here](https://www.hostedhooks.com/settings/account).
25
+ Initialize the gem with your API key that is [found here](https://www.hostedhooks.com/settings/account)
26
26
 
27
27
  client = HostedHooks::Client.new('API_KEY')
28
28
 
@@ -58,7 +58,9 @@ Initialize the gem with your API key [found here](https://www.hostedhooks.com/se
58
58
 
59
59
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hostedhooks-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/HostedHooks/hostedhooks-ruby/blob/master/CODE_OF_CONDUCT.md).
60
60
 
61
-
62
61
  ## Code of Conduct
63
62
 
64
63
  Everyone interacting in the Hostedhooks::Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/HostedHooks/hostedhooks-ruby/blob/master/CODE_OF_CONDUCT.md).
64
+
65
+ ## License
66
+ The gem is available as open source under the terms of the MIT License.
@@ -8,8 +8,8 @@ module HostedHooks
8
8
 
9
9
  # Apps
10
10
 
11
- def list_apps
12
- get_response("/apps")
11
+ def list_apps(params = {})
12
+ get_response("/apps", params.slice(:page, :per_page, :offset))
13
13
  end
14
14
 
15
15
  def create_app(payload = {})
@@ -22,12 +22,12 @@ module HostedHooks
22
22
 
23
23
  # Subscriptions
24
24
 
25
- def get_subscription(uuid)
26
- get_response "/subscriptions/#{uuid}"
25
+ def get_subscription(uuid, params = {})
26
+ get_response("/subscriptions/#{uuid}", params.slice(:page, :per_page, :offset))
27
27
  end
28
28
 
29
- def list_subscriptions(app_uuid)
30
- get_response("/apps/#{app_uuid}/subscriptions")
29
+ def list_subscriptions(app_uuid, params = {})
30
+ get_response("/apps/#{app_uuid}/subscriptions", params.slice(:page, :per_page, :offset))
31
31
  end
32
32
 
33
33
  def create_subscription(app_uuid, payload = {})
@@ -36,50 +36,64 @@ module HostedHooks
36
36
 
37
37
  # Endpoints
38
38
 
39
- def get_endpoint(app_uuid, endpoint_uuid)
40
- get_response "/apps/#{app_uuid}/endpoints/#{endpoint_uuid}"
39
+ def get_endpoint(app_uuid, endpoint_uuid, params = {})
40
+ get_response("/apps/#{app_uuid}/endpoints/#{endpoint_uuid}", params.slice(:page, :per_page, :offset))
41
41
  end
42
42
 
43
- def list_endpoints(app_uuid)
44
- get_response("/apps/#{app_uuid}/endpoints")
43
+ def list_endpoints(app_uuid, params = {})
44
+ get_response("/apps/#{app_uuid}/endpoints", params.slice(:page, :per_page, :offset))
45
45
  end
46
46
 
47
- def create_subscription(subscription_uuid, payload = {})
47
+ def create_endpoint(subscription_uuid, payload = {})
48
48
  post_response "/subscriptions/#{subscription_uuid}/endpoints", payload.slice(:url, :enabled_events, :version, :status, :description)
49
49
  end
50
50
 
51
- def update_app(subscription_uuid, endpoint_uuid, payload = {})
51
+ def update_endpoint(subscription_uuid, endpoint_uuid, payload = {})
52
52
  patch_response "/subscriptions/#{subscription_uuid}/endpoints/#{endpoint_uuid}", payload.slice(:url, :enabled_events, :version, :status, :description)
53
53
  end
54
54
 
55
55
  # Webhook Events
56
56
 
57
- def list_webhook_events(app_uuid)
58
- get_response("/apps/#{app_uuid}/webhook_events")
57
+ def list_webhook_events(app_uuid, params = {})
58
+ get_response("/apps/#{app_uuid}/webhook_events", params.slice(:page, :per_page, :offset))
59
59
  end
60
60
 
61
61
  # Messages
62
62
 
63
63
  def create_app_message(app_uuid, payload = {})
64
- post_response "/apps/#{app_uuid}/messages", payload.slice(:event_type, :data, :version, :event_id)
64
+ post_response "/apps/#{app_uuid}/messages", payload.slice(:event_type, :data, :version, :event_id, :override_payload)
65
65
  end
66
66
 
67
67
  def create_subscription_message(subscription_uuid, payload = {})
68
- post_response "/subscriptions/#{subscription_uuid}/messages", payload.slice(:event_type, :data, :version, :event_id)
68
+ post_response "/subscriptions/#{subscription_uuid}/messages", payload.slice(:event_type, :data, :version, :event_id, :override_payload)
69
69
  end
70
70
 
71
71
  def create_endpoint_message(subscription_uuid, endpoint_uuid, payload = {})
72
- post_response "/subscriptions/#{subscription_uuid}/endpoints/#{endpoint_uuid}/messages", payload.slice(:event_type, :data, :version, :event_id)
72
+ post_response "/subscriptions/#{subscription_uuid}/endpoints/#{endpoint_uuid}/messages", payload.slice(:event_type, :data, :version, :event_id, :override_payload)
73
+ end
74
+
75
+ # Webhook Attempts
76
+
77
+ def get_webhook_attempt(app_uuid, webhook_attempt_uuid)
78
+ get_response("/apps/#{app_uuid}/webhook_attempts/#{webhook_attempt_uuid}")
79
+ end
80
+
81
+ def list_webhook_attempts(app_uuid, params = {})
82
+ get_response("/apps/#{app_uuid}/webhook_attempts", params.slice(:page, :per_page, :offset))
73
83
  end
74
84
 
75
85
  private
76
86
 
77
- HOSTEDHOOKS_API_ENDPOINT = "https://hostedhooks.com/api/v1"
87
+ # HOSTEDHOOKS_API_ENDPOINT = "https://hostedhooks.com/api/v1"
88
+ HOSTEDHOOKS_API_ENDPOINT = "http://localhost:7891/api/v1"
78
89
 
79
- def get_response(url)
80
- response = HTTParty.get("#{HOSTEDHOOKS_API_ENDPOINT}#{url}", timeout: 3, headers: { 'Authorization' => "Bearer #{@api_key}" })
90
+ def get_response(url, params=nil)
91
+ if params
92
+ pagination_query = "?#{params.to_query}"
93
+ end
94
+ response = HTTParty.get("#{HOSTEDHOOKS_API_ENDPOINT}#{url}#{pagination_query || ''}", timeout: 3, headers: { 'Authorization' => "Bearer #{@api_key}" })
81
95
  body = JSON.parse(response.body)
82
- return {"error" => body['message'], "code" => response.code} if response.code >= 400
96
+ return {"error" => body['error'], "code" => response.code} if response.code >= 400
83
97
  return body
84
98
  end
85
99
 
@@ -93,7 +107,7 @@ module HostedHooks
93
107
  }
94
108
  )
95
109
  body = JSON.parse(response.body)
96
- return {"error" => body['message'], "code" => response.code} if response.code >= 400
110
+ return {"error" => body['error'], "code" => response.code} if response.code >= 400
97
111
  return body
98
112
  end
99
113
 
@@ -107,7 +121,7 @@ module HostedHooks
107
121
  }
108
122
  )
109
123
  body = JSON.parse(response.body)
110
- return {"error" => body['message'], "code" => response.code} if response.code >= 400
124
+ return {"error" => body['error'], "code" => response.code} if response.code >= 400
111
125
  return body
112
126
  end
113
127
 
@@ -1,3 +1,3 @@
1
1
  module HostedHooks
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hostedhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Grabill
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty