Class: Uploadcare::Resources::Webhook
- Inherits:
-
BaseResource
- Object
- BaseResource
- Uploadcare::Resources::Webhook
- Defined in:
- lib/uploadcare/resources/webhook.rb
Overview
Webhook resource for managing Uploadcare webhooks.
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#event ⇒ Object
Returns the value of attribute event.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_active ⇒ Object
Returns the value of attribute is_active.
-
#project ⇒ Object
Returns the value of attribute project.
-
#signing_secret ⇒ Object
Returns the value of attribute signing_secret.
-
#target_url ⇒ Object
Returns the value of attribute target_url.
-
#updated ⇒ Object
Returns the value of attribute updated.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.create(target_url:, client: nil, config: Uploadcare.configuration, request_options: {}, **options) ⇒ Uploadcare::Resources::Webhook
Create a new webhook.
-
.delete(target_url:, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ nil
(also: unsubscribe)
Delete a webhook by target URL.
-
.list(client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Array<Uploadcare::Resources::Webhook>
List all project webhooks.
-
.update(id:, client: nil, config: Uploadcare.configuration, request_options: {}, **options) ⇒ Uploadcare::Resources::Webhook
Update a webhook.
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def created @created end |
#event ⇒ Object
Returns the value of attribute event.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def event @event end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def id @id end |
#is_active ⇒ Object
Returns the value of attribute is_active.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def is_active @is_active end |
#project ⇒ Object
Returns the value of attribute project.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def project @project end |
#signing_secret ⇒ Object
Returns the value of attribute signing_secret.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def signing_secret @signing_secret end |
#target_url ⇒ Object
Returns the value of attribute target_url.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def target_url @target_url end |
#updated ⇒ Object
Returns the value of attribute updated.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def updated @updated end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/uploadcare/resources/webhook.rb', line 7 def version @version end |
Class Method Details
.create(target_url:, client: nil, config: Uploadcare.configuration, request_options: {}, **options) ⇒ Uploadcare::Resources::Webhook
Create a new webhook.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/uploadcare/resources/webhook.rb', line 35 def self.create(target_url:, client: nil, config: Uploadcare.configuration, request_options: {}, **) resolved_client = resolve_client(client: client, config: config) event = .fetch(:event, 'file.uploaded') is_active = .key?(:is_active) ? [:is_active] : true payload = { target_url: target_url, event: event, is_active: is_active } payload[:signing_secret] = [:signing_secret] if [:signing_secret] payload[:version] = [:version] if [:version] response = Uploadcare::Result.unwrap( resolved_client.api.rest.webhooks.create(options: payload, request_options: ) ) new(response, resolved_client) end |
.delete(target_url:, client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ nil Also known as: unsubscribe
Delete a webhook by target URL.
75 76 77 78 79 80 |
# File 'lib/uploadcare/resources/webhook.rb', line 75 def self.delete(target_url:, client: nil, config: Uploadcare.configuration, request_options: {}) resolved_client = resolve_client(client: client, config: config) Uploadcare::Result.unwrap( resolved_client.api.rest.webhooks.delete(target_url: target_url, request_options: ) ) end |
.list(client: nil, config: Uploadcare.configuration, request_options: {}) ⇒ Array<Uploadcare::Resources::Webhook>
List all project webhooks.
15 16 17 18 19 20 21 |
# File 'lib/uploadcare/resources/webhook.rb', line 15 def self.list(client: nil, config: Uploadcare.configuration, request_options: {}) resolved_client = resolve_client(client: client, config: config) response = Uploadcare::Result.unwrap( resolved_client.api.rest.webhooks.list(request_options: ) ) response.map { |data| new(data, resolved_client) } end |
.update(id:, client: nil, config: Uploadcare.configuration, request_options: {}, **options) ⇒ Uploadcare::Resources::Webhook
Update a webhook.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/uploadcare/resources/webhook.rb', line 57 def self.update(id:, client: nil, config: Uploadcare.configuration, request_options: {}, **) resolved_client = resolve_client(client: client, config: config) payload = .slice(:target_url, :event, :signing_secret, :version) payload[:is_active] = [:is_active] if .key?(:is_active) response = Uploadcare::Result.unwrap( resolved_client.api.rest.webhooks.update(id: id, options: payload, request_options: ) ) new(response, resolved_client) end |