Class: CDEKApiClient::API::Webhook

Inherits:
Object
  • Object
show all
Defined in:
lib/cdek_api_client/api/webhook.rb

Overview

Handles webhook-related API requests.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Webhook

Initializes the Webhook object.

Parameters:



10
11
12
# File 'lib/cdek_api_client/api/webhook.rb', line 10

def initialize(client)
  @client = client
end

Instance Method Details

#delete(webhook_id) ⇒ Hash

Deletes a webhook by its ID.

Parameters:

  • webhook_id (String)

    the ID of the webhook to delete.

Returns:

  • (Hash)

    the response from the API.



35
36
37
38
# File 'lib/cdek_api_client/api/webhook.rb', line 35

def delete(webhook_id)
  response = @client.request('delete', "webhooks/#{webhook_id}")
  @client.send(:handle_response, response)
end

#listArray<Hash>

Retrieves a list of registered webhooks.

Returns:

  • (Array<Hash>)

    the list of webhooks.



26
27
28
29
# File 'lib/cdek_api_client/api/webhook.rb', line 26

def list
  response = @client.request('get', 'webhooks')
  @client.send(:handle_response, response)
end

#register(webhook_data) ⇒ Hash

Registers a new webhook.

Parameters:

Returns:

  • (Hash)

    the response from the API.



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