Class: Pago::V2026_04::Services::Webhooks

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/webhooks.rb,
sig/pago/v2026_04/generated.rbs

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Pago::Service

Instance Method Details

#create_webhook_endpoint(body: {}) ⇒ Models::WebhookEndpoint

Create a webhook endpoint.

Scopes: webhooks:write

Parameters:

Returns:

Raises:



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pago/v2026_04/services/webhooks.rb', line 48

def create_webhook_endpoint(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/webhooks/endpoints",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::WebhookEndpoint.from_json(data)
end

#delete_webhook_endpoint(id) ⇒ nil

Delete a webhook endpoint.

Scopes: webhooks:write

Parameters:

  • id (String)

    The webhook endpoint ID.

Returns:

  • (nil)

Raises:



91
92
93
94
95
96
97
98
99
100
# File 'lib/pago/v2026_04/services/webhooks.rb', line 91

def delete_webhook_endpoint(id)
  client.request(
    http_method: "DELETE",
    path: "/v1/webhooks/endpoints/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :none,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
end

#get_webhook_endpoint(id) ⇒ Models::WebhookEndpoint

Get a webhook endpoint by ID.

Scopes: webhooks:read webhooks:write

Parameters:

  • id (String)

    The webhook endpoint ID.

Returns:

Raises:



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/pago/v2026_04/services/webhooks.rb', line 70

def get_webhook_endpoint(id)
  data = client.request(
    http_method: "GET",
    path: "/v1/webhooks/endpoints/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::WebhookEndpoint.from_json(data)
end

#list_webhook_deliveries(endpoint_id: nil, start_timestamp: nil, end_timestamp: nil, succeeded: nil, query: nil, http_code_class: nil, event_type: nil, page: 1, limit: 10) ⇒ Models::ListResourceWebhookDelivery

List webhook deliveries.

Deliveries are all the attempts to deliver a webhook event to an endpoint.

Scopes: webhooks:read webhooks:write

Parameters:

  • endpoint_id (String, Array<String>, nil) (defaults to: nil)

    Filter by webhook endpoint ID.

  • start_timestamp (String, nil) (defaults to: nil)

    Filter deliveries after this timestamp.

  • end_timestamp (String, nil) (defaults to: nil)

    Filter deliveries before this timestamp.

  • succeeded (Boolean, nil) (defaults to: nil)

    Filter by delivery success status.

  • query (String, nil) (defaults to: nil)

    Query to filter webhook deliveries.

  • http_code_class (String, nil) (defaults to: nil)

    Filter by HTTP response code class (2xx, 3xx, 4xx, 5xx).

  • event_type (String, Array<String>, nil) (defaults to: nil)

    Filter by webhook event type.

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • endpoint_id: (Object) (defaults to: nil)
  • start_timestamp: (String, nil) (defaults to: nil)
  • end_timestamp: (String, nil) (defaults to: nil)
  • succeeded: (Boolean, nil) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • http_code_class: (Object) (defaults to: nil)
  • event_type: (Object) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)

Returns:

Raises:



164
165
166
167
168
169
170
171
172
173
174
# File 'lib/pago/v2026_04/services/webhooks.rb', line 164

def list_webhook_deliveries(endpoint_id: nil, start_timestamp: nil, end_timestamp: nil, succeeded: nil, query: nil, http_code_class: nil, event_type: nil, page: 1, limit: 10)
  data = client.request(
    http_method: "GET",
    path: "/v1/webhooks/deliveries",
    path_params: {},
    query: { "endpoint_id" => endpoint_id, "start_timestamp" => start_timestamp, "end_timestamp" => end_timestamp, "succeeded" => succeeded, "query" => query, "http_code_class" => http_code_class, "event_type" => event_type, "page" => page, "limit" => limit },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceWebhookDelivery.from_json(data)
end

#list_webhook_deliveries_each(endpoint_id: nil, start_timestamp: nil, end_timestamp: nil, succeeded: nil, query: nil, http_code_class: nil, event_type: nil, limit: 10) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list_webhook_deliveries, fetching pages on demand.

Parameters:

  • endpoint_id: (Object) (defaults to: nil)
  • start_timestamp: (String, nil) (defaults to: nil)
  • end_timestamp: (String, nil) (defaults to: nil)
  • succeeded: (Boolean, nil) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • http_code_class: (Object) (defaults to: nil)
  • event_type: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)

Yield Parameters:

Returns:



180
181
182
183
184
185
# File 'lib/pago/v2026_04/services/webhooks.rb', line 180

def list_webhook_deliveries_each(endpoint_id: nil, start_timestamp: nil, end_timestamp: nil, succeeded: nil, query: nil, http_code_class: nil, event_type: nil, limit: 10, &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list_webhook_deliveries(endpoint_id: endpoint_id, start_timestamp: start_timestamp, end_timestamp: end_timestamp, succeeded: succeeded, query: query, http_code_class: http_code_class, event_type: event_type, page: page_number, limit: limit)
  end
  block ? paginator.each(&block) : paginator
end

#list_webhook_endpoints(organization_id: nil, page: 1, limit: 10) ⇒ Models::ListResourceWebhookEndpoint

List webhook endpoints.

Scopes: webhooks:read webhooks:write

Parameters:

  • organization_id (String, Array<String>, nil) (defaults to: nil)

    Filter by organization ID.

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • organization_id: (Object) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)

Returns:

Raises:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pago/v2026_04/services/webhooks.rb', line 17

def list_webhook_endpoints(organization_id: nil, page: 1, limit: 10)
  data = client.request(
    http_method: "GET",
    path: "/v1/webhooks/endpoints",
    path_params: {},
    query: { "organization_id" => organization_id, "page" => page, "limit" => limit },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceWebhookEndpoint.from_json(data)
end

#list_webhook_endpoints_each(organization_id: nil, limit: 10) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list_webhook_endpoints, fetching pages on demand.

Parameters:

  • organization_id: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)

Yield Parameters:

Returns:



33
34
35
36
37
38
# File 'lib/pago/v2026_04/services/webhooks.rb', line 33

def list_webhook_endpoints_each(organization_id: nil, limit: 10, &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list_webhook_endpoints(organization_id: organization_id, page: page_number, limit: limit)
  end
  block ? paginator.each(&block) : paginator
end

#redeliver_webhook_event(id) ⇒ Object

Schedule the re-delivery of a webhook event.

Scopes: webhooks:write

Parameters:

  • id (String)

    The webhook event ID.

Returns:

  • (Object)

Raises:



196
197
198
199
200
201
202
203
204
205
206
# File 'lib/pago/v2026_04/services/webhooks.rb', line 196

def redeliver_webhook_event(id)
  data = client.request(
    http_method: "POST",
    path: "/v1/webhooks/events/{id}/redeliver",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  data
end

#reset_webhook_endpoint_secret(id) ⇒ Models::WebhookEndpoint

Regenerate a webhook endpoint secret.

Scopes: webhooks:write

Parameters:

  • id (String)

    The webhook endpoint ID.

Returns:

Raises:



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/pago/v2026_04/services/webhooks.rb', line 134

def reset_webhook_endpoint_secret(id)
  data = client.request(
    http_method: "PATCH",
    path: "/v1/webhooks/endpoints/{id}/secret",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::WebhookEndpoint.from_json(data)
end

#update_webhook_endpoint(id, body: {}) ⇒ Models::WebhookEndpoint

Update a webhook endpoint.

Scopes: webhooks:write

Parameters:

  • id (String)

    The webhook endpoint ID.

  • body (Hash, Models::WebhookEndpointUpdate) (defaults to: {})

    the request body.

  • body: (Object) (defaults to: {})

Returns:

Raises:



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/pago/v2026_04/services/webhooks.rb', line 112

def update_webhook_endpoint(id, body: {})
  data = client.request(
    http_method: "PATCH",
    path: "/v1/webhooks/endpoints/{id}",
    path_params: { "id" => id },
    query: {},
    body: body,
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Models::WebhookEndpoint.from_json(data)
end