hostedhooks 0.1.0 → 0.3.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: f6053d809a77d73f584f112c4064ebd1df468ab161489152f0561b4bcd60bcd5
4
+ data.tar.gz: 690263c92f20b52f3e39a8e1572b589be019c9faa323d4c5666448acbdc9e0c7
5
5
  SHA512:
6
- metadata.gz: 38a3988a0930be8cf7a1e17828e393a20086e13e5b90b57663dccd8a350909c6e70570664f9b58cf540c6ec18a7ddeb2f9909a4f8b57a306dd8fd81646f769af
7
- data.tar.gz: 9a4270c7d3a75b704e5681e61bc3258d7105a49d037d2b3a4e35e4474bf6492d876b4683f13ff643f89e42cb1f202806a6c261565ebab0fed878a3134f3cfbc7
6
+ metadata.gz: 4be889cf06a7c80b75605cad00b8b61ff16f84fddcb133fcd019a2c0860757b6cf5b244434d725d1f5a5654efe6e2327e4d3f75490edef11feb846a645ea1f13
7
+ data.tar.gz: 0251c4bce5cefcb38e47903b081b7bda063a546a64074e575df7291dbde0fdf28cf8d95fd55e23fc97fa81784d94e2cf3aaaba3b5a5bc407c85d28c9c879245c
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
 
@@ -30,10 +30,8 @@ Initialize the gem with your API key [found here](https://www.hostedhooks.com/se
30
30
 
31
31
  client.get_endpoint("endpoint_uuid")
32
32
 
33
-
34
33
  ### Get a collection of records
35
34
 
36
-
37
35
  client.list_subscriptions("app_uuid")
38
36
 
39
37
  ### Create a record
@@ -46,19 +44,21 @@ Initialize the gem with your API key [found here](https://www.hostedhooks.com/se
46
44
 
47
45
 
48
46
  ## Resources
49
-
50
- * Apps
51
- * Subscriptions
52
- * Endpoints
53
- * Webhook Events
54
- * Messages
47
+ * [Apps](https://developer.hostedhooks.com/#apps)
48
+ * [Subscriptions](https://developer.hostedhooks.com/#subscriptions)
49
+ * [Endpoints](https://developer.hostedhooks.com/#endpoints)
50
+ * [Webhook Events](https://developer.hostedhooks.com/#webhook-events)
51
+ * [Messages](https://developer.hostedhooks.com/#messages)
52
+ * [Webhook Attempts](https://developer.hostedhooks.com/#webhook-attempts)
55
53
 
56
54
 
57
55
  ## Contributing
58
56
 
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
-
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/HostedHooks/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).
61
58
 
62
59
  ## Code of Conduct
63
60
 
64
61
  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).
62
+
63
+ ## License
64
+ 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,63 @@ 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
87
  HOSTEDHOOKS_API_ENDPOINT = "https://hostedhooks.com/api/v1"
78
88
 
79
- def get_response(url)
80
- response = HTTParty.get("#{HOSTEDHOOKS_API_ENDPOINT}#{url}", timeout: 3, headers: { 'Authorization' => "Bearer #{@api_key}" })
89
+ def get_response(url, params=nil)
90
+ if params
91
+ pagination_query = "?#{params.to_query}"
92
+ end
93
+ response = HTTParty.get("#{HOSTEDHOOKS_API_ENDPOINT}#{url}#{pagination_query || ''}", timeout: 3, headers: { 'Authorization' => "Bearer #{@api_key}" })
81
94
  body = JSON.parse(response.body)
82
- return {"error" => body['message'], "code" => response.code} if response.code >= 400
95
+ return {"error" => body['error'], "code" => response.code} if response.code >= 400
83
96
  return body
84
97
  end
85
98
 
@@ -93,7 +106,7 @@ module HostedHooks
93
106
  }
94
107
  )
95
108
  body = JSON.parse(response.body)
96
- return {"error" => body['message'], "code" => response.code} if response.code >= 400
109
+ return {"error" => body['error'], "code" => response.code} if response.code >= 400
97
110
  return body
98
111
  end
99
112
 
@@ -107,7 +120,7 @@ module HostedHooks
107
120
  }
108
121
  )
109
122
  body = JSON.parse(response.body)
110
- return {"error" => body['message'], "code" => response.code} if response.code >= 400
123
+ return {"error" => body['error'], "code" => response.code} if response.code >= 400
111
124
  return body
112
125
  end
113
126
 
@@ -1,3 +1,3 @@
1
1
  module HostedHooks
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Grabill
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2023-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description:
27
+ description:
28
28
  email:
29
29
  - ian@hostedhooks.com
30
30
  executables: []
@@ -48,7 +48,7 @@ licenses:
48
48
  - MIT
49
49
  metadata:
50
50
  homepage_uri: https://github.com/HostedHooks/hostedhooks-ruby
51
- post_install_message:
51
+ post_install_message:
52
52
  rdoc_options: []
53
53
  require_paths:
54
54
  - lib
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubygems_version: 3.1.4
67
- signing_key:
67
+ signing_key:
68
68
  specification_version: 4
69
69
  summary: A ruby library for the HostedHooks API
70
70
  test_files: []