Class: Amocrm::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/amocrm/resources/webhooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Webhooks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Webhooks.

Parameters:



75
76
77
# File 'lib/amocrm/resources/webhooks.rb', line 75

def initialize(client:)
  @client = client
end

Instance Method Details

#list(filter: nil, request_options: {}) ⇒ Amocrm::Models::WebhookListResponse::WebhookListResponse, Amocrm::Models::WebhookListResponse::Problem

Get webhooks list.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/amocrm/resources/webhooks.rb', line 16

def list(params = {})
  parsed, options = Amocrm::WebhookListParams.dump_request(params)
  query = Amocrm::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v4/webhooks",
    query: query,
    model: Amocrm::Models::WebhookListResponse,
    options: options
  )
end

#subscribe(destination:, settings:, sort: nil, request_options: {}) ⇒ Amocrm::Models::WebhookSubscribeResponse::Webhook, Amocrm::Models::WebhookSubscribeResponse::Problem

Subscribe to webhook events.

Parameters:

  • destination (String)
  • settings (Array<String>)
  • sort (Integer)
  • request_options (Amocrm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



40
41
42
43
44
45
46
47
48
49
# File 'lib/amocrm/resources/webhooks.rb', line 40

def subscribe(params)
  parsed, options = Amocrm::WebhookSubscribeParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v4/webhooks",
    body: parsed,
    model: Amocrm::Models::WebhookSubscribeResponse,
    options: options
  )
end

#unsubscribe(destination:, request_options: {}) ⇒ Amocrm::Models::WebhookUnsubscribeResponse::EmptyResponse, Amocrm::Models::WebhookUnsubscribeResponse::Problem

Unsubscribe webhook by destination.



61
62
63
64
65
66
67
68
69
70
# File 'lib/amocrm/resources/webhooks.rb', line 61

def unsubscribe(params)
  parsed, options = Amocrm::WebhookUnsubscribeParams.dump_request(params)
  @client.request(
    method: :delete,
    path: "api/v4/webhooks",
    body: parsed,
    model: Amocrm::Models::WebhookUnsubscribeResponse,
    options: options
  )
end