pago-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +131 -0
- data/lib/pago/base_client.rb +116 -0
- data/lib/pago/errors.rb +83 -0
- data/lib/pago/http.rb +78 -0
- data/lib/pago/model.rb +86 -0
- data/lib/pago/paginator.rb +67 -0
- data/lib/pago/serde.rb +186 -0
- data/lib/pago/service.rb +17 -0
- data/lib/pago/v2026_04/client.rb +124 -0
- data/lib/pago/v2026_04/enums.rb +4552 -0
- data/lib/pago/v2026_04/errors.rb +1121 -0
- data/lib/pago/v2026_04/models.rb +46344 -0
- data/lib/pago/v2026_04/services/benefit_grants.rb +48 -0
- data/lib/pago/v2026_04/services/benefits.rb +179 -0
- data/lib/pago/v2026_04/services/checkout_links.rb +131 -0
- data/lib/pago/v2026_04/services/checkouts.rb +185 -0
- data/lib/pago/v2026_04/services/custom_fields.rb +132 -0
- data/lib/pago/v2026_04/services/customer_meters.rb +69 -0
- data/lib/pago/v2026_04/services/customer_portal.rb +1181 -0
- data/lib/pago/v2026_04/services/customer_seats.rb +137 -0
- data/lib/pago/v2026_04/services/customer_sessions.rb +35 -0
- data/lib/pago/v2026_04/services/customers.rb +556 -0
- data/lib/pago/v2026_04/services/discounts.rb +131 -0
- data/lib/pago/v2026_04/services/disputes.rb +93 -0
- data/lib/pago/v2026_04/services/event_types.rb +74 -0
- data/lib/pago/v2026_04/services/events.rb +126 -0
- data/lib/pago/v2026_04/services/files.rb +135 -0
- data/lib/pago/v2026_04/services/license_keys.rb +183 -0
- data/lib/pago/v2026_04/services/members.rb +47 -0
- data/lib/pago/v2026_04/services/meters.rb +142 -0
- data/lib/pago/v2026_04/services/metrics.rb +188 -0
- data/lib/pago/v2026_04/services/oauth2.rb +175 -0
- data/lib/pago/v2026_04/services/orders.rb +238 -0
- data/lib/pago/v2026_04/services/organizations.rb +113 -0
- data/lib/pago/v2026_04/services/payments.rb +72 -0
- data/lib/pago/v2026_04/services/products.rb +142 -0
- data/lib/pago/v2026_04/services/refunds.rb +73 -0
- data/lib/pago/v2026_04/services/subscriptions.rb +171 -0
- data/lib/pago/v2026_04/services/webhooks.rb +212 -0
- data/lib/pago/v2026_04/unions.rb +739 -0
- data/lib/pago/v2026_04/webhooks.rb +86 -0
- data/lib/pago/version.rb +5 -0
- data/lib/pago/webhooks.rb +159 -0
- data/lib/pago.rb +39 -0
- data/sig/pago/v2026_04/generated.rbs +12401 -0
- data/sig/pago.rbs +204 -0
- metadata +91 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Subscriptions < ::Pago::Service
|
|
7
|
+
# List subscriptions.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `subscriptions:read` `subscriptions:write`
|
|
10
|
+
#
|
|
11
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
12
|
+
# @param product_id [String, Array<String>, nil] Filter by product ID.
|
|
13
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
14
|
+
# @param external_customer_id [String, Array<String>, nil] Filter by customer external ID.
|
|
15
|
+
# @param discount_id [String, Array<String>, nil] Filter by discount ID.
|
|
16
|
+
# @param active [Boolean, nil] Filter by active or inactive subscription.
|
|
17
|
+
# @param status [String, Array<String>, nil] Filter by subscription status.
|
|
18
|
+
# @param cancel_at_period_end [Boolean, nil] Filter by subscriptions that are set to cancel at period end.
|
|
19
|
+
# @param customer_cancellation_reason [String, Array<String>, nil] Filter by customer cancellation reason.
|
|
20
|
+
# @param canceled_at_after [String, nil] Filter by cancellation date (after or equal to).
|
|
21
|
+
# @param canceled_at_before [String, nil] Filter by cancellation date (before or equal to).
|
|
22
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
23
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
24
|
+
# @param sorting [Array<String>, nil] Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign `-` before the criteria name to sort by descending order.
|
|
25
|
+
# @param metadata [Object] Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.
|
|
26
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
27
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
28
|
+
# @return [Models::ListResourceSubscription]
|
|
29
|
+
def list(organization_id: nil, product_id: nil, customer_id: nil, external_customer_id: nil, discount_id: nil, active: nil, status: nil, cancel_at_period_end: nil, customer_cancellation_reason: nil, canceled_at_after: nil, canceled_at_before: nil, page: 1, limit: 10, sorting: ["-started_at"], metadata: nil)
|
|
30
|
+
data = client.request(
|
|
31
|
+
http_method: "GET",
|
|
32
|
+
path: "/v1/subscriptions/",
|
|
33
|
+
path_params: {},
|
|
34
|
+
query: { "organization_id" => organization_id, "product_id" => product_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "discount_id" => discount_id, "active" => active, "status" => status, "cancel_at_period_end" => cancel_at_period_end, "customer_cancellation_reason" => customer_cancellation_reason, "canceled_at_after" => canceled_at_after, "canceled_at_before" => canceled_at_before, "page" => page, "limit" => limit, "sorting" => sorting, "metadata" => metadata },
|
|
35
|
+
response_type: :json,
|
|
36
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
37
|
+
)
|
|
38
|
+
Models::ListResourceSubscription.from_json(data)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
42
|
+
#
|
|
43
|
+
# @yieldparam item [Models::Subscription]
|
|
44
|
+
# @return [Pago::Paginator] when called without a block.
|
|
45
|
+
def list_each(organization_id: nil, product_id: nil, customer_id: nil, external_customer_id: nil, discount_id: nil, active: nil, status: nil, cancel_at_period_end: nil, customer_cancellation_reason: nil, canceled_at_after: nil, canceled_at_before: nil, limit: 10, sorting: ["-started_at"], metadata: nil, &block)
|
|
46
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
47
|
+
list(organization_id: organization_id, product_id: product_id, customer_id: customer_id, external_customer_id: external_customer_id, discount_id: discount_id, active: active, status: status, cancel_at_period_end: cancel_at_period_end, customer_cancellation_reason: customer_cancellation_reason, canceled_at_after: canceled_at_after, canceled_at_before: canceled_at_before, page: page_number, limit: limit, sorting: sorting, metadata: metadata)
|
|
48
|
+
end
|
|
49
|
+
block ? paginator.each(&block) : paginator
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Create a subscription programmatically.
|
|
53
|
+
#
|
|
54
|
+
# This endpoint only allows to create subscription on free products.
|
|
55
|
+
# For paid products, use the checkout flow.
|
|
56
|
+
#
|
|
57
|
+
# No initial order will be created and no confirmation email will be sent.
|
|
58
|
+
#
|
|
59
|
+
# **Scopes**: `subscriptions:write`
|
|
60
|
+
#
|
|
61
|
+
# @param body [Hash, Models::SubscriptionCreateCustomer, Models::SubscriptionCreateExternalCustomer] the request body.
|
|
62
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
63
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
64
|
+
# @return [Models::Subscription]
|
|
65
|
+
def create(body: {})
|
|
66
|
+
data = client.request(
|
|
67
|
+
http_method: "POST",
|
|
68
|
+
path: "/v1/subscriptions/",
|
|
69
|
+
path_params: {},
|
|
70
|
+
query: {},
|
|
71
|
+
body: body,
|
|
72
|
+
response_type: :json,
|
|
73
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
74
|
+
)
|
|
75
|
+
Models::Subscription.from_json(data)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Export subscriptions as a CSV file.
|
|
79
|
+
#
|
|
80
|
+
# **Scopes**: `subscriptions:read` `subscriptions:write`
|
|
81
|
+
#
|
|
82
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
83
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
84
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
85
|
+
# @return [String]
|
|
86
|
+
def export(organization_id: nil)
|
|
87
|
+
client.request(
|
|
88
|
+
http_method: "GET",
|
|
89
|
+
path: "/v1/subscriptions/export",
|
|
90
|
+
path_params: {},
|
|
91
|
+
query: { "organization_id" => organization_id },
|
|
92
|
+
response_type: :text,
|
|
93
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
94
|
+
)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Get a subscription by ID.
|
|
98
|
+
#
|
|
99
|
+
# **Scopes**: `subscriptions:read` `subscriptions:write`
|
|
100
|
+
#
|
|
101
|
+
# @param id [String] The subscription ID.
|
|
102
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
103
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
104
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
105
|
+
# @return [Models::Subscription]
|
|
106
|
+
def get(id)
|
|
107
|
+
data = client.request(
|
|
108
|
+
http_method: "GET",
|
|
109
|
+
path: "/v1/subscriptions/{id}",
|
|
110
|
+
path_params: { "id" => id },
|
|
111
|
+
query: {},
|
|
112
|
+
response_type: :json,
|
|
113
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
114
|
+
)
|
|
115
|
+
Models::Subscription.from_json(data)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Revoke a subscription, i.e cancel immediately.
|
|
119
|
+
#
|
|
120
|
+
# **Scopes**: `subscriptions:write`
|
|
121
|
+
#
|
|
122
|
+
# @param id [String] The subscription ID.
|
|
123
|
+
# @raise [Errors::AlreadyCanceledSubscription] on HTTP 403.
|
|
124
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
125
|
+
# @raise [Errors::SubscriptionLocked] on HTTP 409.
|
|
126
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
127
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
128
|
+
# @return [Models::Subscription]
|
|
129
|
+
def revoke(id)
|
|
130
|
+
data = client.request(
|
|
131
|
+
http_method: "DELETE",
|
|
132
|
+
path: "/v1/subscriptions/{id}",
|
|
133
|
+
path_params: { "id" => id },
|
|
134
|
+
query: {},
|
|
135
|
+
response_type: :json,
|
|
136
|
+
errors: { 403 => Errors::AlreadyCanceledSubscription, 404 => Errors::ResourceNotFound, 409 => Errors::SubscriptionLocked, 422 => Errors::HTTPValidationError }
|
|
137
|
+
)
|
|
138
|
+
Models::Subscription.from_json(data)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Update a subscription.
|
|
142
|
+
#
|
|
143
|
+
# **Scopes**: `subscriptions:write`
|
|
144
|
+
#
|
|
145
|
+
# @param id [String] The subscription ID.
|
|
146
|
+
# @param body [Hash, Object] the request body.
|
|
147
|
+
# @raise [Errors::PaymentFailed] on HTTP 402.
|
|
148
|
+
# @raise [Errors::AlreadyCanceledSubscription] on HTTP 403.
|
|
149
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
150
|
+
# @raise [Errors::SubscriptionLocked] on HTTP 409.
|
|
151
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
152
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
153
|
+
# @return [Models::Subscription]
|
|
154
|
+
def update(id, body: {})
|
|
155
|
+
data = client.request(
|
|
156
|
+
http_method: "PATCH",
|
|
157
|
+
path: "/v1/subscriptions/{id}",
|
|
158
|
+
path_params: { "id" => id },
|
|
159
|
+
query: {},
|
|
160
|
+
body: body,
|
|
161
|
+
response_type: :json,
|
|
162
|
+
errors: { 402 => Errors::PaymentFailed, 403 => Errors::AlreadyCanceledSubscription, 404 => Errors::ResourceNotFound, 409 => Errors::SubscriptionLocked, 422 => Errors::HTTPValidationError }
|
|
163
|
+
)
|
|
164
|
+
Models::Subscription.from_json(data)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Webhooks < ::Pago::Service
|
|
7
|
+
# List webhook endpoints.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `webhooks:read` `webhooks:write`
|
|
10
|
+
#
|
|
11
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
12
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
13
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
14
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
15
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
16
|
+
# @return [Models::ListResourceWebhookEndpoint]
|
|
17
|
+
def list_webhook_endpoints(organization_id: nil, page: 1, limit: 10)
|
|
18
|
+
data = client.request(
|
|
19
|
+
http_method: "GET",
|
|
20
|
+
path: "/v1/webhooks/endpoints",
|
|
21
|
+
path_params: {},
|
|
22
|
+
query: { "organization_id" => organization_id, "page" => page, "limit" => limit },
|
|
23
|
+
response_type: :json,
|
|
24
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
25
|
+
)
|
|
26
|
+
Models::ListResourceWebhookEndpoint.from_json(data)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Enumerate every item of `list_webhook_endpoints`, fetching pages on demand.
|
|
30
|
+
#
|
|
31
|
+
# @yieldparam item [Models::WebhookEndpoint]
|
|
32
|
+
# @return [Pago::Paginator] when called without a block.
|
|
33
|
+
def list_webhook_endpoints_each(organization_id: nil, limit: 10, &block)
|
|
34
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
35
|
+
list_webhook_endpoints(organization_id: organization_id, page: page_number, limit: limit)
|
|
36
|
+
end
|
|
37
|
+
block ? paginator.each(&block) : paginator
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Create a webhook endpoint.
|
|
41
|
+
#
|
|
42
|
+
# **Scopes**: `webhooks:write`
|
|
43
|
+
#
|
|
44
|
+
# @param body [Hash, Models::WebhookEndpointCreate] the request body.
|
|
45
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
46
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
47
|
+
# @return [Models::WebhookEndpoint]
|
|
48
|
+
def create_webhook_endpoint(body: {})
|
|
49
|
+
data = client.request(
|
|
50
|
+
http_method: "POST",
|
|
51
|
+
path: "/v1/webhooks/endpoints",
|
|
52
|
+
path_params: {},
|
|
53
|
+
query: {},
|
|
54
|
+
body: body,
|
|
55
|
+
response_type: :json,
|
|
56
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
57
|
+
)
|
|
58
|
+
Models::WebhookEndpoint.from_json(data)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Get a webhook endpoint by ID.
|
|
62
|
+
#
|
|
63
|
+
# **Scopes**: `webhooks:read` `webhooks:write`
|
|
64
|
+
#
|
|
65
|
+
# @param id [String] The webhook endpoint ID.
|
|
66
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
67
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
68
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
69
|
+
# @return [Models::WebhookEndpoint]
|
|
70
|
+
def get_webhook_endpoint(id)
|
|
71
|
+
data = client.request(
|
|
72
|
+
http_method: "GET",
|
|
73
|
+
path: "/v1/webhooks/endpoints/{id}",
|
|
74
|
+
path_params: { "id" => id },
|
|
75
|
+
query: {},
|
|
76
|
+
response_type: :json,
|
|
77
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
78
|
+
)
|
|
79
|
+
Models::WebhookEndpoint.from_json(data)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Delete a webhook endpoint.
|
|
83
|
+
#
|
|
84
|
+
# **Scopes**: `webhooks:write`
|
|
85
|
+
#
|
|
86
|
+
# @param id [String] The webhook endpoint ID.
|
|
87
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
88
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
89
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
90
|
+
# @return [nil]
|
|
91
|
+
def delete_webhook_endpoint(id)
|
|
92
|
+
client.request(
|
|
93
|
+
http_method: "DELETE",
|
|
94
|
+
path: "/v1/webhooks/endpoints/{id}",
|
|
95
|
+
path_params: { "id" => id },
|
|
96
|
+
query: {},
|
|
97
|
+
response_type: :none,
|
|
98
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Update a webhook endpoint.
|
|
103
|
+
#
|
|
104
|
+
# **Scopes**: `webhooks:write`
|
|
105
|
+
#
|
|
106
|
+
# @param id [String] The webhook endpoint ID.
|
|
107
|
+
# @param body [Hash, Models::WebhookEndpointUpdate] the request body.
|
|
108
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
109
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
110
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
111
|
+
# @return [Models::WebhookEndpoint]
|
|
112
|
+
def update_webhook_endpoint(id, body: {})
|
|
113
|
+
data = client.request(
|
|
114
|
+
http_method: "PATCH",
|
|
115
|
+
path: "/v1/webhooks/endpoints/{id}",
|
|
116
|
+
path_params: { "id" => id },
|
|
117
|
+
query: {},
|
|
118
|
+
body: body,
|
|
119
|
+
response_type: :json,
|
|
120
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
121
|
+
)
|
|
122
|
+
Models::WebhookEndpoint.from_json(data)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Regenerate a webhook endpoint secret.
|
|
126
|
+
#
|
|
127
|
+
# **Scopes**: `webhooks:write`
|
|
128
|
+
#
|
|
129
|
+
# @param id [String] The webhook endpoint ID.
|
|
130
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
131
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
132
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
133
|
+
# @return [Models::WebhookEndpoint]
|
|
134
|
+
def reset_webhook_endpoint_secret(id)
|
|
135
|
+
data = client.request(
|
|
136
|
+
http_method: "PATCH",
|
|
137
|
+
path: "/v1/webhooks/endpoints/{id}/secret",
|
|
138
|
+
path_params: { "id" => id },
|
|
139
|
+
query: {},
|
|
140
|
+
response_type: :json,
|
|
141
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
142
|
+
)
|
|
143
|
+
Models::WebhookEndpoint.from_json(data)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# List webhook deliveries.
|
|
147
|
+
#
|
|
148
|
+
# Deliveries are all the attempts to deliver a webhook event to an endpoint.
|
|
149
|
+
#
|
|
150
|
+
# **Scopes**: `webhooks:read` `webhooks:write`
|
|
151
|
+
#
|
|
152
|
+
# @param endpoint_id [String, Array<String>, nil] Filter by webhook endpoint ID.
|
|
153
|
+
# @param start_timestamp [String, nil] Filter deliveries after this timestamp.
|
|
154
|
+
# @param end_timestamp [String, nil] Filter deliveries before this timestamp.
|
|
155
|
+
# @param succeeded [Boolean, nil] Filter by delivery success status.
|
|
156
|
+
# @param query [String, nil] Query to filter webhook deliveries.
|
|
157
|
+
# @param http_code_class [String, nil] Filter by HTTP response code class (2xx, 3xx, 4xx, 5xx).
|
|
158
|
+
# @param event_type [String, Array<String>, nil] Filter by webhook event type.
|
|
159
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
160
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
161
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
162
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
163
|
+
# @return [Models::ListResourceWebhookDelivery]
|
|
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)
|
|
165
|
+
data = client.request(
|
|
166
|
+
http_method: "GET",
|
|
167
|
+
path: "/v1/webhooks/deliveries",
|
|
168
|
+
path_params: {},
|
|
169
|
+
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 },
|
|
170
|
+
response_type: :json,
|
|
171
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
172
|
+
)
|
|
173
|
+
Models::ListResourceWebhookDelivery.from_json(data)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Enumerate every item of `list_webhook_deliveries`, fetching pages on demand.
|
|
177
|
+
#
|
|
178
|
+
# @yieldparam item [Models::WebhookDelivery]
|
|
179
|
+
# @return [Pago::Paginator] when called without a block.
|
|
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)
|
|
181
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
182
|
+
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)
|
|
183
|
+
end
|
|
184
|
+
block ? paginator.each(&block) : paginator
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Schedule the re-delivery of a webhook event.
|
|
188
|
+
#
|
|
189
|
+
# **Scopes**: `webhooks:write`
|
|
190
|
+
#
|
|
191
|
+
# @param id [String] The webhook event ID.
|
|
192
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
193
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
194
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
195
|
+
# @return [Object]
|
|
196
|
+
def redeliver_webhook_event(id)
|
|
197
|
+
data = client.request(
|
|
198
|
+
http_method: "POST",
|
|
199
|
+
path: "/v1/webhooks/events/{id}/redeliver",
|
|
200
|
+
path_params: { "id" => id },
|
|
201
|
+
query: {},
|
|
202
|
+
response_type: :json,
|
|
203
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
204
|
+
)
|
|
205
|
+
data
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|