trophy_api_client 1.8.0 → 1.9.1
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 +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/requests.rb +34 -8
- data/lib/trophy_api_client/achievements/client.rb +4 -0
- data/lib/trophy_api_client/admin/attributes/client.rb +10 -0
- data/lib/trophy_api_client/admin/client.rb +7 -0
- data/lib/trophy_api_client/admin/leaderboards/client.rb +10 -0
- data/lib/trophy_api_client/admin/metrics/client.rb +10 -0
- data/lib/trophy_api_client/admin/points/boosts/client.rb +10 -0
- data/lib/trophy_api_client/admin/points/levels/client.rb +10 -0
- data/lib/trophy_api_client/admin/points/systems/client.rb +10 -0
- data/lib/trophy_api_client/admin/points/triggers/client.rb +10 -0
- data/lib/trophy_api_client/admin/streaks/client.rb +2 -0
- data/lib/trophy_api_client/admin/streaks/freezes/client.rb +2 -0
- data/lib/trophy_api_client/admin/tenants/client.rb +376 -0
- data/lib/trophy_api_client/leaderboards/client.rb +4 -0
- data/lib/trophy_api_client/metrics/client.rb +2 -0
- data/lib/trophy_api_client/points/client.rb +10 -0
- data/lib/trophy_api_client/streaks/client.rb +4 -0
- data/lib/trophy_api_client/types/admin_points_boost.rb +2 -2
- data/lib/trophy_api_client/types/admin_tenant.rb +103 -0
- data/lib/trophy_api_client/types/admin_tenant_status.rb +9 -0
- data/lib/trophy_api_client/types/create_tenant_request_item.rb +66 -0
- data/lib/trophy_api_client/types/create_tenants_request.rb +7 -0
- data/lib/trophy_api_client/types/create_tenants_response.rb +74 -0
- data/lib/trophy_api_client/types/delete_tenants_response.rb +74 -0
- data/lib/trophy_api_client/types/list_tenants_response.rb +7 -0
- data/lib/trophy_api_client/types/update_tenant_request_item.rb +75 -0
- data/lib/trophy_api_client/types/update_tenants_request.rb +7 -0
- data/lib/trophy_api_client/types/update_tenants_response.rb +74 -0
- data/lib/trophy_api_client/users/client.rb +32 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/trophy_api_client.rb +12 -4
- data/lib/types_export.rb +10 -0
- metadata +13 -2
|
@@ -41,6 +41,7 @@ module TrophyApiClient
|
|
|
41
41
|
response = @request_client.conn.get do |req|
|
|
42
42
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
43
43
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
44
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
44
45
|
req.headers = {
|
|
45
46
|
**(req.headers || {}),
|
|
46
47
|
**@request_client.get_headers,
|
|
@@ -80,6 +81,7 @@ module TrophyApiClient
|
|
|
80
81
|
response = @request_client.conn.post do |req|
|
|
81
82
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
82
83
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
84
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
83
85
|
req.headers = {
|
|
84
86
|
**(req.headers || {}),
|
|
85
87
|
**@request_client.get_headers,
|
|
@@ -110,6 +112,7 @@ module TrophyApiClient
|
|
|
110
112
|
response = @request_client.conn.delete do |req|
|
|
111
113
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
112
114
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
115
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
113
116
|
req.headers = {
|
|
114
117
|
**(req.headers || {}),
|
|
115
118
|
**@request_client.get_headers,
|
|
@@ -140,6 +143,7 @@ module TrophyApiClient
|
|
|
140
143
|
response = @request_client.conn.patch do |req|
|
|
141
144
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
142
145
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
146
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
143
147
|
req.headers = {
|
|
144
148
|
**(req.headers || {}),
|
|
145
149
|
**@request_client.get_headers,
|
|
@@ -170,6 +174,7 @@ module TrophyApiClient
|
|
|
170
174
|
response = @request_client.conn.get do |req|
|
|
171
175
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
172
176
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
177
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
173
178
|
req.headers = {
|
|
174
179
|
**(req.headers || {}),
|
|
175
180
|
**@request_client.get_headers,
|
|
@@ -215,6 +220,7 @@ module TrophyApiClient
|
|
|
215
220
|
response = @request_client.conn.get do |req|
|
|
216
221
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
217
222
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
223
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
218
224
|
req.headers = {
|
|
219
225
|
**(req.headers || {}),
|
|
220
226
|
**@request_client.get_headers,
|
|
@@ -256,6 +262,7 @@ module TrophyApiClient
|
|
|
256
262
|
response = @request_client.conn.post do |req|
|
|
257
263
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
258
264
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
265
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
259
266
|
req.headers = {
|
|
260
267
|
**(req.headers || {}),
|
|
261
268
|
**@request_client.get_headers,
|
|
@@ -288,6 +295,7 @@ module TrophyApiClient
|
|
|
288
295
|
response = @request_client.conn.delete do |req|
|
|
289
296
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
290
297
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
298
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
291
299
|
req.headers = {
|
|
292
300
|
**(req.headers || {}),
|
|
293
301
|
**@request_client.get_headers,
|
|
@@ -320,6 +328,7 @@ module TrophyApiClient
|
|
|
320
328
|
response = @request_client.conn.patch do |req|
|
|
321
329
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
322
330
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
331
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
323
332
|
req.headers = {
|
|
324
333
|
**(req.headers || {}),
|
|
325
334
|
**@request_client.get_headers,
|
|
@@ -352,6 +361,7 @@ module TrophyApiClient
|
|
|
352
361
|
response = @request_client.conn.get do |req|
|
|
353
362
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
354
363
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
364
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
355
365
|
req.headers = {
|
|
356
366
|
**(req.headers || {}),
|
|
357
367
|
**@request_client.get_headers,
|
|
@@ -46,6 +46,7 @@ module TrophyApiClient
|
|
|
46
46
|
response = @request_client.conn.get do |req|
|
|
47
47
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
48
48
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
49
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
49
50
|
req.headers = {
|
|
50
51
|
**(req.headers || {}),
|
|
51
52
|
**@request_client.get_headers,
|
|
@@ -86,6 +87,7 @@ module TrophyApiClient
|
|
|
86
87
|
response = @request_client.conn.post do |req|
|
|
87
88
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
88
89
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
90
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
89
91
|
req.headers = {
|
|
90
92
|
**(req.headers || {}),
|
|
91
93
|
**@request_client.get_headers,
|
|
@@ -118,6 +120,7 @@ module TrophyApiClient
|
|
|
118
120
|
response = @request_client.conn.delete do |req|
|
|
119
121
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
120
122
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
123
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
121
124
|
req.headers = {
|
|
122
125
|
**(req.headers || {}),
|
|
123
126
|
**@request_client.get_headers,
|
|
@@ -151,6 +154,7 @@ module TrophyApiClient
|
|
|
151
154
|
response = @request_client.conn.patch do |req|
|
|
152
155
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
153
156
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
157
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
154
158
|
req.headers = {
|
|
155
159
|
**(req.headers || {}),
|
|
156
160
|
**@request_client.get_headers,
|
|
@@ -183,6 +187,7 @@ module TrophyApiClient
|
|
|
183
187
|
response = @request_client.conn.get do |req|
|
|
184
188
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
185
189
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
190
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
186
191
|
req.headers = {
|
|
187
192
|
**(req.headers || {}),
|
|
188
193
|
**@request_client.get_headers,
|
|
@@ -234,6 +239,7 @@ module TrophyApiClient
|
|
|
234
239
|
response = @request_client.conn.get do |req|
|
|
235
240
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
236
241
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
242
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
237
243
|
req.headers = {
|
|
238
244
|
**(req.headers || {}),
|
|
239
245
|
**@request_client.get_headers,
|
|
@@ -276,6 +282,7 @@ module TrophyApiClient
|
|
|
276
282
|
response = @request_client.conn.post do |req|
|
|
277
283
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
278
284
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
285
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
279
286
|
req.headers = {
|
|
280
287
|
**(req.headers || {}),
|
|
281
288
|
**@request_client.get_headers,
|
|
@@ -310,6 +317,7 @@ module TrophyApiClient
|
|
|
310
317
|
response = @request_client.conn.delete do |req|
|
|
311
318
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
312
319
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
320
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
313
321
|
req.headers = {
|
|
314
322
|
**(req.headers || {}),
|
|
315
323
|
**@request_client.get_headers,
|
|
@@ -345,6 +353,7 @@ module TrophyApiClient
|
|
|
345
353
|
response = @request_client.conn.patch do |req|
|
|
346
354
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
347
355
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
356
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
348
357
|
req.headers = {
|
|
349
358
|
**(req.headers || {}),
|
|
350
359
|
**@request_client.get_headers,
|
|
@@ -379,6 +388,7 @@ module TrophyApiClient
|
|
|
379
388
|
response = @request_client.conn.get do |req|
|
|
380
389
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
381
390
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
391
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
382
392
|
req.headers = {
|
|
383
393
|
**(req.headers || {}),
|
|
384
394
|
**@request_client.get_headers,
|
|
@@ -38,6 +38,7 @@ module TrophyApiClient
|
|
|
38
38
|
response = @request_client.conn.post do |req|
|
|
39
39
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
40
40
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
41
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
41
42
|
req.headers = {
|
|
42
43
|
**(req.headers || {}),
|
|
43
44
|
**@request_client.get_headers,
|
|
@@ -85,6 +86,7 @@ module TrophyApiClient
|
|
|
85
86
|
response = @request_client.conn.post do |req|
|
|
86
87
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
87
88
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
89
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
88
90
|
req.headers = {
|
|
89
91
|
**(req.headers || {}),
|
|
90
92
|
**@request_client.get_headers,
|
|
@@ -35,6 +35,7 @@ module TrophyApiClient
|
|
|
35
35
|
response = @request_client.conn.post do |req|
|
|
36
36
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
37
37
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
38
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
38
39
|
req.headers = {
|
|
39
40
|
**(req.headers || {}),
|
|
40
41
|
**@request_client.get_headers,
|
|
@@ -78,6 +79,7 @@ module TrophyApiClient
|
|
|
78
79
|
response = @request_client.conn.post do |req|
|
|
79
80
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
80
81
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
82
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
81
83
|
req.headers = {
|
|
82
84
|
**(req.headers || {}),
|
|
83
85
|
**@request_client.get_headers,
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../../requests"
|
|
4
|
+
require_relative "../../types/list_tenants_response"
|
|
5
|
+
require "json"
|
|
6
|
+
require_relative "../../types/create_tenants_request"
|
|
7
|
+
require_relative "../../types/create_tenants_response"
|
|
8
|
+
require_relative "../../types/delete_tenants_response"
|
|
9
|
+
require_relative "../../types/update_tenants_request"
|
|
10
|
+
require_relative "../../types/update_tenants_response"
|
|
11
|
+
require_relative "../../types/admin_tenant"
|
|
12
|
+
require "async"
|
|
13
|
+
|
|
14
|
+
module TrophyApiClient
|
|
15
|
+
module Admin
|
|
16
|
+
class TenantsClient
|
|
17
|
+
# @return [TrophyApiClient::RequestClient]
|
|
18
|
+
attr_reader :request_client
|
|
19
|
+
|
|
20
|
+
# @param request_client [TrophyApiClient::RequestClient]
|
|
21
|
+
# @return [TrophyApiClient::Admin::TenantsClient]
|
|
22
|
+
def initialize(request_client:)
|
|
23
|
+
@request_client = request_client
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# List tenants in the current environment.
|
|
27
|
+
#
|
|
28
|
+
# @param limit [Integer] Number of records to return.
|
|
29
|
+
# @param skip [Integer] Number of records to skip from the start of the list.
|
|
30
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
31
|
+
# @return [TrophyApiClient::LIST_TENANTS_RESPONSE]
|
|
32
|
+
# @example
|
|
33
|
+
# api = TrophyApiClient::Client.new(
|
|
34
|
+
# base_url: "https://api.example.com",
|
|
35
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
36
|
+
# api_key: "YOUR_API_KEY"
|
|
37
|
+
# )
|
|
38
|
+
# api.admin.tenants.list(limit: 1, skip: 1)
|
|
39
|
+
def list(limit: nil, skip: nil, request_options: nil)
|
|
40
|
+
response = @request_client.conn.get do |req|
|
|
41
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
42
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
43
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
44
|
+
req.headers = {
|
|
45
|
+
**(req.headers || {}),
|
|
46
|
+
**@request_client.get_headers,
|
|
47
|
+
**(request_options&.additional_headers || {})
|
|
48
|
+
}.compact
|
|
49
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "skip": skip }.compact
|
|
50
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
51
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
52
|
+
end
|
|
53
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
54
|
+
end
|
|
55
|
+
parsed_json = JSON.parse(response.body)
|
|
56
|
+
parsed_json&.map do |item|
|
|
57
|
+
item = item.to_json
|
|
58
|
+
TrophyApiClient::AdminTenant.from_json(json_object: item)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Create tenants.
|
|
63
|
+
#
|
|
64
|
+
# @param request [TrophyApiClient::CREATE_TENANTS_REQUEST]
|
|
65
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
66
|
+
# @return [TrophyApiClient::CreateTenantsResponse]
|
|
67
|
+
# @example
|
|
68
|
+
# api = TrophyApiClient::Client.new(
|
|
69
|
+
# base_url: "https://api.example.com",
|
|
70
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
71
|
+
# api_key: "YOUR_API_KEY"
|
|
72
|
+
# )
|
|
73
|
+
# api.admin.tenants.create(request: [{ customer_id: "customer_12345", name: "Acme Corp" }, { customer_id: "customer_67890", name: "Globex Inc" }])
|
|
74
|
+
def create(request:, request_options: nil)
|
|
75
|
+
response = @request_client.conn.post do |req|
|
|
76
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
77
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
78
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
79
|
+
req.headers = {
|
|
80
|
+
**(req.headers || {}),
|
|
81
|
+
**@request_client.get_headers,
|
|
82
|
+
**(request_options&.additional_headers || {})
|
|
83
|
+
}.compact
|
|
84
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
85
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
86
|
+
end
|
|
87
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
88
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
89
|
+
end
|
|
90
|
+
TrophyApiClient::CreateTenantsResponse.from_json(json_object: response.body)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Delete tenants by ID.
|
|
94
|
+
#
|
|
95
|
+
# @param ids [String] Tenant IDs to delete. Repeat the query param or provide a comma-separated list.
|
|
96
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
97
|
+
# @return [TrophyApiClient::DeleteTenantsResponse]
|
|
98
|
+
# @example
|
|
99
|
+
# api = TrophyApiClient::Client.new(
|
|
100
|
+
# base_url: "https://api.example.com",
|
|
101
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
102
|
+
# api_key: "YOUR_API_KEY"
|
|
103
|
+
# )
|
|
104
|
+
# api.admin.tenants.delete
|
|
105
|
+
def delete(ids: nil, request_options: nil)
|
|
106
|
+
response = @request_client.conn.delete do |req|
|
|
107
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
108
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
109
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
110
|
+
req.headers = {
|
|
111
|
+
**(req.headers || {}),
|
|
112
|
+
**@request_client.get_headers,
|
|
113
|
+
**(request_options&.additional_headers || {})
|
|
114
|
+
}.compact
|
|
115
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
|
|
116
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
117
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
118
|
+
end
|
|
119
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
120
|
+
end
|
|
121
|
+
TrophyApiClient::DeleteTenantsResponse.from_json(json_object: response.body)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Update tenants by ID.
|
|
125
|
+
#
|
|
126
|
+
# @param request [TrophyApiClient::UPDATE_TENANTS_REQUEST]
|
|
127
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
128
|
+
# @return [TrophyApiClient::UpdateTenantsResponse]
|
|
129
|
+
# @example
|
|
130
|
+
# api = TrophyApiClient::Client.new(
|
|
131
|
+
# base_url: "https://api.example.com",
|
|
132
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
133
|
+
# api_key: "YOUR_API_KEY"
|
|
134
|
+
# )
|
|
135
|
+
# api.admin.tenants.update(request: [{ id: "550e8400-e29b-41d4-a716-446655440000", name: "Acme Corporation" }])
|
|
136
|
+
def update(request:, request_options: nil)
|
|
137
|
+
response = @request_client.conn.patch do |req|
|
|
138
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
139
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
140
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
141
|
+
req.headers = {
|
|
142
|
+
**(req.headers || {}),
|
|
143
|
+
**@request_client.get_headers,
|
|
144
|
+
**(request_options&.additional_headers || {})
|
|
145
|
+
}.compact
|
|
146
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
147
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
148
|
+
end
|
|
149
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
150
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
151
|
+
end
|
|
152
|
+
TrophyApiClient::UpdateTenantsResponse.from_json(json_object: response.body)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Get a tenant by ID.
|
|
156
|
+
#
|
|
157
|
+
# @param id [String] The UUID of the tenant to retrieve.
|
|
158
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
159
|
+
# @return [TrophyApiClient::AdminTenant]
|
|
160
|
+
# @example
|
|
161
|
+
# api = TrophyApiClient::Client.new(
|
|
162
|
+
# base_url: "https://api.example.com",
|
|
163
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
164
|
+
# api_key: "YOUR_API_KEY"
|
|
165
|
+
# )
|
|
166
|
+
# api.admin.tenants.get(id: "550e8400-e29b-41d4-a716-446655440000")
|
|
167
|
+
def get(id:, request_options: nil)
|
|
168
|
+
response = @request_client.conn.get do |req|
|
|
169
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
170
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
171
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
172
|
+
req.headers = {
|
|
173
|
+
**(req.headers || {}),
|
|
174
|
+
**@request_client.get_headers,
|
|
175
|
+
**(request_options&.additional_headers || {})
|
|
176
|
+
}.compact
|
|
177
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
178
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
179
|
+
end
|
|
180
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
181
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
182
|
+
end
|
|
183
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants/#{id}"
|
|
184
|
+
end
|
|
185
|
+
TrophyApiClient::AdminTenant.from_json(json_object: response.body)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
class AsyncTenantsClient
|
|
190
|
+
# @return [TrophyApiClient::AsyncRequestClient]
|
|
191
|
+
attr_reader :request_client
|
|
192
|
+
|
|
193
|
+
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
|
194
|
+
# @return [TrophyApiClient::Admin::AsyncTenantsClient]
|
|
195
|
+
def initialize(request_client:)
|
|
196
|
+
@request_client = request_client
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# List tenants in the current environment.
|
|
200
|
+
#
|
|
201
|
+
# @param limit [Integer] Number of records to return.
|
|
202
|
+
# @param skip [Integer] Number of records to skip from the start of the list.
|
|
203
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
204
|
+
# @return [TrophyApiClient::LIST_TENANTS_RESPONSE]
|
|
205
|
+
# @example
|
|
206
|
+
# api = TrophyApiClient::Client.new(
|
|
207
|
+
# base_url: "https://api.example.com",
|
|
208
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
209
|
+
# api_key: "YOUR_API_KEY"
|
|
210
|
+
# )
|
|
211
|
+
# api.admin.tenants.list(limit: 1, skip: 1)
|
|
212
|
+
def list(limit: nil, skip: nil, request_options: nil)
|
|
213
|
+
Async do
|
|
214
|
+
response = @request_client.conn.get do |req|
|
|
215
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
216
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
217
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
218
|
+
req.headers = {
|
|
219
|
+
**(req.headers || {}),
|
|
220
|
+
**@request_client.get_headers,
|
|
221
|
+
**(request_options&.additional_headers || {})
|
|
222
|
+
}.compact
|
|
223
|
+
req.params = {
|
|
224
|
+
**(request_options&.additional_query_parameters || {}),
|
|
225
|
+
"limit": limit,
|
|
226
|
+
"skip": skip
|
|
227
|
+
}.compact
|
|
228
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
229
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
230
|
+
end
|
|
231
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
232
|
+
end
|
|
233
|
+
parsed_json = JSON.parse(response.body)
|
|
234
|
+
parsed_json&.map do |item|
|
|
235
|
+
item = item.to_json
|
|
236
|
+
TrophyApiClient::AdminTenant.from_json(json_object: item)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Create tenants.
|
|
242
|
+
#
|
|
243
|
+
# @param request [TrophyApiClient::CREATE_TENANTS_REQUEST]
|
|
244
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
245
|
+
# @return [TrophyApiClient::CreateTenantsResponse]
|
|
246
|
+
# @example
|
|
247
|
+
# api = TrophyApiClient::Client.new(
|
|
248
|
+
# base_url: "https://api.example.com",
|
|
249
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
250
|
+
# api_key: "YOUR_API_KEY"
|
|
251
|
+
# )
|
|
252
|
+
# api.admin.tenants.create(request: [{ customer_id: "customer_12345", name: "Acme Corp" }, { customer_id: "customer_67890", name: "Globex Inc" }])
|
|
253
|
+
def create(request:, request_options: nil)
|
|
254
|
+
Async do
|
|
255
|
+
response = @request_client.conn.post do |req|
|
|
256
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
257
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
258
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
259
|
+
req.headers = {
|
|
260
|
+
**(req.headers || {}),
|
|
261
|
+
**@request_client.get_headers,
|
|
262
|
+
**(request_options&.additional_headers || {})
|
|
263
|
+
}.compact
|
|
264
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
265
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
266
|
+
end
|
|
267
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
268
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
269
|
+
end
|
|
270
|
+
TrophyApiClient::CreateTenantsResponse.from_json(json_object: response.body)
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Delete tenants by ID.
|
|
275
|
+
#
|
|
276
|
+
# @param ids [String] Tenant IDs to delete. Repeat the query param or provide a comma-separated list.
|
|
277
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
278
|
+
# @return [TrophyApiClient::DeleteTenantsResponse]
|
|
279
|
+
# @example
|
|
280
|
+
# api = TrophyApiClient::Client.new(
|
|
281
|
+
# base_url: "https://api.example.com",
|
|
282
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
283
|
+
# api_key: "YOUR_API_KEY"
|
|
284
|
+
# )
|
|
285
|
+
# api.admin.tenants.delete
|
|
286
|
+
def delete(ids: nil, request_options: nil)
|
|
287
|
+
Async do
|
|
288
|
+
response = @request_client.conn.delete do |req|
|
|
289
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
290
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
291
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
292
|
+
req.headers = {
|
|
293
|
+
**(req.headers || {}),
|
|
294
|
+
**@request_client.get_headers,
|
|
295
|
+
**(request_options&.additional_headers || {})
|
|
296
|
+
}.compact
|
|
297
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
|
|
298
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
299
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
300
|
+
end
|
|
301
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
302
|
+
end
|
|
303
|
+
TrophyApiClient::DeleteTenantsResponse.from_json(json_object: response.body)
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
# Update tenants by ID.
|
|
308
|
+
#
|
|
309
|
+
# @param request [TrophyApiClient::UPDATE_TENANTS_REQUEST]
|
|
310
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
311
|
+
# @return [TrophyApiClient::UpdateTenantsResponse]
|
|
312
|
+
# @example
|
|
313
|
+
# api = TrophyApiClient::Client.new(
|
|
314
|
+
# base_url: "https://api.example.com",
|
|
315
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
316
|
+
# api_key: "YOUR_API_KEY"
|
|
317
|
+
# )
|
|
318
|
+
# api.admin.tenants.update(request: [{ id: "550e8400-e29b-41d4-a716-446655440000", name: "Acme Corporation" }])
|
|
319
|
+
def update(request:, request_options: nil)
|
|
320
|
+
Async do
|
|
321
|
+
response = @request_client.conn.patch do |req|
|
|
322
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
323
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
324
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
325
|
+
req.headers = {
|
|
326
|
+
**(req.headers || {}),
|
|
327
|
+
**@request_client.get_headers,
|
|
328
|
+
**(request_options&.additional_headers || {})
|
|
329
|
+
}.compact
|
|
330
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
331
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
332
|
+
end
|
|
333
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
334
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants"
|
|
335
|
+
end
|
|
336
|
+
TrophyApiClient::UpdateTenantsResponse.from_json(json_object: response.body)
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Get a tenant by ID.
|
|
341
|
+
#
|
|
342
|
+
# @param id [String] The UUID of the tenant to retrieve.
|
|
343
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
344
|
+
# @return [TrophyApiClient::AdminTenant]
|
|
345
|
+
# @example
|
|
346
|
+
# api = TrophyApiClient::Client.new(
|
|
347
|
+
# base_url: "https://api.example.com",
|
|
348
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
349
|
+
# api_key: "YOUR_API_KEY"
|
|
350
|
+
# )
|
|
351
|
+
# api.admin.tenants.get(id: "550e8400-e29b-41d4-a716-446655440000")
|
|
352
|
+
def get(id:, request_options: nil)
|
|
353
|
+
Async do
|
|
354
|
+
response = @request_client.conn.get do |req|
|
|
355
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
356
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
357
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
358
|
+
req.headers = {
|
|
359
|
+
**(req.headers || {}),
|
|
360
|
+
**@request_client.get_headers,
|
|
361
|
+
**(request_options&.additional_headers || {})
|
|
362
|
+
}.compact
|
|
363
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
364
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
365
|
+
end
|
|
366
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
367
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
368
|
+
end
|
|
369
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/tenants/#{id}"
|
|
370
|
+
end
|
|
371
|
+
TrophyApiClient::AdminTenant.from_json(json_object: response.body)
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
end
|
|
@@ -35,6 +35,7 @@ module TrophyApiClient
|
|
|
35
35
|
response = @request_client.conn.get do |req|
|
|
36
36
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
37
37
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
38
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
38
39
|
req.headers = {
|
|
39
40
|
**(req.headers || {}),
|
|
40
41
|
**@request_client.get_headers,
|
|
@@ -89,6 +90,7 @@ module TrophyApiClient
|
|
|
89
90
|
response = @request_client.conn.get do |req|
|
|
90
91
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
91
92
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
93
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
92
94
|
req.headers = {
|
|
93
95
|
**(req.headers || {}),
|
|
94
96
|
**@request_client.get_headers,
|
|
@@ -140,6 +142,7 @@ module TrophyApiClient
|
|
|
140
142
|
response = @request_client.conn.get do |req|
|
|
141
143
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
142
144
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
145
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
143
146
|
req.headers = {
|
|
144
147
|
**(req.headers || {}),
|
|
145
148
|
**@request_client.get_headers,
|
|
@@ -196,6 +199,7 @@ module TrophyApiClient
|
|
|
196
199
|
response = @request_client.conn.get do |req|
|
|
197
200
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
198
201
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
202
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
199
203
|
req.headers = {
|
|
200
204
|
**(req.headers || {}),
|
|
201
205
|
**@request_client.get_headers,
|
|
@@ -50,6 +50,7 @@ module TrophyApiClient
|
|
|
50
50
|
response = @request_client.conn.post do |req|
|
|
51
51
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
52
52
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
53
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
53
54
|
req.headers = {
|
|
54
55
|
**(req.headers || {}),
|
|
55
56
|
**@request_client.get_headers,
|
|
@@ -116,6 +117,7 @@ module TrophyApiClient
|
|
|
116
117
|
response = @request_client.conn.post do |req|
|
|
117
118
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
118
119
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
120
|
+
req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
|
|
119
121
|
req.headers = {
|
|
120
122
|
**(req.headers || {}),
|
|
121
123
|
**@request_client.get_headers,
|