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,238 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Orders < ::Pago::Service
|
|
7
|
+
# List orders.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `orders:read`
|
|
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 product_billing_type [String, Array<String>, nil] Filter by product billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases.
|
|
14
|
+
# @param discount_id [String, Array<String>, nil] Filter by discount ID.
|
|
15
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
16
|
+
# @param external_customer_id [String, Array<String>, nil] Filter by customer external ID.
|
|
17
|
+
# @param checkout_id [String, Array<String>, nil] Filter by checkout ID.
|
|
18
|
+
# @param subscription_id [String, Array<String>, nil] Filter by subscription ID.
|
|
19
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
20
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
21
|
+
# @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.
|
|
22
|
+
# @param metadata [Object] Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.
|
|
23
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
24
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
25
|
+
# @return [Models::ListResourceOrder]
|
|
26
|
+
def list(organization_id: nil, product_id: nil, product_billing_type: nil, discount_id: nil, customer_id: nil, external_customer_id: nil, checkout_id: nil, subscription_id: nil, page: 1, limit: 10, sorting: ["-created_at"], metadata: nil)
|
|
27
|
+
data = client.request(
|
|
28
|
+
http_method: "GET",
|
|
29
|
+
path: "/v1/orders/",
|
|
30
|
+
path_params: {},
|
|
31
|
+
query: { "organization_id" => organization_id, "product_id" => product_id, "product_billing_type" => product_billing_type, "discount_id" => discount_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "checkout_id" => checkout_id, "subscription_id" => subscription_id, "page" => page, "limit" => limit, "sorting" => sorting, "metadata" => metadata },
|
|
32
|
+
response_type: :json,
|
|
33
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
34
|
+
)
|
|
35
|
+
Models::ListResourceOrder.from_json(data)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
39
|
+
#
|
|
40
|
+
# @yieldparam item [Models::Order]
|
|
41
|
+
# @return [Pago::Paginator] when called without a block.
|
|
42
|
+
def list_each(organization_id: nil, product_id: nil, product_billing_type: nil, discount_id: nil, customer_id: nil, external_customer_id: nil, checkout_id: nil, subscription_id: nil, limit: 10, sorting: ["-created_at"], metadata: nil, &block)
|
|
43
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
44
|
+
list(organization_id: organization_id, product_id: product_id, product_billing_type: product_billing_type, discount_id: discount_id, customer_id: customer_id, external_customer_id: external_customer_id, checkout_id: checkout_id, subscription_id: subscription_id, page: page_number, limit: limit, sorting: sorting, metadata: metadata)
|
|
45
|
+
end
|
|
46
|
+
block ? paginator.each(&block) : paginator
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Create a draft order for an off-session charge against a saved payment
|
|
50
|
+
# method. The order is created with `status=draft` and no invoice number;
|
|
51
|
+
# call `POST /v1/orders/{id}/finalize` to attempt the charge.
|
|
52
|
+
#
|
|
53
|
+
# The organization must have the `off_session_charges_enabled` feature flag.
|
|
54
|
+
#
|
|
55
|
+
# **Scopes**: `orders:write`
|
|
56
|
+
#
|
|
57
|
+
# @param body [Hash, Models::OrderCreate] the request body.
|
|
58
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
59
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
60
|
+
# @return [Models::Order]
|
|
61
|
+
def create(body: {})
|
|
62
|
+
data = client.request(
|
|
63
|
+
http_method: "POST",
|
|
64
|
+
path: "/v1/orders/",
|
|
65
|
+
path_params: {},
|
|
66
|
+
query: {},
|
|
67
|
+
body: body,
|
|
68
|
+
response_type: :json,
|
|
69
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
70
|
+
)
|
|
71
|
+
Models::Order.from_json(data)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Export orders as a CSV file.
|
|
75
|
+
#
|
|
76
|
+
# **Scopes**: `orders:read`
|
|
77
|
+
#
|
|
78
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
79
|
+
# @param product_id [String, Array<String>, nil] Filter by product ID.
|
|
80
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
81
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
82
|
+
# @return [String]
|
|
83
|
+
def export(organization_id: nil, product_id: nil)
|
|
84
|
+
client.request(
|
|
85
|
+
http_method: "GET",
|
|
86
|
+
path: "/v1/orders/export",
|
|
87
|
+
path_params: {},
|
|
88
|
+
query: { "organization_id" => organization_id, "product_id" => product_id },
|
|
89
|
+
response_type: :text,
|
|
90
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Get an order by ID.
|
|
95
|
+
#
|
|
96
|
+
# **Scopes**: `orders:read`
|
|
97
|
+
#
|
|
98
|
+
# @param id [String] The order ID.
|
|
99
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
100
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
101
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
102
|
+
# @return [Models::Order]
|
|
103
|
+
def get(id)
|
|
104
|
+
data = client.request(
|
|
105
|
+
http_method: "GET",
|
|
106
|
+
path: "/v1/orders/{id}",
|
|
107
|
+
path_params: { "id" => id },
|
|
108
|
+
query: {},
|
|
109
|
+
response_type: :json,
|
|
110
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
111
|
+
)
|
|
112
|
+
Models::Order.from_json(data)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Update an order.
|
|
116
|
+
#
|
|
117
|
+
# **Scopes**: `orders:write`
|
|
118
|
+
#
|
|
119
|
+
# @param id [String] The order ID.
|
|
120
|
+
# @param body [Hash, Models::OrderUpdate] the request body.
|
|
121
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
122
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
123
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
124
|
+
# @return [Models::Order]
|
|
125
|
+
def update(id, body: {})
|
|
126
|
+
data = client.request(
|
|
127
|
+
http_method: "PATCH",
|
|
128
|
+
path: "/v1/orders/{id}",
|
|
129
|
+
path_params: { "id" => id },
|
|
130
|
+
query: {},
|
|
131
|
+
body: body,
|
|
132
|
+
response_type: :json,
|
|
133
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
134
|
+
)
|
|
135
|
+
Models::Order.from_json(data)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Finalize a draft order and synchronously attempt an off-session charge.
|
|
139
|
+
#
|
|
140
|
+
# On success, the order transitions to `paid` and benefit grants fire
|
|
141
|
+
# before the response returns. On failure (decline, missing payment method,
|
|
142
|
+
# SCA challenge), the order stays in `draft` and a 4xx error is returned.
|
|
143
|
+
#
|
|
144
|
+
# The request fails with 412 if the order is not in `draft` status.
|
|
145
|
+
#
|
|
146
|
+
# **Scopes**: `orders:write`
|
|
147
|
+
#
|
|
148
|
+
# @param id [String] The order ID.
|
|
149
|
+
# @param body [Hash, Models::OrderFinalize] the request body.
|
|
150
|
+
# @raise [Errors::Finalize402Error] on HTTP 402.
|
|
151
|
+
# @raise [Errors::Finalize403Error] on HTTP 403.
|
|
152
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
153
|
+
# @raise [Errors::OrderNotDraft] on HTTP 412.
|
|
154
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
155
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
156
|
+
# @return [Models::Order]
|
|
157
|
+
def finalize(id, body: {})
|
|
158
|
+
data = client.request(
|
|
159
|
+
http_method: "POST",
|
|
160
|
+
path: "/v1/orders/{id}/finalize",
|
|
161
|
+
path_params: { "id" => id },
|
|
162
|
+
query: {},
|
|
163
|
+
body: body,
|
|
164
|
+
response_type: :json,
|
|
165
|
+
errors: { 402 => Errors::Finalize402Error, 403 => Errors::Finalize403Error, 404 => Errors::ResourceNotFound, 412 => Errors::OrderNotDraft, 422 => Errors::HTTPValidationError }
|
|
166
|
+
)
|
|
167
|
+
Models::Order.from_json(data)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Get an order's invoice data.
|
|
171
|
+
#
|
|
172
|
+
# **Scopes**: `orders:read`
|
|
173
|
+
#
|
|
174
|
+
# @param id [String] The order ID.
|
|
175
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
176
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
177
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
178
|
+
# @return [Models::OrderInvoice]
|
|
179
|
+
def invoice(id)
|
|
180
|
+
data = client.request(
|
|
181
|
+
http_method: "GET",
|
|
182
|
+
path: "/v1/orders/{id}/invoice",
|
|
183
|
+
path_params: { "id" => id },
|
|
184
|
+
query: {},
|
|
185
|
+
response_type: :json,
|
|
186
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
187
|
+
)
|
|
188
|
+
Models::OrderInvoice.from_json(data)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Trigger generation of an order's invoice.
|
|
192
|
+
#
|
|
193
|
+
# **Scopes**: `orders:read`
|
|
194
|
+
#
|
|
195
|
+
# @param id [String] The order ID.
|
|
196
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
197
|
+
# @raise [Errors::OrderNotEligibleForInvoice] on HTTP 409.
|
|
198
|
+
# @raise [Errors::MissingInvoiceBillingDetails] on HTTP 422.
|
|
199
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
200
|
+
# @return [Object]
|
|
201
|
+
def generate_invoice(id)
|
|
202
|
+
data = client.request(
|
|
203
|
+
http_method: "POST",
|
|
204
|
+
path: "/v1/orders/{id}/invoice",
|
|
205
|
+
path_params: { "id" => id },
|
|
206
|
+
query: {},
|
|
207
|
+
response_type: :json,
|
|
208
|
+
errors: { 404 => Errors::ResourceNotFound, 409 => Errors::OrderNotEligibleForInvoice, 422 => Errors::MissingInvoiceBillingDetails }
|
|
209
|
+
)
|
|
210
|
+
data
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Get a presigned URL to download an order's receipt PDF.
|
|
214
|
+
#
|
|
215
|
+
# **Scopes**: `orders:read`
|
|
216
|
+
#
|
|
217
|
+
# @param id [String] The order ID.
|
|
218
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
219
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
220
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
221
|
+
# @return [Models::OrderReceipt]
|
|
222
|
+
def receipt(id)
|
|
223
|
+
data = client.request(
|
|
224
|
+
http_method: "GET",
|
|
225
|
+
path: "/v1/orders/{id}/receipt",
|
|
226
|
+
path_params: { "id" => id },
|
|
227
|
+
query: {},
|
|
228
|
+
response_type: :json,
|
|
229
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
230
|
+
)
|
|
231
|
+
Models::OrderReceipt.from_json(data)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Organizations < ::Pago::Service
|
|
7
|
+
# List organizations.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `organizations:read` `organizations:write`
|
|
10
|
+
#
|
|
11
|
+
# @param slug [String, nil] Filter by slug.
|
|
12
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
13
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
14
|
+
# @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.
|
|
15
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
16
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
17
|
+
# @return [Models::ListResourceOrganization]
|
|
18
|
+
def list(slug: nil, page: 1, limit: 10, sorting: ["created_at"])
|
|
19
|
+
data = client.request(
|
|
20
|
+
http_method: "GET",
|
|
21
|
+
path: "/v1/organizations/",
|
|
22
|
+
path_params: {},
|
|
23
|
+
query: { "slug" => slug, "page" => page, "limit" => limit, "sorting" => sorting },
|
|
24
|
+
response_type: :json,
|
|
25
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
26
|
+
)
|
|
27
|
+
Models::ListResourceOrganization.from_json(data)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
31
|
+
#
|
|
32
|
+
# @yieldparam item [Models::Organization]
|
|
33
|
+
# @return [Pago::Paginator] when called without a block.
|
|
34
|
+
def list_each(slug: nil, limit: 10, sorting: ["created_at"], &block)
|
|
35
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
36
|
+
list(slug: slug, page: page_number, limit: limit, sorting: sorting)
|
|
37
|
+
end
|
|
38
|
+
block ? paginator.each(&block) : paginator
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Create an organization.
|
|
42
|
+
#
|
|
43
|
+
# **Scopes**: `organizations:write`
|
|
44
|
+
#
|
|
45
|
+
# @param body [Hash, Models::OrganizationCreate] the request body.
|
|
46
|
+
# @raise [Errors::CannotCreateOrganizationError] on HTTP 403.
|
|
47
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
48
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
49
|
+
# @return [Models::Organization]
|
|
50
|
+
def create(body: {})
|
|
51
|
+
data = client.request(
|
|
52
|
+
http_method: "POST",
|
|
53
|
+
path: "/v1/organizations/",
|
|
54
|
+
path_params: {},
|
|
55
|
+
query: {},
|
|
56
|
+
body: body,
|
|
57
|
+
response_type: :json,
|
|
58
|
+
errors: { 403 => Errors::CannotCreateOrganizationError, 422 => Errors::HTTPValidationError }
|
|
59
|
+
)
|
|
60
|
+
Models::Organization.from_json(data)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Get an organization by ID.
|
|
64
|
+
#
|
|
65
|
+
# **Scopes**: `organizations:read` `organizations:write`
|
|
66
|
+
#
|
|
67
|
+
# @param id [String]
|
|
68
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
69
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
70
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
71
|
+
# @return [Models::Organization]
|
|
72
|
+
def get(id)
|
|
73
|
+
data = client.request(
|
|
74
|
+
http_method: "GET",
|
|
75
|
+
path: "/v1/organizations/{id}",
|
|
76
|
+
path_params: { "id" => id },
|
|
77
|
+
query: {},
|
|
78
|
+
response_type: :json,
|
|
79
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
80
|
+
)
|
|
81
|
+
Models::Organization.from_json(data)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Update an organization.
|
|
85
|
+
#
|
|
86
|
+
# **Scopes**: `organizations:write`
|
|
87
|
+
#
|
|
88
|
+
# @param id [String]
|
|
89
|
+
# @param body [Hash, Models::OrganizationUpdate] the request body.
|
|
90
|
+
# @raise [Errors::NotPermitted] on HTTP 403.
|
|
91
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
92
|
+
# @raise [Errors::SSOEnforcementRequiresConnection] on HTTP 409.
|
|
93
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
94
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
95
|
+
# @return [Models::Organization]
|
|
96
|
+
def update(id, body: {})
|
|
97
|
+
data = client.request(
|
|
98
|
+
http_method: "PATCH",
|
|
99
|
+
path: "/v1/organizations/{id}",
|
|
100
|
+
path_params: { "id" => id },
|
|
101
|
+
query: {},
|
|
102
|
+
body: body,
|
|
103
|
+
response_type: :json,
|
|
104
|
+
errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 409 => Errors::SSOEnforcementRequiresConnection, 422 => Errors::HTTPValidationError }
|
|
105
|
+
)
|
|
106
|
+
Models::Organization.from_json(data)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Payments < ::Pago::Service
|
|
7
|
+
# List payments.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `payments:read`
|
|
10
|
+
#
|
|
11
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
12
|
+
# @param checkout_id [String, Array<String>, nil] Filter by checkout ID.
|
|
13
|
+
# @param order_id [String, Array<String>, nil] Filter by order ID.
|
|
14
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
15
|
+
# @param status [String, Array<String>, nil] Filter by payment status.
|
|
16
|
+
# @param method [String, Array<String>, nil] Filter by payment method.
|
|
17
|
+
# @param customer_email [String, Array<String>, nil] Filter by customer email.
|
|
18
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
19
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
20
|
+
# @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.
|
|
21
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
22
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
23
|
+
# @return [Models::ListResourcePayment]
|
|
24
|
+
def list(organization_id: nil, checkout_id: nil, order_id: nil, customer_id: nil, status: nil, method: nil, customer_email: nil, page: 1, limit: 10, sorting: ["-created_at"])
|
|
25
|
+
data = client.request(
|
|
26
|
+
http_method: "GET",
|
|
27
|
+
path: "/v1/payments/",
|
|
28
|
+
path_params: {},
|
|
29
|
+
query: { "organization_id" => organization_id, "checkout_id" => checkout_id, "order_id" => order_id, "customer_id" => customer_id, "status" => status, "method" => method, "customer_email" => customer_email, "page" => page, "limit" => limit, "sorting" => sorting },
|
|
30
|
+
response_type: :json,
|
|
31
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
32
|
+
)
|
|
33
|
+
Models::ListResourcePayment.from_json(data)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
37
|
+
#
|
|
38
|
+
# @yieldparam item [Object]
|
|
39
|
+
# @return [Pago::Paginator] when called without a block.
|
|
40
|
+
def list_each(organization_id: nil, checkout_id: nil, order_id: nil, customer_id: nil, status: nil, method: nil, customer_email: nil, limit: 10, sorting: ["-created_at"], &block)
|
|
41
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
42
|
+
list(organization_id: organization_id, checkout_id: checkout_id, order_id: order_id, customer_id: customer_id, status: status, method: method, customer_email: customer_email, page: page_number, limit: limit, sorting: sorting)
|
|
43
|
+
end
|
|
44
|
+
block ? paginator.each(&block) : paginator
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Get a payment by ID.
|
|
48
|
+
#
|
|
49
|
+
# **Scopes**: `payments:read`
|
|
50
|
+
#
|
|
51
|
+
# @param id [String] The payment ID.
|
|
52
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
53
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
54
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
55
|
+
# @return [Object]
|
|
56
|
+
def get(id)
|
|
57
|
+
data = client.request(
|
|
58
|
+
http_method: "GET",
|
|
59
|
+
path: "/v1/payments/{id}",
|
|
60
|
+
path_params: { "id" => id },
|
|
61
|
+
query: {},
|
|
62
|
+
response_type: :json,
|
|
63
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
64
|
+
)
|
|
65
|
+
Unions::Payment.from_json(data)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Products < ::Pago::Service
|
|
7
|
+
# List products.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `products:read` `products:write`
|
|
10
|
+
#
|
|
11
|
+
# @param id [String, Array<String>, nil] Filter by product ID.
|
|
12
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
13
|
+
# @param query [String, nil] Filter by product name.
|
|
14
|
+
# @param is_archived [Boolean, nil] Filter on archived products.
|
|
15
|
+
# @param is_recurring [Boolean, nil] Filter on recurring products. If `true`, only subscriptions tiers are returned. If `false`, only one-time purchase products are returned.
|
|
16
|
+
# @param benefit_id [String, Array<String>, nil] Filter products granting specific benefit.
|
|
17
|
+
# @param visibility [Array<String>, nil] Filter by visibility.
|
|
18
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
19
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
20
|
+
# @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.
|
|
21
|
+
# @param metadata [Object] Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.
|
|
22
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
23
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
24
|
+
# @return [Models::ListResourceProduct]
|
|
25
|
+
def list(id: nil, organization_id: nil, query: nil, is_archived: nil, is_recurring: nil, benefit_id: nil, visibility: nil, page: 1, limit: 10, sorting: ["-created_at"], metadata: nil)
|
|
26
|
+
data = client.request(
|
|
27
|
+
http_method: "GET",
|
|
28
|
+
path: "/v1/products/",
|
|
29
|
+
path_params: {},
|
|
30
|
+
query: { "id" => id, "organization_id" => organization_id, "query" => query, "is_archived" => is_archived, "is_recurring" => is_recurring, "benefit_id" => benefit_id, "visibility" => visibility, "page" => page, "limit" => limit, "sorting" => sorting, "metadata" => metadata },
|
|
31
|
+
response_type: :json,
|
|
32
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
33
|
+
)
|
|
34
|
+
Models::ListResourceProduct.from_json(data)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
38
|
+
#
|
|
39
|
+
# @yieldparam item [Models::Product]
|
|
40
|
+
# @return [Pago::Paginator] when called without a block.
|
|
41
|
+
def list_each(id: nil, organization_id: nil, query: nil, is_archived: nil, is_recurring: nil, benefit_id: nil, visibility: nil, limit: 10, sorting: ["-created_at"], metadata: nil, &block)
|
|
42
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
43
|
+
list(id: id, organization_id: organization_id, query: query, is_archived: is_archived, is_recurring: is_recurring, benefit_id: benefit_id, visibility: visibility, page: page_number, limit: limit, sorting: sorting, metadata: metadata)
|
|
44
|
+
end
|
|
45
|
+
block ? paginator.each(&block) : paginator
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Create a product.
|
|
49
|
+
#
|
|
50
|
+
# **Scopes**: `products:write`
|
|
51
|
+
#
|
|
52
|
+
# @param body [Hash, Object] the request body.
|
|
53
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
54
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
55
|
+
# @return [Models::Product]
|
|
56
|
+
def create(body: {})
|
|
57
|
+
data = client.request(
|
|
58
|
+
http_method: "POST",
|
|
59
|
+
path: "/v1/products/",
|
|
60
|
+
path_params: {},
|
|
61
|
+
query: {},
|
|
62
|
+
body: body,
|
|
63
|
+
response_type: :json,
|
|
64
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
65
|
+
)
|
|
66
|
+
Models::Product.from_json(data)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Get a product by ID.
|
|
70
|
+
#
|
|
71
|
+
# **Scopes**: `products:read` `products:write`
|
|
72
|
+
#
|
|
73
|
+
# @param id [String]
|
|
74
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
75
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
76
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
77
|
+
# @return [Models::Product]
|
|
78
|
+
def get(id)
|
|
79
|
+
data = client.request(
|
|
80
|
+
http_method: "GET",
|
|
81
|
+
path: "/v1/products/{id}",
|
|
82
|
+
path_params: { "id" => id },
|
|
83
|
+
query: {},
|
|
84
|
+
response_type: :json,
|
|
85
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
86
|
+
)
|
|
87
|
+
Models::Product.from_json(data)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Update a product.
|
|
91
|
+
#
|
|
92
|
+
# **Scopes**: `products:write`
|
|
93
|
+
#
|
|
94
|
+
# @param id [String]
|
|
95
|
+
# @param body [Hash, Models::ProductUpdate] the request body.
|
|
96
|
+
# @raise [Errors::NotPermitted] on HTTP 403.
|
|
97
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
98
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
99
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
100
|
+
# @return [Models::Product]
|
|
101
|
+
def update(id, body: {})
|
|
102
|
+
data = client.request(
|
|
103
|
+
http_method: "PATCH",
|
|
104
|
+
path: "/v1/products/{id}",
|
|
105
|
+
path_params: { "id" => id },
|
|
106
|
+
query: {},
|
|
107
|
+
body: body,
|
|
108
|
+
response_type: :json,
|
|
109
|
+
errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
110
|
+
)
|
|
111
|
+
Models::Product.from_json(data)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Update benefits granted by a product.
|
|
115
|
+
#
|
|
116
|
+
# **Scopes**: `products:write`
|
|
117
|
+
#
|
|
118
|
+
# @param id [String]
|
|
119
|
+
# @param body [Hash, Models::ProductBenefitsUpdate] the request body.
|
|
120
|
+
# @raise [Errors::NotPermitted] on HTTP 403.
|
|
121
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
122
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
123
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
124
|
+
# @return [Models::Product]
|
|
125
|
+
def update_benefits(id, body: {})
|
|
126
|
+
data = client.request(
|
|
127
|
+
http_method: "POST",
|
|
128
|
+
path: "/v1/products/{id}/benefits",
|
|
129
|
+
path_params: { "id" => id },
|
|
130
|
+
query: {},
|
|
131
|
+
body: body,
|
|
132
|
+
response_type: :json,
|
|
133
|
+
errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
134
|
+
)
|
|
135
|
+
Models::Product.from_json(data)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Refunds < ::Pago::Service
|
|
7
|
+
# List refunds.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `refunds:read` `refunds:write`
|
|
10
|
+
#
|
|
11
|
+
# @param id [String, Array<String>, nil] Filter by refund ID.
|
|
12
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
13
|
+
# @param order_id [String, Array<String>, nil] Filter by order ID.
|
|
14
|
+
# @param subscription_id [String, Array<String>, nil] Filter by subscription ID.
|
|
15
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
16
|
+
# @param external_customer_id [String, Array<String>, nil] Filter by customer external ID.
|
|
17
|
+
# @param succeeded [Boolean, nil] Filter by `succeeded`.
|
|
18
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
19
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
20
|
+
# @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.
|
|
21
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
22
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
23
|
+
# @return [Models::ListResourceRefund]
|
|
24
|
+
def list(id: nil, organization_id: nil, order_id: nil, subscription_id: nil, customer_id: nil, external_customer_id: nil, succeeded: nil, page: 1, limit: 10, sorting: ["-created_at"])
|
|
25
|
+
data = client.request(
|
|
26
|
+
http_method: "GET",
|
|
27
|
+
path: "/v1/refunds/",
|
|
28
|
+
path_params: {},
|
|
29
|
+
query: { "id" => id, "organization_id" => organization_id, "order_id" => order_id, "subscription_id" => subscription_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "succeeded" => succeeded, "page" => page, "limit" => limit, "sorting" => sorting },
|
|
30
|
+
response_type: :json,
|
|
31
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
32
|
+
)
|
|
33
|
+
Models::ListResourceRefund.from_json(data)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
37
|
+
#
|
|
38
|
+
# @yieldparam item [Models::Refund]
|
|
39
|
+
# @return [Pago::Paginator] when called without a block.
|
|
40
|
+
def list_each(id: nil, organization_id: nil, order_id: nil, subscription_id: nil, customer_id: nil, external_customer_id: nil, succeeded: nil, limit: 10, sorting: ["-created_at"], &block)
|
|
41
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
42
|
+
list(id: id, organization_id: organization_id, order_id: order_id, subscription_id: subscription_id, customer_id: customer_id, external_customer_id: external_customer_id, succeeded: succeeded, page: page_number, limit: limit, sorting: sorting)
|
|
43
|
+
end
|
|
44
|
+
block ? paginator.each(&block) : paginator
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Create a refund.
|
|
48
|
+
#
|
|
49
|
+
# **Scopes**: `refunds:write`
|
|
50
|
+
#
|
|
51
|
+
# @param body [Hash, Models::RefundCreate] the request body.
|
|
52
|
+
# @raise [Errors::RefundedAlready] on HTTP 403.
|
|
53
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
54
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
55
|
+
# @return [Models::Refund]
|
|
56
|
+
def create(body: {})
|
|
57
|
+
data = client.request(
|
|
58
|
+
http_method: "POST",
|
|
59
|
+
path: "/v1/refunds/",
|
|
60
|
+
path_params: {},
|
|
61
|
+
query: {},
|
|
62
|
+
body: body,
|
|
63
|
+
response_type: :json,
|
|
64
|
+
errors: { 403 => Errors::RefundedAlready, 422 => Errors::HTTPValidationError }
|
|
65
|
+
)
|
|
66
|
+
Models::Refund.from_json(data)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|