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,93 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Disputes < ::Pago::Service
|
|
7
|
+
# List disputes.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `disputes:read` `disputes:write`
|
|
10
|
+
#
|
|
11
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
12
|
+
# @param order_id [String, Array<String>, nil] Filter by order ID.
|
|
13
|
+
# @param status [String, Array<String>, nil] Filter by dispute status.
|
|
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::ListResourceDispute]
|
|
20
|
+
def list(organization_id: nil, order_id: nil, status: nil, page: 1, limit: 10, sorting: ["-created_at"])
|
|
21
|
+
data = client.request(
|
|
22
|
+
http_method: "GET",
|
|
23
|
+
path: "/v1/disputes/",
|
|
24
|
+
path_params: {},
|
|
25
|
+
query: { "organization_id" => organization_id, "order_id" => order_id, "status" => status, "page" => page, "limit" => limit, "sorting" => sorting },
|
|
26
|
+
response_type: :json,
|
|
27
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
28
|
+
)
|
|
29
|
+
Models::ListResourceDispute.from_json(data)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
33
|
+
#
|
|
34
|
+
# @yieldparam item [Models::Dispute]
|
|
35
|
+
# @return [Pago::Paginator] when called without a block.
|
|
36
|
+
def list_each(organization_id: nil, order_id: nil, status: nil, limit: 10, sorting: ["-created_at"], &block)
|
|
37
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
38
|
+
list(organization_id: organization_id, order_id: order_id, status: status, page: page_number, limit: limit, sorting: sorting)
|
|
39
|
+
end
|
|
40
|
+
block ? paginator.each(&block) : paginator
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Get a dispute by ID.
|
|
44
|
+
#
|
|
45
|
+
# **Scopes**: `disputes:read` `disputes:write`
|
|
46
|
+
#
|
|
47
|
+
# @param id [String] The dispute ID.
|
|
48
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
49
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
50
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
51
|
+
# @return [Models::Dispute]
|
|
52
|
+
def get(id)
|
|
53
|
+
data = client.request(
|
|
54
|
+
http_method: "GET",
|
|
55
|
+
path: "/v1/disputes/{id}",
|
|
56
|
+
path_params: { "id" => id },
|
|
57
|
+
query: {},
|
|
58
|
+
response_type: :json,
|
|
59
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
60
|
+
)
|
|
61
|
+
Models::Dispute.from_json(data)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Accept a dispute, conceding the chargeback.
|
|
65
|
+
#
|
|
66
|
+
# Closes the dispute with the processor (settling it as `lost`) and records
|
|
67
|
+
# the merchant's decision on the dispute's support case.
|
|
68
|
+
#
|
|
69
|
+
# **Scopes**: `disputes:write`
|
|
70
|
+
#
|
|
71
|
+
# @param id [String] The dispute ID.
|
|
72
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
73
|
+
# @raise [Errors::DisputeNotOpenError] on HTTP 409.
|
|
74
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
75
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
76
|
+
# @return [Models::Dispute]
|
|
77
|
+
def accept(id)
|
|
78
|
+
data = client.request(
|
|
79
|
+
http_method: "POST",
|
|
80
|
+
path: "/v1/disputes/{id}/accept",
|
|
81
|
+
path_params: { "id" => id },
|
|
82
|
+
query: {},
|
|
83
|
+
response_type: :json,
|
|
84
|
+
errors: { 404 => Errors::ResourceNotFound, 409 => Errors::DisputeNotOpenError, 422 => Errors::HTTPValidationError }
|
|
85
|
+
)
|
|
86
|
+
Models::Dispute.from_json(data)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class EventTypes < ::Pago::Service
|
|
7
|
+
# List event types with aggregated statistics.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `events:read` `events: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 external customer ID.
|
|
14
|
+
# @param query [String, nil] Query to filter event types by name or label.
|
|
15
|
+
# @param root_events [Boolean] When true, only return event types with root events (parent_id IS NULL).
|
|
16
|
+
# @param parent_id [String, nil] Filter by specific parent event ID.
|
|
17
|
+
# @param source [String, nil] Filter by event source (system or user).
|
|
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::ListResourceEventTypeWithStats]
|
|
24
|
+
def list(organization_id: nil, customer_id: nil, external_customer_id: nil, query: nil, root_events: false, parent_id: nil, source: nil, page: 1, limit: 10, sorting: ["-last_seen"])
|
|
25
|
+
data = client.request(
|
|
26
|
+
http_method: "GET",
|
|
27
|
+
path: "/v1/event-types/",
|
|
28
|
+
path_params: {},
|
|
29
|
+
query: { "organization_id" => organization_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "query" => query, "root_events" => root_events, "parent_id" => parent_id, "source" => source, "page" => page, "limit" => limit, "sorting" => sorting },
|
|
30
|
+
response_type: :json,
|
|
31
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
32
|
+
)
|
|
33
|
+
Models::ListResourceEventTypeWithStats.from_json(data)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
37
|
+
#
|
|
38
|
+
# @yieldparam item [Models::EventTypeWithStats]
|
|
39
|
+
# @return [Pago::Paginator] when called without a block.
|
|
40
|
+
def list_each(organization_id: nil, customer_id: nil, external_customer_id: nil, query: nil, root_events: false, parent_id: nil, source: nil, limit: 10, sorting: ["-last_seen"], &block)
|
|
41
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
42
|
+
list(organization_id: organization_id, customer_id: customer_id, external_customer_id: external_customer_id, query: query, root_events: root_events, parent_id: parent_id, source: source, page: page_number, limit: limit, sorting: sorting)
|
|
43
|
+
end
|
|
44
|
+
block ? paginator.each(&block) : paginator
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Update an event type's label.
|
|
48
|
+
#
|
|
49
|
+
# **Scopes**: `events:write`
|
|
50
|
+
#
|
|
51
|
+
# @param id [String] The event type ID.
|
|
52
|
+
# @param body [Hash, Models::EventTypeUpdate] the request body.
|
|
53
|
+
# @raise [Errors::Update404Error] on HTTP 404.
|
|
54
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
55
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
56
|
+
# @return [Models::EventType]
|
|
57
|
+
def update(id, body: {})
|
|
58
|
+
data = client.request(
|
|
59
|
+
http_method: "PATCH",
|
|
60
|
+
path: "/v1/event-types/{id}",
|
|
61
|
+
path_params: { "id" => id },
|
|
62
|
+
query: {},
|
|
63
|
+
body: body,
|
|
64
|
+
response_type: :json,
|
|
65
|
+
errors: { 404 => Errors::Update404Error, 422 => Errors::HTTPValidationError }
|
|
66
|
+
)
|
|
67
|
+
Models::EventType.from_json(data)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Events < ::Pago::Service
|
|
7
|
+
# List events.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `events:read` `events:write`
|
|
10
|
+
#
|
|
11
|
+
# @param filter [String, nil] Filter events following filter clauses. JSON string following the same schema a meter filter clause.
|
|
12
|
+
# @param start_timestamp [String, nil] Filter events after this timestamp.
|
|
13
|
+
# @param end_timestamp [String, nil] Filter events before this timestamp.
|
|
14
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
15
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
16
|
+
# @param external_customer_id [String, Array<String>, nil] Filter by external customer ID.
|
|
17
|
+
# @param meter_id [String, nil] Filter by a meter filter clause.
|
|
18
|
+
# @param name [String, Array<String>, nil] Filter by event name.
|
|
19
|
+
# @param source [String, Array<String>, nil] Filter by event source.
|
|
20
|
+
# @param query [String, nil] Query to filter events.
|
|
21
|
+
# @param parent_id [String, nil] When combined with depth, use this event as the anchor instead of root events.
|
|
22
|
+
# @param depth [Integer, nil] Fetch descendants up to this depth. When set: 0=root events only, 1=roots+children, etc. Max 5. When not set, returns all events.
|
|
23
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
24
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
25
|
+
# @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.
|
|
26
|
+
# @param metadata [Object] Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.
|
|
27
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
28
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
29
|
+
# @return [Models::ListResourceEvent, Models::ListResourceWithCursorPaginationEvent]
|
|
30
|
+
def list(filter: nil, start_timestamp: nil, end_timestamp: nil, organization_id: nil, customer_id: nil, external_customer_id: nil, meter_id: nil, name: nil, source: nil, query: nil, parent_id: nil, depth: nil, page: 1, limit: 10, sorting: ["-timestamp"], metadata: nil)
|
|
31
|
+
data = client.request(
|
|
32
|
+
http_method: "GET",
|
|
33
|
+
path: "/v1/events/",
|
|
34
|
+
path_params: {},
|
|
35
|
+
query: { "filter" => filter, "start_timestamp" => start_timestamp, "end_timestamp" => end_timestamp, "organization_id" => organization_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "meter_id" => meter_id, "name" => name, "source" => source, "query" => query, "parent_id" => parent_id, "depth" => depth, "page" => page, "limit" => limit, "sorting" => sorting, "metadata" => metadata },
|
|
36
|
+
response_type: :json,
|
|
37
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
38
|
+
)
|
|
39
|
+
::Pago::Serde.union(data, variants: [Models::ListResourceEvent, Models::ListResourceWithCursorPaginationEvent])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# List event names.
|
|
43
|
+
#
|
|
44
|
+
# **Scopes**: `events:read` `events:write`
|
|
45
|
+
#
|
|
46
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
47
|
+
# @param customer_id [String, Array<String>, nil] Filter by customer ID.
|
|
48
|
+
# @param external_customer_id [String, Array<String>, nil] Filter by external customer ID.
|
|
49
|
+
# @param source [String, Array<String>, nil] Filter by event source.
|
|
50
|
+
# @param query [String, nil] Query to filter event names.
|
|
51
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
52
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
53
|
+
# @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.
|
|
54
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
55
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
56
|
+
# @return [Models::ListResourceEventName]
|
|
57
|
+
def list_names(organization_id: nil, customer_id: nil, external_customer_id: nil, source: nil, query: nil, page: 1, limit: 10, sorting: ["-last_seen"])
|
|
58
|
+
data = client.request(
|
|
59
|
+
http_method: "GET",
|
|
60
|
+
path: "/v1/events/names",
|
|
61
|
+
path_params: {},
|
|
62
|
+
query: { "organization_id" => organization_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "source" => source, "query" => query, "page" => page, "limit" => limit, "sorting" => sorting },
|
|
63
|
+
response_type: :json,
|
|
64
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
65
|
+
)
|
|
66
|
+
Models::ListResourceEventName.from_json(data)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Enumerate every item of `list_names`, fetching pages on demand.
|
|
70
|
+
#
|
|
71
|
+
# @yieldparam item [Models::EventName]
|
|
72
|
+
# @return [Pago::Paginator] when called without a block.
|
|
73
|
+
def list_names_each(organization_id: nil, customer_id: nil, external_customer_id: nil, source: nil, query: nil, limit: 10, sorting: ["-last_seen"], &block)
|
|
74
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
75
|
+
list_names(organization_id: organization_id, customer_id: customer_id, external_customer_id: external_customer_id, source: source, query: query, page: page_number, limit: limit, sorting: sorting)
|
|
76
|
+
end
|
|
77
|
+
block ? paginator.each(&block) : paginator
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Get an event by ID.
|
|
81
|
+
#
|
|
82
|
+
# **Scopes**: `events:read` `events:write`
|
|
83
|
+
#
|
|
84
|
+
# @param id [String] The event ID.
|
|
85
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
86
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
87
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
88
|
+
# @return [Object]
|
|
89
|
+
def get(id)
|
|
90
|
+
data = client.request(
|
|
91
|
+
http_method: "GET",
|
|
92
|
+
path: "/v1/events/{id}",
|
|
93
|
+
path_params: { "id" => id },
|
|
94
|
+
query: {},
|
|
95
|
+
response_type: :json,
|
|
96
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
97
|
+
)
|
|
98
|
+
Unions::Event.from_json(data)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Ingest batch of events.
|
|
102
|
+
#
|
|
103
|
+
# **Scopes**: `events:write`
|
|
104
|
+
#
|
|
105
|
+
# @param body [Hash, Models::EventsIngest] the request body.
|
|
106
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
107
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
108
|
+
# @return [Models::EventsIngestResponse]
|
|
109
|
+
def ingest(body: {})
|
|
110
|
+
data = client.request(
|
|
111
|
+
http_method: "POST",
|
|
112
|
+
path: "/v1/events/ingest",
|
|
113
|
+
path_params: {},
|
|
114
|
+
query: {},
|
|
115
|
+
body: body,
|
|
116
|
+
response_type: :json,
|
|
117
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
118
|
+
)
|
|
119
|
+
Models::EventsIngestResponse.from_json(data)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Files < ::Pago::Service
|
|
7
|
+
# List files.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `files:read` `files:write`
|
|
10
|
+
#
|
|
11
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
12
|
+
# @param ids [String, Array<String>, nil] Filter by file 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
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
16
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
17
|
+
# @return [Models::ListResourceFileRead]
|
|
18
|
+
def list(organization_id: nil, ids: nil, page: 1, limit: 10)
|
|
19
|
+
data = client.request(
|
|
20
|
+
http_method: "GET",
|
|
21
|
+
path: "/v1/files/",
|
|
22
|
+
path_params: {},
|
|
23
|
+
query: { "organization_id" => organization_id, "ids" => ids, "page" => page, "limit" => limit },
|
|
24
|
+
response_type: :json,
|
|
25
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
26
|
+
)
|
|
27
|
+
Models::ListResourceFileRead.from_json(data)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
31
|
+
#
|
|
32
|
+
# @yieldparam item [Object]
|
|
33
|
+
# @return [Pago::Paginator] when called without a block.
|
|
34
|
+
def list_each(organization_id: nil, ids: nil, limit: 10, &block)
|
|
35
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
36
|
+
list(organization_id: organization_id, ids: ids, page: page_number, limit: limit)
|
|
37
|
+
end
|
|
38
|
+
block ? paginator.each(&block) : paginator
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Create a file.
|
|
42
|
+
#
|
|
43
|
+
# **Scopes**: `files:write`
|
|
44
|
+
#
|
|
45
|
+
# @param body [Hash, Object] the request body.
|
|
46
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
47
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
48
|
+
# @return [Models::FileUpload]
|
|
49
|
+
def create(body: {})
|
|
50
|
+
data = client.request(
|
|
51
|
+
http_method: "POST",
|
|
52
|
+
path: "/v1/files/",
|
|
53
|
+
path_params: {},
|
|
54
|
+
query: {},
|
|
55
|
+
body: body,
|
|
56
|
+
response_type: :json,
|
|
57
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
58
|
+
)
|
|
59
|
+
Models::FileUpload.from_json(data)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Complete a file upload.
|
|
63
|
+
#
|
|
64
|
+
# **Scopes**: `files:write`
|
|
65
|
+
#
|
|
66
|
+
# @param id_path [String] The file ID.
|
|
67
|
+
# @param body [Hash, Models::FileUploadCompleted] the request body.
|
|
68
|
+
# @raise [Errors::NotPermitted] on HTTP 403.
|
|
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 uploaded(id_path, body: {})
|
|
74
|
+
data = client.request(
|
|
75
|
+
http_method: "POST",
|
|
76
|
+
path: "/v1/files/{id}/uploaded",
|
|
77
|
+
path_params: { "id" => id_path },
|
|
78
|
+
query: {},
|
|
79
|
+
body: body,
|
|
80
|
+
response_type: :json,
|
|
81
|
+
errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
82
|
+
)
|
|
83
|
+
Unions::FileRead.from_json(data)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Delete a file.
|
|
87
|
+
#
|
|
88
|
+
# **Scopes**: `files:write`
|
|
89
|
+
#
|
|
90
|
+
# @param id [String]
|
|
91
|
+
# @raise [Errors::NotPermitted] on HTTP 403.
|
|
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 [nil]
|
|
96
|
+
def delete(id)
|
|
97
|
+
client.request(
|
|
98
|
+
http_method: "DELETE",
|
|
99
|
+
path: "/v1/files/{id}",
|
|
100
|
+
path_params: { "id" => id },
|
|
101
|
+
query: {},
|
|
102
|
+
response_type: :none,
|
|
103
|
+
errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Update a file.
|
|
108
|
+
#
|
|
109
|
+
# **Scopes**: `files:write`
|
|
110
|
+
#
|
|
111
|
+
# @param id [String] The file ID.
|
|
112
|
+
# @param body [Hash, Models::FilePatch] the request body.
|
|
113
|
+
# @raise [Errors::NotPermitted] on HTTP 403.
|
|
114
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
115
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
116
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
117
|
+
# @return [Object]
|
|
118
|
+
def update(id, body: {})
|
|
119
|
+
data = client.request(
|
|
120
|
+
http_method: "PATCH",
|
|
121
|
+
path: "/v1/files/{id}",
|
|
122
|
+
path_params: { "id" => id },
|
|
123
|
+
query: {},
|
|
124
|
+
body: body,
|
|
125
|
+
response_type: :json,
|
|
126
|
+
errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
127
|
+
)
|
|
128
|
+
Unions::FileRead.from_json(data)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class LicenseKeys < ::Pago::Service
|
|
7
|
+
# Get license keys connected to the given organization & filters.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `license_keys:read` `license_keys:write`
|
|
10
|
+
#
|
|
11
|
+
# @param organization_id [String, Array<String>, nil] Filter by organization ID.
|
|
12
|
+
# @param benefit_id [String, Array<String>, nil] Filter by benefit ID.
|
|
13
|
+
# @param status [String, Array<String>, nil] Filter by license key status.
|
|
14
|
+
# @param page [Integer] Page number, defaults to 1.
|
|
15
|
+
# @param limit [Integer] Size of a page, defaults to 10. Maximum is 100.
|
|
16
|
+
# @raise [Errors::Unauthorized] on HTTP 401.
|
|
17
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
18
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
19
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
20
|
+
# @return [Models::ListResourceLicenseKeyRead]
|
|
21
|
+
def list(organization_id: nil, benefit_id: nil, status: nil, page: 1, limit: 10)
|
|
22
|
+
data = client.request(
|
|
23
|
+
http_method: "GET",
|
|
24
|
+
path: "/v1/license-keys/",
|
|
25
|
+
path_params: {},
|
|
26
|
+
query: { "organization_id" => organization_id, "benefit_id" => benefit_id, "status" => status, "page" => page, "limit" => limit },
|
|
27
|
+
response_type: :json,
|
|
28
|
+
errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
29
|
+
)
|
|
30
|
+
Models::ListResourceLicenseKeyRead.from_json(data)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Enumerate every item of `list`, fetching pages on demand.
|
|
34
|
+
#
|
|
35
|
+
# @yieldparam item [Models::LicenseKeyRead]
|
|
36
|
+
# @return [Pago::Paginator] when called without a block.
|
|
37
|
+
def list_each(organization_id: nil, benefit_id: nil, status: nil, limit: 10, &block)
|
|
38
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
39
|
+
list(organization_id: organization_id, benefit_id: benefit_id, status: status, page: page_number, limit: limit)
|
|
40
|
+
end
|
|
41
|
+
block ? paginator.each(&block) : paginator
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Get a license key.
|
|
45
|
+
#
|
|
46
|
+
# **Scopes**: `license_keys:read` `license_keys:write`
|
|
47
|
+
#
|
|
48
|
+
# @param id [String]
|
|
49
|
+
# @raise [Errors::Unauthorized] on HTTP 401.
|
|
50
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
51
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
52
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
53
|
+
# @return [Models::LicenseKeyWithActivations]
|
|
54
|
+
def get(id)
|
|
55
|
+
data = client.request(
|
|
56
|
+
http_method: "GET",
|
|
57
|
+
path: "/v1/license-keys/{id}",
|
|
58
|
+
path_params: { "id" => id },
|
|
59
|
+
query: {},
|
|
60
|
+
response_type: :json,
|
|
61
|
+
errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
62
|
+
)
|
|
63
|
+
Models::LicenseKeyWithActivations.from_json(data)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Update a license key.
|
|
67
|
+
#
|
|
68
|
+
# **Scopes**: `license_keys:write`
|
|
69
|
+
#
|
|
70
|
+
# @param id [String]
|
|
71
|
+
# @param body [Hash, Models::LicenseKeyUpdate] the request body.
|
|
72
|
+
# @raise [Errors::Unauthorized] on HTTP 401.
|
|
73
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
74
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
75
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
76
|
+
# @return [Models::LicenseKeyRead]
|
|
77
|
+
def update(id, body: {})
|
|
78
|
+
data = client.request(
|
|
79
|
+
http_method: "PATCH",
|
|
80
|
+
path: "/v1/license-keys/{id}",
|
|
81
|
+
path_params: { "id" => id },
|
|
82
|
+
query: {},
|
|
83
|
+
body: body,
|
|
84
|
+
response_type: :json,
|
|
85
|
+
errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
86
|
+
)
|
|
87
|
+
Models::LicenseKeyRead.from_json(data)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Get a license key activation.
|
|
91
|
+
#
|
|
92
|
+
# **Scopes**: `license_keys:read` `license_keys:write`
|
|
93
|
+
#
|
|
94
|
+
# @param id [String]
|
|
95
|
+
# @param activation_id [String]
|
|
96
|
+
# @raise [Errors::Unauthorized] on HTTP 401.
|
|
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::LicenseKeyActivationRead]
|
|
101
|
+
def get_activation(id, activation_id)
|
|
102
|
+
data = client.request(
|
|
103
|
+
http_method: "GET",
|
|
104
|
+
path: "/v1/license-keys/{id}/activations/{activation_id}",
|
|
105
|
+
path_params: { "id" => id, "activation_id" => activation_id },
|
|
106
|
+
query: {},
|
|
107
|
+
response_type: :json,
|
|
108
|
+
errors: { 401 => Errors::Unauthorized, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
109
|
+
)
|
|
110
|
+
Models::LicenseKeyActivationRead.from_json(data)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Validate a license key.
|
|
114
|
+
#
|
|
115
|
+
# **Scopes**: `license_keys:write`
|
|
116
|
+
#
|
|
117
|
+
# @param body [Hash, Models::LicenseKeyValidate] the request body.
|
|
118
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
119
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
120
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
121
|
+
# @return [Models::ValidatedLicenseKey]
|
|
122
|
+
def validate(body: {})
|
|
123
|
+
data = client.request(
|
|
124
|
+
http_method: "POST",
|
|
125
|
+
path: "/v1/license-keys/validate",
|
|
126
|
+
path_params: {},
|
|
127
|
+
query: {},
|
|
128
|
+
body: body,
|
|
129
|
+
response_type: :json,
|
|
130
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
131
|
+
)
|
|
132
|
+
Models::ValidatedLicenseKey.from_json(data)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Activate a license key instance.
|
|
136
|
+
#
|
|
137
|
+
# **Scopes**: `license_keys:write`
|
|
138
|
+
#
|
|
139
|
+
# @param body [Hash, Models::LicenseKeyActivate] the request body.
|
|
140
|
+
# @raise [Errors::NotPermitted] on HTTP 403.
|
|
141
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
142
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
143
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
144
|
+
# @return [Models::LicenseKeyActivationRead]
|
|
145
|
+
def activate(body: {})
|
|
146
|
+
data = client.request(
|
|
147
|
+
http_method: "POST",
|
|
148
|
+
path: "/v1/license-keys/activate",
|
|
149
|
+
path_params: {},
|
|
150
|
+
query: {},
|
|
151
|
+
body: body,
|
|
152
|
+
response_type: :json,
|
|
153
|
+
errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
154
|
+
)
|
|
155
|
+
Models::LicenseKeyActivationRead.from_json(data)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Deactivate a license key instance.
|
|
159
|
+
#
|
|
160
|
+
# **Scopes**: `license_keys:write`
|
|
161
|
+
#
|
|
162
|
+
# @param body [Hash, Models::LicenseKeyDeactivate] the request body.
|
|
163
|
+
# @raise [Errors::ResourceNotFound] on HTTP 404.
|
|
164
|
+
# @raise [Errors::HTTPValidationError] on HTTP 422.
|
|
165
|
+
# @raise [Pago::NetworkError] when the request never reached the API.
|
|
166
|
+
# @return [nil]
|
|
167
|
+
def deactivate(body: {})
|
|
168
|
+
client.request(
|
|
169
|
+
http_method: "POST",
|
|
170
|
+
path: "/v1/license-keys/deactivate",
|
|
171
|
+
path_params: {},
|
|
172
|
+
query: {},
|
|
173
|
+
body: body,
|
|
174
|
+
response_type: :none,
|
|
175
|
+
errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
|
|
176
|
+
)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pago
|
|
4
|
+
module V2026_04
|
|
5
|
+
module Services
|
|
6
|
+
class Members < ::Pago::Service
|
|
7
|
+
# List members with optional customer ID filter.
|
|
8
|
+
#
|
|
9
|
+
# **Scopes**: `members:read` `members:write`
|
|
10
|
+
#
|
|
11
|
+
# @param customer_id [String, nil] Filter by customer ID.
|
|
12
|
+
# @param external_customer_id [String, nil] Filter by customer external ID.
|
|
13
|
+
# @param role [String, nil] Filter by member role.
|
|
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::ListResourceMember]
|
|
20
|
+
def list_members(customer_id: nil, external_customer_id: nil, role: nil, page: 1, limit: 10, sorting: ["-created_at"])
|
|
21
|
+
data = client.request(
|
|
22
|
+
http_method: "GET",
|
|
23
|
+
path: "/v1/members/",
|
|
24
|
+
path_params: {},
|
|
25
|
+
query: { "customer_id" => customer_id, "external_customer_id" => external_customer_id, "role" => role, "page" => page, "limit" => limit, "sorting" => sorting },
|
|
26
|
+
response_type: :json,
|
|
27
|
+
errors: { 422 => Errors::HTTPValidationError }
|
|
28
|
+
)
|
|
29
|
+
Models::ListResourceMember.from_json(data)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Enumerate every item of `list_members`, fetching pages on demand.
|
|
33
|
+
#
|
|
34
|
+
# @yieldparam item [Models::Member]
|
|
35
|
+
# @return [Pago::Paginator] when called without a block.
|
|
36
|
+
def list_members_each(customer_id: nil, external_customer_id: nil, role: nil, limit: 10, sorting: ["-created_at"], &block)
|
|
37
|
+
paginator = ::Pago::Paginator.new do |page_number|
|
|
38
|
+
list_members(customer_id: customer_id, external_customer_id: external_customer_id, role: role, page: page_number, limit: limit, sorting: sorting)
|
|
39
|
+
end
|
|
40
|
+
block ? paginator.each(&block) : paginator
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|