Class: CDEKApiClient::API::Webhook
- Inherits:
-
Object
- Object
- CDEKApiClient::API::Webhook
- Defined in:
- lib/cdek_api_client/api/webhook.rb
Overview
Handles webhook-related API requests.
Instance Method Summary collapse
-
#delete(webhook_uuid) ⇒ Hash
Deletes a webhook by its UUID.
-
#get(webhook_uuid) ⇒ Hash
Retrieves information about a specific webhook by its UUID.
-
#initialize(client) ⇒ Webhook
constructor
Initializes the Webhook object.
-
#list ⇒ Array<Hash>
Retrieves a list of registered webhooks.
-
#list_all ⇒ Array<Hash>
Retrieves a list of all registered webhooks.
-
#register(webhook_data) ⇒ Hash
Registers a new webhook.
-
#register_simple(url, event_types, type: 'WEBHOOK') ⇒ Hash
Registers a new webhook with simple parameters.
Constructor Details
#initialize(client) ⇒ Webhook
Initializes the Webhook object.
10 11 12 |
# File 'lib/cdek_api_client/api/webhook.rb', line 10 def initialize(client) @client = client end |
Instance Method Details
#delete(webhook_uuid) ⇒ Hash
Deletes a webhook by its UUID.
67 68 69 70 |
# File 'lib/cdek_api_client/api/webhook.rb', line 67 def delete(webhook_uuid) response = @client.request('delete', "webhooks/#{webhook_uuid}") @client.send(:handle_response, response) end |
#get(webhook_uuid) ⇒ Hash
Retrieves information about a specific webhook by its UUID.
58 59 60 61 |
# File 'lib/cdek_api_client/api/webhook.rb', line 58 def get(webhook_uuid) response = @client.request('get', "webhooks/#{webhook_uuid}") @client.send(:handle_response, response) end |
#list ⇒ Array<Hash>
Retrieves a list of registered webhooks.
41 42 43 44 |
# File 'lib/cdek_api_client/api/webhook.rb', line 41 def list response = @client.request('get', 'webhooks') @client.send(:handle_response, response) end |
#list_all ⇒ Array<Hash>
Retrieves a list of all registered webhooks.
49 50 51 52 |
# File 'lib/cdek_api_client/api/webhook.rb', line 49 def list_all response = @client.request('get', 'webhooks') @client.send(:handle_response, response) end |
#register(webhook_data) ⇒ Hash
Registers a new webhook.
18 19 20 21 |
# File 'lib/cdek_api_client/api/webhook.rb', line 18 def register(webhook_data) response = @client.request('post', 'webhooks', body: webhook_data) @client.send(:handle_response, response) end |
#register_simple(url, event_types, type: 'WEBHOOK') ⇒ Hash
Registers a new webhook with simple parameters.
29 30 31 32 33 34 35 36 |
# File 'lib/cdek_api_client/api/webhook.rb', line 29 def register_simple(url, event_types, type: 'WEBHOOK') webhook_data = CDEKApiClient::Entities::Webhook.new( url: url, type: type, event_types: event_types ) register(webhook_data) end |