Class: Uploadcare::Client::WebhookClient
- Inherits:
-
RestClient
- Object
- ApiStruct::Client
- RestClient
- Uploadcare::Client::WebhookClient
- Defined in:
- lib/uploadcare/client/webhook_client.rb
Overview
client for webhook management
Instance Method Summary collapse
-
#create(options = {}) ⇒ Object
(also: #create_webhook)
Create webhook.
-
#delete(target_url) ⇒ Object
(also: #delete_webhook)
Permanently deletes subscription.
-
#list ⇒ Object
(also: #list_webhooks)
Returns array (not paginated list) of webhooks.
-
#update(id, options = {}) ⇒ Object
(also: #update_webhook)
Updates webhook.
Methods inherited from RestClient
#api_root, #api_struct_delete, #api_struct_get, #api_struct_post, #api_struct_put, #get, #headers, #post, #put, #request
Methods included from Uploadcare::Concerns::ThrottleHandler
Methods included from Uploadcare::Concerns::ErrorHandler
Instance Method Details
#create(options = {}) ⇒ Object Also known as: create_webhook
Create webhook
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/uploadcare/client/webhook_client.rb', line 12 def create( = {}) body = { target_url: [:target_url], event: [:event] || 'file.uploaded', is_active: [:is_active].nil? ? true : [:is_active] }.merge( { signing_secret: [:signing_secret] }.compact ).to_json post(uri: '/webhooks/', content: body) end |
#delete(target_url) ⇒ Object Also known as: delete_webhook
Permanently deletes subscription
31 32 33 34 |
# File 'lib/uploadcare/client/webhook_client.rb', line 31 def delete(target_url) body = { target_url: target_url }.to_json request(method: 'DELETE', uri: '/webhooks/unsubscribe/', content: body) end |
#list ⇒ Object Also known as: list_webhooks
Returns array (not paginated list) of webhooks
25 26 27 |
# File 'lib/uploadcare/client/webhook_client.rb', line 25 def list get(uri: '/webhooks/') end |
#update(id, options = {}) ⇒ Object Also known as: update_webhook
Updates webhook
38 39 40 41 |
# File 'lib/uploadcare/client/webhook_client.rb', line 38 def update(id, = {}) body = .to_json put(uri: "/webhooks/#{id}/", content: body) end |