Class: Apertur::Resources::Webhooks
- Inherits:
-
Object
- Object
- Apertur::Resources::Webhooks
- Defined in:
- lib/apertur/resources/webhooks.rb
Overview
Manage event webhooks within a project.
Instance Method Summary collapse
-
#create(project_id, **config) ⇒ Hash
Create a new webhook.
-
#delete(project_id, webhook_id) ⇒ nil
Delete a webhook.
-
#deliveries(project_id, webhook_id, **options) ⇒ Hash
List delivery attempts for a webhook.
-
#initialize(http) ⇒ Webhooks
constructor
A new instance of Webhooks.
-
#list(project_id) ⇒ Array<Hash>
List all webhooks for a project.
-
#retry_delivery(project_id, webhook_id, delivery_id) ⇒ Hash
Retry a failed delivery attempt.
-
#test(project_id, webhook_id) ⇒ Hash
Send a test event to a webhook.
-
#update(project_id, webhook_id, **config) ⇒ Hash
Update an existing webhook.
Constructor Details
#initialize(http) ⇒ Webhooks
Returns a new instance of Webhooks.
8 9 10 |
# File 'lib/apertur/resources/webhooks.rb', line 8 def initialize(http) @http = http end |
Instance Method Details
#create(project_id, **config) ⇒ Hash
Create a new webhook.
25 26 27 |
# File 'lib/apertur/resources/webhooks.rb', line 25 def create(project_id, **config) @http.request(:post, "/api/v1/projects/#{project_id}/webhooks", body: config) end |
#delete(project_id, webhook_id) ⇒ nil
Delete a webhook.
44 45 46 |
# File 'lib/apertur/resources/webhooks.rb', line 44 def delete(project_id, webhook_id) @http.request(:delete, "/api/v1/projects/#{project_id}/webhooks/#{webhook_id}") end |
#deliveries(project_id, webhook_id, **options) ⇒ Hash
List delivery attempts for a webhook.
64 65 66 67 68 69 |
# File 'lib/apertur/resources/webhooks.rb', line 64 def deliveries(project_id, webhook_id, **) query = {} query["page"] = [:page].to_s if [:page] query["limit"] = [:limit].to_s if [:limit] @http.request(:get, "/api/v1/projects/#{project_id}/webhooks/#{webhook_id}/deliveries", query: query) end |
#list(project_id) ⇒ Array<Hash>
List all webhooks for a project.
16 17 18 |
# File 'lib/apertur/resources/webhooks.rb', line 16 def list(project_id) @http.request(:get, "/api/v1/projects/#{project_id}/webhooks") end |
#retry_delivery(project_id, webhook_id, delivery_id) ⇒ Hash
Retry a failed delivery attempt.
77 78 79 80 81 82 |
# File 'lib/apertur/resources/webhooks.rb', line 77 def retry_delivery(project_id, webhook_id, delivery_id) @http.request( :post, "/api/v1/projects/#{project_id}/webhooks/#{webhook_id}/deliveries/#{delivery_id}/retry" ) end |
#test(project_id, webhook_id) ⇒ Hash
Send a test event to a webhook.
53 54 55 |
# File 'lib/apertur/resources/webhooks.rb', line 53 def test(project_id, webhook_id) @http.request(:post, "/api/v1/projects/#{project_id}/webhooks/#{webhook_id}/test") end |
#update(project_id, webhook_id, **config) ⇒ Hash
Update an existing webhook.
35 36 37 |
# File 'lib/apertur/resources/webhooks.rb', line 35 def update(project_id, webhook_id, **config) @http.request(:patch, "/api/v1/projects/#{project_id}/webhooks/#{webhook_id}", body: config) end |