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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +131 -0
  4. data/lib/pago/base_client.rb +116 -0
  5. data/lib/pago/errors.rb +83 -0
  6. data/lib/pago/http.rb +78 -0
  7. data/lib/pago/model.rb +86 -0
  8. data/lib/pago/paginator.rb +67 -0
  9. data/lib/pago/serde.rb +186 -0
  10. data/lib/pago/service.rb +17 -0
  11. data/lib/pago/v2026_04/client.rb +124 -0
  12. data/lib/pago/v2026_04/enums.rb +4552 -0
  13. data/lib/pago/v2026_04/errors.rb +1121 -0
  14. data/lib/pago/v2026_04/models.rb +46344 -0
  15. data/lib/pago/v2026_04/services/benefit_grants.rb +48 -0
  16. data/lib/pago/v2026_04/services/benefits.rb +179 -0
  17. data/lib/pago/v2026_04/services/checkout_links.rb +131 -0
  18. data/lib/pago/v2026_04/services/checkouts.rb +185 -0
  19. data/lib/pago/v2026_04/services/custom_fields.rb +132 -0
  20. data/lib/pago/v2026_04/services/customer_meters.rb +69 -0
  21. data/lib/pago/v2026_04/services/customer_portal.rb +1181 -0
  22. data/lib/pago/v2026_04/services/customer_seats.rb +137 -0
  23. data/lib/pago/v2026_04/services/customer_sessions.rb +35 -0
  24. data/lib/pago/v2026_04/services/customers.rb +556 -0
  25. data/lib/pago/v2026_04/services/discounts.rb +131 -0
  26. data/lib/pago/v2026_04/services/disputes.rb +93 -0
  27. data/lib/pago/v2026_04/services/event_types.rb +74 -0
  28. data/lib/pago/v2026_04/services/events.rb +126 -0
  29. data/lib/pago/v2026_04/services/files.rb +135 -0
  30. data/lib/pago/v2026_04/services/license_keys.rb +183 -0
  31. data/lib/pago/v2026_04/services/members.rb +47 -0
  32. data/lib/pago/v2026_04/services/meters.rb +142 -0
  33. data/lib/pago/v2026_04/services/metrics.rb +188 -0
  34. data/lib/pago/v2026_04/services/oauth2.rb +175 -0
  35. data/lib/pago/v2026_04/services/orders.rb +238 -0
  36. data/lib/pago/v2026_04/services/organizations.rb +113 -0
  37. data/lib/pago/v2026_04/services/payments.rb +72 -0
  38. data/lib/pago/v2026_04/services/products.rb +142 -0
  39. data/lib/pago/v2026_04/services/refunds.rb +73 -0
  40. data/lib/pago/v2026_04/services/subscriptions.rb +171 -0
  41. data/lib/pago/v2026_04/services/webhooks.rb +212 -0
  42. data/lib/pago/v2026_04/unions.rb +739 -0
  43. data/lib/pago/v2026_04/webhooks.rb +86 -0
  44. data/lib/pago/version.rb +5 -0
  45. data/lib/pago/webhooks.rb +159 -0
  46. data/lib/pago.rb +39 -0
  47. data/sig/pago/v2026_04/generated.rbs +12401 -0
  48. data/sig/pago.rbs +204 -0
  49. metadata +91 -0
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pago
4
+ module V2026_04
5
+ module Services
6
+ class BenefitGrants < ::Pago::Service
7
+ # List benefit grants across all benefits accessible to the authenticated subject.
8
+ #
9
+ # **Scopes**: `benefits:read` `benefits:write`
10
+ #
11
+ # @param organization_id [String, Array<String>, nil] Filter by organization ID.
12
+ # @param customer_id [String, Array<String>, nil] Filter by customer ID.
13
+ # @param external_customer_id [String, Array<String>, nil] Filter by customer external ID.
14
+ # @param is_granted [Boolean, nil] Filter by granted status. If `true`, only granted benefits will be returned. If `false`, only revoked benefits will be returned.
15
+ # @param page [Integer] Page number, defaults to 1.
16
+ # @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
17
+ # @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.
18
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
19
+ # @raise [Pago::NetworkError] when the request never reached the API.
20
+ # @return [Models::ListResourceBenefitGrant]
21
+ def list(organization_id: nil, customer_id: nil, external_customer_id: nil, is_granted: nil, page: 1, limit: 10, sorting: ["-created_at"])
22
+ data = client.request(
23
+ http_method: "GET",
24
+ path: "/v1/benefit-grants/",
25
+ path_params: {},
26
+ query: { "organization_id" => organization_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "is_granted" => is_granted, "page" => page, "limit" => limit, "sorting" => sorting },
27
+ response_type: :json,
28
+ errors: { 422 => Errors::HTTPValidationError }
29
+ )
30
+ Models::ListResourceBenefitGrant.from_json(data)
31
+ end
32
+
33
+ # Enumerate every item of `list`, fetching pages on demand.
34
+ #
35
+ # @yieldparam item [Models::BenefitGrant]
36
+ # @return [Pago::Paginator] when called without a block.
37
+ def list_each(organization_id: nil, customer_id: nil, external_customer_id: nil, is_granted: nil, limit: 10, sorting: ["-created_at"], &block)
38
+ paginator = ::Pago::Paginator.new do |page_number|
39
+ list(organization_id: organization_id, customer_id: customer_id, external_customer_id: external_customer_id, is_granted: is_granted, page: page_number, limit: limit, sorting: sorting)
40
+ end
41
+ block ? paginator.each(&block) : paginator
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,179 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pago
4
+ module V2026_04
5
+ module Services
6
+ class Benefits < ::Pago::Service
7
+ # List benefits.
8
+ #
9
+ # **Scopes**: `benefits:read` `benefits:write`
10
+ #
11
+ # @param organization_id [String, Array<String>, nil] Filter by organization ID.
12
+ # @param type [String, Array<String>, nil] Filter by benefit type.
13
+ # @param id [String, Array<String>, nil] Filter by benefit IDs.
14
+ # @param exclude_id [String, Array<String>, nil] Exclude benefits with these IDs.
15
+ # @param query [String, nil] Filter by description.
16
+ # @param page [Integer] Page number, defaults to 1.
17
+ # @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
18
+ # @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.
19
+ # @param metadata [Object] Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.
20
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
21
+ # @raise [Pago::NetworkError] when the request never reached the API.
22
+ # @return [Models::ListResourceBenefit]
23
+ def list(organization_id: nil, type: nil, id: nil, exclude_id: nil, query: nil, page: 1, limit: 10, sorting: ["-created_at"], metadata: nil)
24
+ data = client.request(
25
+ http_method: "GET",
26
+ path: "/v1/benefits/",
27
+ path_params: {},
28
+ query: { "organization_id" => organization_id, "type" => type, "id" => id, "exclude_id" => exclude_id, "query" => query, "page" => page, "limit" => limit, "sorting" => sorting, "metadata" => metadata },
29
+ response_type: :json,
30
+ errors: { 422 => Errors::HTTPValidationError }
31
+ )
32
+ Models::ListResourceBenefit.from_json(data)
33
+ end
34
+
35
+ # Enumerate every item of `list`, fetching pages on demand.
36
+ #
37
+ # @yieldparam item [Object]
38
+ # @return [Pago::Paginator] when called without a block.
39
+ def list_each(organization_id: nil, type: nil, id: nil, exclude_id: nil, query: nil, limit: 10, sorting: ["-created_at"], metadata: nil, &block)
40
+ paginator = ::Pago::Paginator.new do |page_number|
41
+ list(organization_id: organization_id, type: type, id: id, exclude_id: exclude_id, query: query, page: page_number, limit: limit, sorting: sorting, metadata: metadata)
42
+ end
43
+ block ? paginator.each(&block) : paginator
44
+ end
45
+
46
+ # Create a benefit.
47
+ #
48
+ # **Scopes**: `benefits:write`
49
+ #
50
+ # @param body [Hash, Object] the request body.
51
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
52
+ # @raise [Pago::NetworkError] when the request never reached the API.
53
+ # @return [Object]
54
+ def create(body: {})
55
+ data = client.request(
56
+ http_method: "POST",
57
+ path: "/v1/benefits/",
58
+ path_params: {},
59
+ query: {},
60
+ body: body,
61
+ response_type: :json,
62
+ errors: { 422 => Errors::HTTPValidationError }
63
+ )
64
+ Unions::Benefit.from_json(data)
65
+ end
66
+
67
+ # Get a benefit by ID.
68
+ #
69
+ # **Scopes**: `benefits:read` `benefits:write`
70
+ #
71
+ # @param id [String]
72
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
73
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
74
+ # @raise [Pago::NetworkError] when the request never reached the API.
75
+ # @return [Object]
76
+ def get(id)
77
+ data = client.request(
78
+ http_method: "GET",
79
+ path: "/v1/benefits/{id}",
80
+ path_params: { "id" => id },
81
+ query: {},
82
+ response_type: :json,
83
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
84
+ )
85
+ Unions::Benefit.from_json(data)
86
+ end
87
+
88
+ # Delete a benefit.
89
+ #
90
+ # > [!WARNING]
91
+ # > Every grants associated with the benefit will be revoked.
92
+ # > Users will lose access to the benefit.
93
+ #
94
+ # **Scopes**: `benefits:write`
95
+ #
96
+ # @param id [String]
97
+ # @raise [Errors::NotPermitted] on HTTP 403.
98
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
99
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
100
+ # @raise [Pago::NetworkError] when the request never reached the API.
101
+ # @return [nil]
102
+ def delete(id)
103
+ client.request(
104
+ http_method: "DELETE",
105
+ path: "/v1/benefits/{id}",
106
+ path_params: { "id" => id },
107
+ query: {},
108
+ response_type: :none,
109
+ errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
110
+ )
111
+ end
112
+
113
+ # Update a benefit.
114
+ #
115
+ # **Scopes**: `benefits:write`
116
+ #
117
+ # @param id [String]
118
+ # @param body [Hash, Models::BenefitCustomUpdate, Models::BenefitDiscordUpdate, Models::BenefitGitHubRepositoryUpdate, Models::BenefitDownloadablesUpdate, Models::BenefitLicenseKeysUpdate, Models::BenefitMeterCreditUpdate, Models::BenefitFeatureFlagUpdate, Models::BenefitSlackSharedChannelUpdate] the request body.
119
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
120
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
121
+ # @raise [Pago::NetworkError] when the request never reached the API.
122
+ # @return [Object]
123
+ def update(id, body: {})
124
+ data = client.request(
125
+ http_method: "PATCH",
126
+ path: "/v1/benefits/{id}",
127
+ path_params: { "id" => id },
128
+ query: {},
129
+ body: body,
130
+ response_type: :json,
131
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
132
+ )
133
+ Unions::Benefit.from_json(data)
134
+ end
135
+
136
+ # List the individual grants for a benefit.
137
+ #
138
+ # It's especially useful to check if a user has been granted a benefit.
139
+ #
140
+ # **Scopes**: `benefits:read` `benefits:write`
141
+ #
142
+ # @param id [String]
143
+ # @param is_granted [Boolean, nil] Filter by granted status. If `true`, only granted benefits will be returned. If `false`, only revoked benefits will be returned.
144
+ # @param customer_id [String, Array<String>, nil] Filter by customer.
145
+ # @param member_id [String, Array<String>, nil] Filter by member.
146
+ # @param page [Integer] Page number, defaults to 1.
147
+ # @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
148
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
149
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
150
+ # @raise [Pago::NetworkError] when the request never reached the API.
151
+ # @return [Models::ListResourceBenefitGrant]
152
+ def grants(id, is_granted: nil, customer_id: nil, member_id: nil, page: 1, limit: 10)
153
+ data = client.request(
154
+ http_method: "GET",
155
+ path: "/v1/benefits/{id}/grants",
156
+ path_params: { "id" => id },
157
+ query: { "is_granted" => is_granted, "customer_id" => customer_id, "member_id" => member_id, "page" => page, "limit" => limit },
158
+ response_type: :json,
159
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
160
+ )
161
+ Models::ListResourceBenefitGrant.from_json(data)
162
+ end
163
+
164
+ # Enumerate every item of `grants`, fetching pages on demand.
165
+ #
166
+ # @yieldparam item [Models::BenefitGrant]
167
+ # @return [Pago::Paginator] when called without a block.
168
+ def grants_each(id, is_granted: nil, customer_id: nil, member_id: nil, limit: 10, &block)
169
+ paginator = ::Pago::Paginator.new do |page_number|
170
+ grants(id, is_granted: is_granted, customer_id: customer_id, member_id: member_id, page: page_number, limit: limit)
171
+ end
172
+ block ? paginator.each(&block) : paginator
173
+ end
174
+
175
+ end
176
+
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pago
4
+ module V2026_04
5
+ module Services
6
+ class CheckoutLinks < ::Pago::Service
7
+ # List checkout links.
8
+ #
9
+ # **Scopes**: `checkout_links:read` `checkout_links: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 page [Integer] Page number, defaults to 1.
14
+ # @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
15
+ # @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.
16
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
17
+ # @raise [Pago::NetworkError] when the request never reached the API.
18
+ # @return [Models::ListResourceCheckoutLink]
19
+ def list(organization_id: nil, product_id: nil, page: 1, limit: 10, sorting: ["created_at"])
20
+ data = client.request(
21
+ http_method: "GET",
22
+ path: "/v1/checkout-links/",
23
+ path_params: {},
24
+ query: { "organization_id" => organization_id, "product_id" => product_id, "page" => page, "limit" => limit, "sorting" => sorting },
25
+ response_type: :json,
26
+ errors: { 422 => Errors::HTTPValidationError }
27
+ )
28
+ Models::ListResourceCheckoutLink.from_json(data)
29
+ end
30
+
31
+ # Enumerate every item of `list`, fetching pages on demand.
32
+ #
33
+ # @yieldparam item [Models::CheckoutLink]
34
+ # @return [Pago::Paginator] when called without a block.
35
+ def list_each(organization_id: nil, product_id: nil, limit: 10, sorting: ["created_at"], &block)
36
+ paginator = ::Pago::Paginator.new do |page_number|
37
+ list(organization_id: organization_id, product_id: product_id, page: page_number, limit: limit, sorting: sorting)
38
+ end
39
+ block ? paginator.each(&block) : paginator
40
+ end
41
+
42
+ # Create a checkout link.
43
+ #
44
+ # **Scopes**: `checkout_links:write`
45
+ #
46
+ # @param body [Hash, Object] the request body.
47
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
48
+ # @raise [Pago::NetworkError] when the request never reached the API.
49
+ # @return [Models::CheckoutLink]
50
+ def create(body: {})
51
+ data = client.request(
52
+ http_method: "POST",
53
+ path: "/v1/checkout-links/",
54
+ path_params: {},
55
+ query: {},
56
+ body: body,
57
+ response_type: :json,
58
+ errors: { 422 => Errors::HTTPValidationError }
59
+ )
60
+ Models::CheckoutLink.from_json(data)
61
+ end
62
+
63
+ # Get a checkout link by ID.
64
+ #
65
+ # **Scopes**: `checkout_links:read` `checkout_links:write`
66
+ #
67
+ # @param id [String] The checkout link ID.
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::CheckoutLink]
72
+ def get(id)
73
+ data = client.request(
74
+ http_method: "GET",
75
+ path: "/v1/checkout-links/{id}",
76
+ path_params: { "id" => id },
77
+ query: {},
78
+ response_type: :json,
79
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
80
+ )
81
+ Models::CheckoutLink.from_json(data)
82
+ end
83
+
84
+ # Delete a checkout link.
85
+ #
86
+ # **Scopes**: `checkout_links:write`
87
+ #
88
+ # @param id [String] The checkout link ID.
89
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
90
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
91
+ # @raise [Pago::NetworkError] when the request never reached the API.
92
+ # @return [nil]
93
+ def delete(id)
94
+ client.request(
95
+ http_method: "DELETE",
96
+ path: "/v1/checkout-links/{id}",
97
+ path_params: { "id" => id },
98
+ query: {},
99
+ response_type: :none,
100
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
101
+ )
102
+ end
103
+
104
+ # Update a checkout link.
105
+ #
106
+ # **Scopes**: `checkout_links:write`
107
+ #
108
+ # @param id [String] The checkout link ID.
109
+ # @param body [Hash, Models::CheckoutLinkUpdate] the request body.
110
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
111
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
112
+ # @raise [Pago::NetworkError] when the request never reached the API.
113
+ # @return [Models::CheckoutLink]
114
+ def update(id, body: {})
115
+ data = client.request(
116
+ http_method: "PATCH",
117
+ path: "/v1/checkout-links/{id}",
118
+ path_params: { "id" => id },
119
+ query: {},
120
+ body: body,
121
+ response_type: :json,
122
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
123
+ )
124
+ Models::CheckoutLink.from_json(data)
125
+ end
126
+
127
+ end
128
+
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,185 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pago
4
+ module V2026_04
5
+ module Services
6
+ class Checkouts < ::Pago::Service
7
+ # List checkout sessions.
8
+ #
9
+ # **Scopes**: `checkouts:read` `checkouts: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 status [String, Array<String>, nil] Filter by checkout session status.
16
+ # @param query [String, nil] Filter by customer email.
17
+ # @param page [Integer] Page number, defaults to 1.
18
+ # @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
19
+ # @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.
20
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
21
+ # @raise [Pago::NetworkError] when the request never reached the API.
22
+ # @return [Models::ListResourceCheckout]
23
+ def list(organization_id: nil, product_id: nil, customer_id: nil, external_customer_id: nil, status: nil, query: nil, page: 1, limit: 10, sorting: ["-created_at"])
24
+ data = client.request(
25
+ http_method: "GET",
26
+ path: "/v1/checkouts/",
27
+ path_params: {},
28
+ query: { "organization_id" => organization_id, "product_id" => product_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "status" => status, "query" => query, "page" => page, "limit" => limit, "sorting" => sorting },
29
+ response_type: :json,
30
+ errors: { 422 => Errors::HTTPValidationError }
31
+ )
32
+ Models::ListResourceCheckout.from_json(data)
33
+ end
34
+
35
+ # Enumerate every item of `list`, fetching pages on demand.
36
+ #
37
+ # @yieldparam item [Models::Checkout]
38
+ # @return [Pago::Paginator] when called without a block.
39
+ def list_each(organization_id: nil, product_id: nil, customer_id: nil, external_customer_id: nil, status: nil, query: nil, limit: 10, sorting: ["-created_at"], &block)
40
+ paginator = ::Pago::Paginator.new do |page_number|
41
+ list(organization_id: organization_id, product_id: product_id, customer_id: customer_id, external_customer_id: external_customer_id, status: status, query: query, page: page_number, limit: limit, sorting: sorting)
42
+ end
43
+ block ? paginator.each(&block) : paginator
44
+ end
45
+
46
+ # Create a checkout session.
47
+ #
48
+ # **Scopes**: `checkouts:write`
49
+ #
50
+ # @param body [Hash, Models::CheckoutCreate] the request body.
51
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
52
+ # @raise [Pago::NetworkError] when the request never reached the API.
53
+ # @return [Models::Checkout]
54
+ def create(body: {})
55
+ data = client.request(
56
+ http_method: "POST",
57
+ path: "/v1/checkouts/",
58
+ path_params: {},
59
+ query: {},
60
+ body: body,
61
+ response_type: :json,
62
+ errors: { 422 => Errors::HTTPValidationError }
63
+ )
64
+ Models::Checkout.from_json(data)
65
+ end
66
+
67
+ # Get a checkout session by ID.
68
+ #
69
+ # **Scopes**: `checkouts:read` `checkouts:write`
70
+ #
71
+ # @param id [String] The checkout session ID.
72
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
73
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
74
+ # @raise [Pago::NetworkError] when the request never reached the API.
75
+ # @return [Models::Checkout]
76
+ def get(id)
77
+ data = client.request(
78
+ http_method: "GET",
79
+ path: "/v1/checkouts/{id}",
80
+ path_params: { "id" => id },
81
+ query: {},
82
+ response_type: :json,
83
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
84
+ )
85
+ Models::Checkout.from_json(data)
86
+ end
87
+
88
+ # Update a checkout session.
89
+ #
90
+ # **Scopes**: `checkouts:write`
91
+ #
92
+ # @param id [String] The checkout session ID.
93
+ # @param body [Hash, Models::CheckoutUpdate] the request body.
94
+ # @raise [Errors::Update403Error] on HTTP 403.
95
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
96
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
97
+ # @raise [Pago::NetworkError] when the request never reached the API.
98
+ # @return [Models::Checkout]
99
+ def update(id, body: {})
100
+ data = client.request(
101
+ http_method: "PATCH",
102
+ path: "/v1/checkouts/{id}",
103
+ path_params: { "id" => id },
104
+ query: {},
105
+ body: body,
106
+ response_type: :json,
107
+ errors: { 403 => Errors::Update403Error, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
108
+ )
109
+ Models::Checkout.from_json(data)
110
+ end
111
+
112
+ # Get a checkout session by client secret.
113
+ #
114
+ # @param client_secret [String] The checkout session client secret.
115
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
116
+ # @raise [Errors::ExpiredCheckoutError] on HTTP 410.
117
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
118
+ # @raise [Pago::NetworkError] when the request never reached the API.
119
+ # @return [Models::CheckoutPublic]
120
+ def client_get(client_secret)
121
+ data = client.request(
122
+ http_method: "GET",
123
+ path: "/v1/checkouts/client/{client_secret}",
124
+ path_params: { "client_secret" => client_secret },
125
+ query: {},
126
+ response_type: :json,
127
+ errors: { 404 => Errors::ResourceNotFound, 410 => Errors::ExpiredCheckoutError, 422 => Errors::HTTPValidationError }
128
+ )
129
+ Models::CheckoutPublic.from_json(data)
130
+ end
131
+
132
+ # Update a checkout session by client secret.
133
+ #
134
+ # @param client_secret [String] The checkout session client secret.
135
+ # @param body [Hash, Models::CheckoutUpdatePublic] the request body.
136
+ # @raise [Errors::ClientUpdate403Error] on HTTP 403.
137
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
138
+ # @raise [Errors::ExpiredCheckoutError] on HTTP 410.
139
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
140
+ # @raise [Pago::NetworkError] when the request never reached the API.
141
+ # @return [Models::CheckoutPublic]
142
+ def client_update(client_secret, body: {})
143
+ data = client.request(
144
+ http_method: "PATCH",
145
+ path: "/v1/checkouts/client/{client_secret}",
146
+ path_params: { "client_secret" => client_secret },
147
+ query: {},
148
+ body: body,
149
+ response_type: :json,
150
+ errors: { 403 => Errors::ClientUpdate403Error, 404 => Errors::ResourceNotFound, 410 => Errors::ExpiredCheckoutError, 422 => Errors::HTTPValidationError }
151
+ )
152
+ Models::CheckoutPublic.from_json(data)
153
+ end
154
+
155
+ # Confirm a checkout session by client secret.
156
+ #
157
+ # Orders and subscriptions will be processed.
158
+ #
159
+ # @param client_secret [String] The checkout session client secret.
160
+ # @param body [Hash, Models::CheckoutConfirmStripe] the request body.
161
+ # @raise [Errors::PaymentError] on HTTP 400.
162
+ # @raise [Errors::ClientConfirm403Error] on HTTP 403.
163
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
164
+ # @raise [Errors::ExpiredCheckoutError] on HTTP 410.
165
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
166
+ # @raise [Pago::NetworkError] when the request never reached the API.
167
+ # @return [Models::CheckoutPublicConfirmed]
168
+ def client_confirm(client_secret, body: {})
169
+ data = client.request(
170
+ http_method: "POST",
171
+ path: "/v1/checkouts/client/{client_secret}/confirm",
172
+ path_params: { "client_secret" => client_secret },
173
+ query: {},
174
+ body: body,
175
+ response_type: :json,
176
+ errors: { 400 => Errors::PaymentError, 403 => Errors::ClientConfirm403Error, 404 => Errors::ResourceNotFound, 410 => Errors::ExpiredCheckoutError, 422 => Errors::HTTPValidationError }
177
+ )
178
+ Models::CheckoutPublicConfirmed.from_json(data)
179
+ end
180
+
181
+ end
182
+
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pago
4
+ module V2026_04
5
+ module Services
6
+ class CustomFields < ::Pago::Service
7
+ # List custom fields.
8
+ #
9
+ # **Scopes**: `custom_fields:read` `custom_fields:write`
10
+ #
11
+ # @param organization_id [String, Array<String>, nil] Filter by organization ID.
12
+ # @param query [String, nil] Filter by custom field name or slug.
13
+ # @param type [String, Array<String>, nil] Filter by custom field type.
14
+ # @param page [Integer] Page number, defaults to 1.
15
+ # @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
16
+ # @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.
17
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
18
+ # @raise [Pago::NetworkError] when the request never reached the API.
19
+ # @return [Models::ListResourceCustomField]
20
+ def list(organization_id: nil, query: nil, type: nil, page: 1, limit: 10, sorting: ["slug"])
21
+ data = client.request(
22
+ http_method: "GET",
23
+ path: "/v1/custom-fields/",
24
+ path_params: {},
25
+ query: { "organization_id" => organization_id, "query" => query, "type" => type, "page" => page, "limit" => limit, "sorting" => sorting },
26
+ response_type: :json,
27
+ errors: { 422 => Errors::HTTPValidationError }
28
+ )
29
+ Models::ListResourceCustomField.from_json(data)
30
+ end
31
+
32
+ # Enumerate every item of `list`, fetching pages on demand.
33
+ #
34
+ # @yieldparam item [Object]
35
+ # @return [Pago::Paginator] when called without a block.
36
+ def list_each(organization_id: nil, query: nil, type: nil, limit: 10, sorting: ["slug"], &block)
37
+ paginator = ::Pago::Paginator.new do |page_number|
38
+ list(organization_id: organization_id, query: query, type: type, page: page_number, limit: limit, sorting: sorting)
39
+ end
40
+ block ? paginator.each(&block) : paginator
41
+ end
42
+
43
+ # Create a custom field.
44
+ #
45
+ # **Scopes**: `custom_fields:write`
46
+ #
47
+ # @param body [Hash, Object] the request body.
48
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
49
+ # @raise [Pago::NetworkError] when the request never reached the API.
50
+ # @return [Object]
51
+ def create(body: {})
52
+ data = client.request(
53
+ http_method: "POST",
54
+ path: "/v1/custom-fields/",
55
+ path_params: {},
56
+ query: {},
57
+ body: body,
58
+ response_type: :json,
59
+ errors: { 422 => Errors::HTTPValidationError }
60
+ )
61
+ Unions::CustomField.from_json(data)
62
+ end
63
+
64
+ # Get a custom field by ID.
65
+ #
66
+ # **Scopes**: `custom_fields:read` `custom_fields:write`
67
+ #
68
+ # @param id [String] The custom field ID.
69
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
70
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
71
+ # @raise [Pago::NetworkError] when the request never reached the API.
72
+ # @return [Object]
73
+ def get(id)
74
+ data = client.request(
75
+ http_method: "GET",
76
+ path: "/v1/custom-fields/{id}",
77
+ path_params: { "id" => id },
78
+ query: {},
79
+ response_type: :json,
80
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
81
+ )
82
+ Unions::CustomField.from_json(data)
83
+ end
84
+
85
+ # Delete a custom field.
86
+ #
87
+ # **Scopes**: `custom_fields:write`
88
+ #
89
+ # @param id [String] The custom field ID.
90
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
91
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
92
+ # @raise [Pago::NetworkError] when the request never reached the API.
93
+ # @return [nil]
94
+ def delete(id)
95
+ client.request(
96
+ http_method: "DELETE",
97
+ path: "/v1/custom-fields/{id}",
98
+ path_params: { "id" => id },
99
+ query: {},
100
+ response_type: :none,
101
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
102
+ )
103
+ end
104
+
105
+ # Update a custom field.
106
+ #
107
+ # **Scopes**: `custom_fields:write`
108
+ #
109
+ # @param id [String] The custom field ID.
110
+ # @param body [Hash, Object] the request body.
111
+ # @raise [Errors::ResourceNotFound] on HTTP 404.
112
+ # @raise [Errors::HTTPValidationError] on HTTP 422.
113
+ # @raise [Pago::NetworkError] when the request never reached the API.
114
+ # @return [Object]
115
+ def update(id, body: {})
116
+ data = client.request(
117
+ http_method: "PATCH",
118
+ path: "/v1/custom-fields/{id}",
119
+ path_params: { "id" => id },
120
+ query: {},
121
+ body: body,
122
+ response_type: :json,
123
+ errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
124
+ )
125
+ Unions::CustomField.from_json(data)
126
+ end
127
+
128
+ end
129
+
130
+ end
131
+ end
132
+ end