Class: Yookassa::Resources::Webhook
- Defined in:
- lib/yookassa/resources/webhook.rb
Overview
REST resource for the /v3/webhooks endpoint.
Unlike other resources, webhooks support create, list, and delete
but not find (individual lookup is not available in the API).
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(params, idempotency_key: nil) ⇒ Entities::WebhookObj
Registers a new webhook subscription.
-
#delete(webhook_id) ⇒ true
Deletes a webhook subscription.
-
#list ⇒ Entities::Collection<Entities::WebhookObj>
Lists all registered webhook subscriptions.
Methods inherited from Base
entity_class, #find, #initialize, resource_path
Constructor Details
This class inherits a constructor from Yookassa::Resources::Base
Instance Method Details
#create(params, idempotency_key: nil) ⇒ Entities::WebhookObj
Registers a new webhook subscription.
18 19 20 21 |
# File 'lib/yookassa/resources/webhook.rb', line 18 def create(params, idempotency_key: nil) data = request(:post, "webhooks", body: params, idempotency_key: idempotency_key) Entities::WebhookObj.new(data) end |
#delete(webhook_id) ⇒ true
Deletes a webhook subscription.
39 40 41 42 |
# File 'lib/yookassa/resources/webhook.rb', line 39 def delete(webhook_id) request(:delete, "webhooks/#{webhook_id}") true end |
#list ⇒ Entities::Collection<Entities::WebhookObj>
Lists all registered webhook subscriptions.
26 27 28 29 30 31 32 |
# File 'lib/yookassa/resources/webhook.rb', line 26 def list data = request(:get, "webhooks") Entities::Collection.new( items: data["items"] || [], entity_class: Entities::WebhookObj ) end |