Class: Yoomoney::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/yoomoney/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:



74
75
76
# File 'lib/yoomoney/resources/webhooks.rb', line 74

def initialize(client:)
  @client = client
end

Instance Method Details

#create(event:, url:, idempotence_key:, request_options: {}) ⇒ Yoomoney::Models::Webhook

Создание webhook

Parameters:

Returns:

See Also:



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/yoomoney/resources/webhooks.rb', line 21

def create(params)
  parsed, options = Yoomoney::WebhookCreateParams.dump_request(params)
  header_params = {idempotence_key: "idempotence-key"}
  @client.request(
    method: :post,
    path: "webhooks",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Yoomoney::Webhook,
    options: options
  )
end

#delete(webhook_id, request_options: {}) ⇒ Object

Удаление webhook

Parameters:

Returns:

  • (Object)

See Also:



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

def delete(webhook_id, params = {})
  @client.request(
    method: :delete,
    path: ["webhooks/%1$s", webhook_id],
    model: Yoomoney::Internal::Type::Unknown,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ Yoomoney::Models::WebhookListResponse

Список webhook

Parameters:

Returns:

See Also:



43
44
45
46
47
48
49
50
# File 'lib/yoomoney/resources/webhooks.rb', line 43

def list(params = {})
  @client.request(
    method: :get,
    path: "webhooks",
    model: Yoomoney::Models::WebhookListResponse,
    options: params[:request_options]
  )
end