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,142 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Meters < ::Pago::Service
|
|
7
|
+
# List meters.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `meters:read` `meters:write`
|
|
10
|
+
#
|
|
11
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
12
|
+
# @param query [String, nil] Filter by name.
|
|
13
|
+
# @param is_archived [Boolean, nil] Filter on archived meters.
|
|
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
|
+
# @param metadata [Object] Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.
|
|
18
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
19
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
20
|
+
# @return [Models::ListResourceMeter]
|
|
21
|
+
def list(organization_id: nil, query: nil, is_archived: nil, page: 1, limit: 10, sorting: ["name"], metadata: nil)
|
|
22
|
+
data = client.request(
|
|
23
|
+
http_method: "GET",
|
|
24
|
+
path: "/v1/meters/",
|
|
25
|
+
path_params: {},
|
|
26
|
+
query: { "organization_id" => organization_id, "query" => query, "is_archived" => is_archived, "page" => page, "limit" => limit, "sorting" => sorting, "metadata" => metadata },
|
|
27
|
+
response_type: :json,
|
|
28
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
29
|
+
)
|
|
30
|
+
Models::ListResourceMeter.from_json(data)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
34
|
+
#
|
|
35
|
+
# @yieldparam item [Models::Meter]
|
|
36
|
+
# @return [Pago::Paginator] when called without a block.
|
|
37
|
+
def list_each(organization_id: nil, query: nil, is_archived: nil, limit: 10, sorting: ["name"], metadata: nil, &block)
|
|
38
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
39
|
+
list(organization_id: organization_id, query: query, is_archived: is_archived, page: page_number, limit: limit, sorting: sorting, metadata: metadata)
|
|
40
|
+
end
|
|
41
|
+
block ? paginator.each(&block) : paginator
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Create a meter.
|
|
45
|
+
#
|
|
46
|
+
# **Scopes**: `meters:write`
|
|
47
|
+
#
|
|
48
|
+
# @param body [Hash, Models::MeterCreate] the request body.
|
|
49
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
50
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
51
|
+
# @return [Models::Meter]
|
|
52
|
+
def create(body: {})
|
|
53
|
+
data = client.request(
|
|
54
|
+
http_method: "POST",
|
|
55
|
+
path: "/v1/meters/",
|
|
56
|
+
path_params: {},
|
|
57
|
+
query: {},
|
|
58
|
+
body: body,
|
|
59
|
+
response_type: :json,
|
|
60
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
61
|
+
)
|
|
62
|
+
Models::Meter.from_json(data)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Get a meter by ID.
|
|
66
|
+
#
|
|
67
|
+
# **Scopes**: `meters:read` `meters:write`
|
|
68
|
+
#
|
|
69
|
+
# @param id [String] The meter ID.
|
|
70
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
71
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
72
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
73
|
+
# @return [Models::Meter]
|
|
74
|
+
def get(id)
|
|
75
|
+
data = client.request(
|
|
76
|
+
http_method: "GET",
|
|
77
|
+
path: "/v1/meters/{id}",
|
|
78
|
+
path_params: { "id" => id },
|
|
79
|
+
query: {},
|
|
80
|
+
response_type: :json,
|
|
81
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
82
|
+
)
|
|
83
|
+
Models::Meter.from_json(data)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Update a meter.
|
|
87
|
+
#
|
|
88
|
+
# **Scopes**: `meters:write`
|
|
89
|
+
#
|
|
90
|
+
# @param id [String] The meter ID.
|
|
91
|
+
# @param body [Hash, Models::MeterUpdate] the request body.
|
|
92
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
93
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
94
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
95
|
+
# @return [Models::Meter]
|
|
96
|
+
def update(id, body: {})
|
|
97
|
+
data = client.request(
|
|
98
|
+
http_method: "PATCH",
|
|
99
|
+
path: "/v1/meters/{id}",
|
|
100
|
+
path_params: { "id" => id },
|
|
101
|
+
query: {},
|
|
102
|
+
body: body,
|
|
103
|
+
response_type: :json,
|
|
104
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
105
|
+
)
|
|
106
|
+
Models::Meter.from_json(data)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Get quantities of a meter over a time period.
|
|
110
|
+
#
|
|
111
|
+
# **Scopes**: `meters:read` `meters:write`
|
|
112
|
+
#
|
|
113
|
+
# @param id [String] The meter ID.
|
|
114
|
+
# @param start_timestamp [String] Start timestamp.
|
|
115
|
+
# @param end_timestamp [String] End timestamp.
|
|
116
|
+
# @param interval [String] Interval between two timestamps.
|
|
117
|
+
# @param timezone [String] Timezone to use for the timestamps. Default is UTC.
|
|
118
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
119
|
+
# @param external_customer_id [String, Array<String>, nil] Filter by external customer ID.
|
|
120
|
+
# @param customer_aggregation_function [String, nil] If set, will first compute the quantities per customer before aggregating them using the given function. If not set, the quantities will be aggregated across all events.
|
|
121
|
+
# @param metadata [Object] Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.
|
|
122
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
123
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
124
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
125
|
+
# @return [Models::MeterQuantities]
|
|
126
|
+
def quantities(id, start_timestamp:, end_timestamp:, interval:, timezone: "UTC", customer_id: nil, external_customer_id: nil, customer_aggregation_function: nil, metadata: nil)
|
|
127
|
+
data = client.request(
|
|
128
|
+
http_method: "GET",
|
|
129
|
+
path: "/v1/meters/{id}/quantities",
|
|
130
|
+
path_params: { "id" => id },
|
|
131
|
+
query: { "start_timestamp" => start_timestamp, "end_timestamp" => end_timestamp, "interval" => interval, "timezone" => timezone, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "customer_aggregation_function" => customer_aggregation_function, "metadata" => metadata },
|
|
132
|
+
response_type: :json,
|
|
133
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
134
|
+
)
|
|
135
|
+
Models::MeterQuantities.from_json(data)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Metrics < ::Pago::Service
|
|
7
|
+
# Get metrics about your orders and subscriptions.
|
|
8
|
+
#
|
|
9
|
+
# Currency values are output in cents.
|
|
10
|
+
#
|
|
11
|
+
# **Scopes**: `metrics:read`
|
|
12
|
+
#
|
|
13
|
+
# @param start_date [String] Start date.
|
|
14
|
+
# @param end_date [String] End date.
|
|
15
|
+
# @param timezone [String] Timezone to use for the timestamps. Default is UTC.
|
|
16
|
+
# @param interval [String] Interval between two timestamps.
|
|
17
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
18
|
+
# @param product_id [String, Array<String>, nil] Filter by product ID.
|
|
19
|
+
# @param billing_type [String, Array<String>, nil] Filter by billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases.
|
|
20
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
21
|
+
# @param metrics [Array<String>, nil] List of metric slugs to focus on. When provided, only the queries needed for these metrics will be executed, improving performance. If not provided, all metrics are returned.
|
|
22
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
23
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
24
|
+
# @return [Models::MetricsResponse]
|
|
25
|
+
def get(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil)
|
|
26
|
+
data = client.request(
|
|
27
|
+
http_method: "GET",
|
|
28
|
+
path: "/v1/metrics/",
|
|
29
|
+
path_params: {},
|
|
30
|
+
query: { "start_date" => start_date, "end_date" => end_date, "timezone" => timezone, "interval" => interval, "organization_id" => organization_id, "product_id" => product_id, "billing_type" => billing_type, "customer_id" => customer_id, "metrics" => metrics },
|
|
31
|
+
response_type: :json,
|
|
32
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
33
|
+
)
|
|
34
|
+
Models::MetricsResponse.from_json(data)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Export metrics as a CSV file.
|
|
38
|
+
#
|
|
39
|
+
# **Scopes**: `metrics:read`
|
|
40
|
+
#
|
|
41
|
+
# @param start_date [String] Start date.
|
|
42
|
+
# @param end_date [String] End date.
|
|
43
|
+
# @param timezone [String] Timezone to use for the timestamps. Default is UTC.
|
|
44
|
+
# @param interval [String] Interval between two timestamps.
|
|
45
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
46
|
+
# @param product_id [String, Array<String>, nil] Filter by product ID.
|
|
47
|
+
# @param billing_type [String, Array<String>, nil] Filter by billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases.
|
|
48
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
49
|
+
# @param metrics [Array<String>, nil] List of metric slugs to include in the export. If not provided, all metrics are exported.
|
|
50
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
51
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
52
|
+
# @return [String]
|
|
53
|
+
def export(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil)
|
|
54
|
+
client.request(
|
|
55
|
+
http_method: "GET",
|
|
56
|
+
path: "/v1/metrics/export",
|
|
57
|
+
path_params: {},
|
|
58
|
+
query: { "start_date" => start_date, "end_date" => end_date, "timezone" => timezone, "interval" => interval, "organization_id" => organization_id, "product_id" => product_id, "billing_type" => billing_type, "customer_id" => customer_id, "metrics" => metrics },
|
|
59
|
+
response_type: :text,
|
|
60
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Get the interval limits for the metrics endpoint.
|
|
65
|
+
#
|
|
66
|
+
# **Scopes**: `metrics:read`
|
|
67
|
+
#
|
|
68
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
69
|
+
# @return [Models::MetricsLimits]
|
|
70
|
+
def limits()
|
|
71
|
+
data = client.request(
|
|
72
|
+
http_method: "GET",
|
|
73
|
+
path: "/v1/metrics/limits",
|
|
74
|
+
path_params: {},
|
|
75
|
+
query: {},
|
|
76
|
+
response_type: :json,
|
|
77
|
+
errors: { }
|
|
78
|
+
)
|
|
79
|
+
Models::MetricsLimits.from_json(data)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# List user-defined metric dashboards.
|
|
83
|
+
#
|
|
84
|
+
# **Scopes**: `metrics:read`
|
|
85
|
+
#
|
|
86
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
87
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
88
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
89
|
+
# @return [Array<Models::MetricDashboardSchema>]
|
|
90
|
+
def list_dashboards(organization_id: nil)
|
|
91
|
+
data = client.request(
|
|
92
|
+
http_method: "GET",
|
|
93
|
+
path: "/v1/metrics/dashboards",
|
|
94
|
+
path_params: {},
|
|
95
|
+
query: { "organization_id" => organization_id },
|
|
96
|
+
response_type: :json,
|
|
97
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
98
|
+
)
|
|
99
|
+
::Pago::Serde.array(data) { |item0| Models::MetricDashboardSchema.from_json(item0) }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Create a user-defined metric dashboard.
|
|
103
|
+
#
|
|
104
|
+
# **Scopes**: `metrics:write`
|
|
105
|
+
#
|
|
106
|
+
# @param body [Hash, Models::MetricDashboardCreate] the request body.
|
|
107
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
108
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
109
|
+
# @return [Models::MetricDashboardSchema]
|
|
110
|
+
def create_dashboard(body: {})
|
|
111
|
+
data = client.request(
|
|
112
|
+
http_method: "POST",
|
|
113
|
+
path: "/v1/metrics/dashboards",
|
|
114
|
+
path_params: {},
|
|
115
|
+
query: {},
|
|
116
|
+
body: body,
|
|
117
|
+
response_type: :json,
|
|
118
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
119
|
+
)
|
|
120
|
+
Models::MetricDashboardSchema.from_json(data)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Get a user-defined metric dashboard by ID.
|
|
124
|
+
#
|
|
125
|
+
# **Scopes**: `metrics:read`
|
|
126
|
+
#
|
|
127
|
+
# @param id [String] The metric dashboard ID.
|
|
128
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
129
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
130
|
+
# @return [Models::MetricDashboardSchema]
|
|
131
|
+
def get_dashboard(id)
|
|
132
|
+
data = client.request(
|
|
133
|
+
http_method: "GET",
|
|
134
|
+
path: "/v1/metrics/dashboards/{id}",
|
|
135
|
+
path_params: { "id" => id },
|
|
136
|
+
query: {},
|
|
137
|
+
response_type: :json,
|
|
138
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
139
|
+
)
|
|
140
|
+
Models::MetricDashboardSchema.from_json(data)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Delete a user-defined metric dashboard.
|
|
144
|
+
#
|
|
145
|
+
# **Scopes**: `metrics:write`
|
|
146
|
+
#
|
|
147
|
+
# @param id [String] The metric dashboard ID.
|
|
148
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
149
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
150
|
+
# @return [nil]
|
|
151
|
+
def delete_dashboard(id)
|
|
152
|
+
client.request(
|
|
153
|
+
http_method: "DELETE",
|
|
154
|
+
path: "/v1/metrics/dashboards/{id}",
|
|
155
|
+
path_params: { "id" => id },
|
|
156
|
+
query: {},
|
|
157
|
+
response_type: :none,
|
|
158
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
159
|
+
)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Update a user-defined metric dashboard.
|
|
163
|
+
#
|
|
164
|
+
# **Scopes**: `metrics:write`
|
|
165
|
+
#
|
|
166
|
+
# @param id [String] The metric dashboard ID.
|
|
167
|
+
# @param body [Hash, Models::MetricDashboardUpdate] the request body.
|
|
168
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
169
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
170
|
+
# @return [Models::MetricDashboardSchema]
|
|
171
|
+
def update_dashboard(id, body: {})
|
|
172
|
+
data = client.request(
|
|
173
|
+
http_method: "PATCH",
|
|
174
|
+
path: "/v1/metrics/dashboards/{id}",
|
|
175
|
+
path_params: { "id" => id },
|
|
176
|
+
query: {},
|
|
177
|
+
body: body,
|
|
178
|
+
response_type: :json,
|
|
179
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
180
|
+
)
|
|
181
|
+
Models::MetricDashboardSchema.from_json(data)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Oauth2 < ::Pago::Service
|
|
7
|
+
# @return [Clients]
|
|
8
|
+
def clients = @clients ||= Clients.new(client)
|
|
9
|
+
|
|
10
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
11
|
+
# @return [Models::AuthorizeResponseUser, Models::AuthorizeResponseOrganization]
|
|
12
|
+
def authorize()
|
|
13
|
+
data = client.request(
|
|
14
|
+
http_method: "GET",
|
|
15
|
+
path: "/v1/oauth2/authorize",
|
|
16
|
+
path_params: {},
|
|
17
|
+
query: {},
|
|
18
|
+
response_type: :json,
|
|
19
|
+
errors: { }
|
|
20
|
+
)
|
|
21
|
+
::Pago::Serde.union(data, discriminator: "sub_type", mapping: { "organization" => Models::AuthorizeResponseOrganization, "user" => Models::AuthorizeResponseUser }, variants: [Models::AuthorizeResponseUser, Models::AuthorizeResponseOrganization])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Request an access token using a valid grant.
|
|
25
|
+
#
|
|
26
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
27
|
+
# @return [Models::TokenResponse]
|
|
28
|
+
def request_token()
|
|
29
|
+
data = client.request(
|
|
30
|
+
http_method: "POST",
|
|
31
|
+
path: "/v1/oauth2/token",
|
|
32
|
+
path_params: {},
|
|
33
|
+
query: {},
|
|
34
|
+
response_type: :json,
|
|
35
|
+
errors: { }
|
|
36
|
+
)
|
|
37
|
+
Models::TokenResponse.from_json(data)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Revoke an access token or a refresh token.
|
|
41
|
+
#
|
|
42
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
43
|
+
# @return [Models::RevokeTokenResponse]
|
|
44
|
+
def revoke_token()
|
|
45
|
+
data = client.request(
|
|
46
|
+
http_method: "POST",
|
|
47
|
+
path: "/v1/oauth2/revoke",
|
|
48
|
+
path_params: {},
|
|
49
|
+
query: {},
|
|
50
|
+
response_type: :json,
|
|
51
|
+
errors: { }
|
|
52
|
+
)
|
|
53
|
+
Models::RevokeTokenResponse.from_json(data)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Get information about an access token.
|
|
57
|
+
#
|
|
58
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
59
|
+
# @return [Models::IntrospectTokenResponse]
|
|
60
|
+
def introspect_token()
|
|
61
|
+
data = client.request(
|
|
62
|
+
http_method: "POST",
|
|
63
|
+
path: "/v1/oauth2/introspect",
|
|
64
|
+
path_params: {},
|
|
65
|
+
query: {},
|
|
66
|
+
response_type: :json,
|
|
67
|
+
errors: { }
|
|
68
|
+
)
|
|
69
|
+
Models::IntrospectTokenResponse.from_json(data)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Get information about the authenticated user.
|
|
73
|
+
#
|
|
74
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
75
|
+
# @return [Models::UserInfoUser, Models::UserInfoOrganization]
|
|
76
|
+
def userinfo()
|
|
77
|
+
data = client.request(
|
|
78
|
+
http_method: "GET",
|
|
79
|
+
path: "/v1/oauth2/userinfo",
|
|
80
|
+
path_params: {},
|
|
81
|
+
query: {},
|
|
82
|
+
response_type: :json,
|
|
83
|
+
errors: { }
|
|
84
|
+
)
|
|
85
|
+
::Pago::Serde.union(data, variants: [Models::UserInfoUser, Models::UserInfoOrganization])
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class Clients < ::Pago::Service
|
|
89
|
+
# @return [Oauth2]
|
|
90
|
+
def oauth2 = @oauth2 ||= Oauth2.new(client)
|
|
91
|
+
|
|
92
|
+
class Oauth2 < ::Pago::Service
|
|
93
|
+
# Create an OAuth2 client.
|
|
94
|
+
#
|
|
95
|
+
# @param body [Hash, Models::OAuth2ClientConfiguration] the request body.
|
|
96
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
97
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
98
|
+
# @return [Object]
|
|
99
|
+
def create_client(body: {})
|
|
100
|
+
data = client.request(
|
|
101
|
+
http_method: "POST",
|
|
102
|
+
path: "/v1/oauth2/register",
|
|
103
|
+
path_params: {},
|
|
104
|
+
query: {},
|
|
105
|
+
body: body,
|
|
106
|
+
response_type: :json,
|
|
107
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
108
|
+
)
|
|
109
|
+
data
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Get an OAuth2 client by Client ID.
|
|
113
|
+
#
|
|
114
|
+
# @param client_id [String]
|
|
115
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
116
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
117
|
+
# @return [Object]
|
|
118
|
+
def get_client(client_id)
|
|
119
|
+
data = client.request(
|
|
120
|
+
http_method: "GET",
|
|
121
|
+
path: "/v1/oauth2/register/{client_id}",
|
|
122
|
+
path_params: { "client_id" => client_id },
|
|
123
|
+
query: {},
|
|
124
|
+
response_type: :json,
|
|
125
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
126
|
+
)
|
|
127
|
+
data
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Update an OAuth2 client.
|
|
131
|
+
#
|
|
132
|
+
# @param client_id_path [String]
|
|
133
|
+
# @param body [Hash, Models::OAuth2ClientConfigurationUpdate] the request body.
|
|
134
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
135
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
136
|
+
# @return [Object]
|
|
137
|
+
def update_client(client_id_path, body: {})
|
|
138
|
+
data = client.request(
|
|
139
|
+
http_method: "PUT",
|
|
140
|
+
path: "/v1/oauth2/register/{client_id}",
|
|
141
|
+
path_params: { "client_id" => client_id_path },
|
|
142
|
+
query: {},
|
|
143
|
+
body: body,
|
|
144
|
+
response_type: :json,
|
|
145
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
146
|
+
)
|
|
147
|
+
data
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Delete an OAuth2 client.
|
|
151
|
+
#
|
|
152
|
+
# @param client_id [String]
|
|
153
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
154
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
155
|
+
# @return [nil]
|
|
156
|
+
def delete_client(client_id)
|
|
157
|
+
client.request(
|
|
158
|
+
http_method: "DELETE",
|
|
159
|
+
path: "/v1/oauth2/register/{client_id}",
|
|
160
|
+
path_params: { "client_id" => client_id },
|
|
161
|
+
query: {},
|
|
162
|
+
response_type: :none,
|
|
163
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
164
|
+
)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|