Class: Uploadcare::Api::Rest::Webhooks
- Inherits:
-
Object
- Object
- Uploadcare::Api::Rest::Webhooks
- Defined in:
- lib/uploadcare/api/rest/webhooks.rb
Overview
REST API endpoint for webhook operations.
Instance Attribute Summary collapse
-
#rest ⇒ Uploadcare::Api::Rest
readonly
Parent REST client.
Instance Method Summary collapse
-
#create(options: {}, request_options: {}) ⇒ Uploadcare::Result
Create a new webhook.
-
#delete(target_url:, request_options: {}) ⇒ Uploadcare::Result
Delete a webhook by target URL.
-
#initialize(rest:) ⇒ Webhooks
constructor
A new instance of Webhooks.
-
#list(request_options: {}) ⇒ Uploadcare::Result
List all project webhooks.
-
#update(id:, options: {}, request_options: {}) ⇒ Uploadcare::Result
Update a webhook.
Constructor Details
#initialize(rest:) ⇒ Webhooks
Returns a new instance of Webhooks.
11 12 13 |
# File 'lib/uploadcare/api/rest/webhooks.rb', line 11 def initialize(rest:) @rest = rest end |
Instance Attribute Details
#rest ⇒ Uploadcare::Api::Rest (readonly)
Returns Parent REST client.
8 9 10 |
# File 'lib/uploadcare/api/rest/webhooks.rb', line 8 def rest @rest end |
Instance Method Details
#create(options: {}, request_options: {}) ⇒ Uploadcare::Result
Create a new webhook.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/uploadcare/api/rest/webhooks.rb', line 35 def create(options: {}, request_options: {}) payload = { target_url: [:target_url], event: [:event] || 'file.uploaded', is_active: [:is_active].nil? || [:is_active] } payload.merge!({ signing_secret: [:signing_secret] }.compact) payload.merge!({ version: [:version] }.compact) rest.post(path: '/webhooks/', params: payload, headers: {}, request_options: ) end |
#delete(target_url:, request_options: {}) ⇒ Uploadcare::Result
Delete a webhook by target URL.
69 70 71 72 73 |
# File 'lib/uploadcare/api/rest/webhooks.rb', line 69 def delete(target_url:, request_options: {}) payload = { target_url: target_url } rest.request(method: :delete, path: '/webhooks/unsubscribe/', params: payload, headers: {}, request_options: ) end |
#list(request_options: {}) ⇒ Uploadcare::Result
List all project webhooks.
20 21 22 |
# File 'lib/uploadcare/api/rest/webhooks.rb', line 20 def list(request_options: {}) rest.get(path: '/webhooks/', params: {}, headers: {}, request_options: ) end |
#update(id:, options: {}, request_options: {}) ⇒ Uploadcare::Result
Update a webhook.
59 60 61 |
# File 'lib/uploadcare/api/rest/webhooks.rb', line 59 def update(id:, options: {}, request_options: {}) rest.put(path: "/webhooks/#{id}/", params: , headers: {}, request_options: ) end |