trophy_api_client 1.5.0 → 1.6.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 +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/admin/attributes/client.rb +368 -0
- data/lib/trophy_api_client/admin/client.rb +14 -0
- data/lib/trophy_api_client/admin/metrics/client.rb +366 -0
- data/lib/trophy_api_client/types/admin_attribute.rb +81 -0
- data/lib/trophy_api_client/types/admin_attribute_type.rb +9 -0
- data/lib/trophy_api_client/types/create_attribute_request_item.rb +76 -0
- data/lib/trophy_api_client/types/create_attribute_request_item_type.rb +9 -0
- data/lib/trophy_api_client/types/create_attributes_request.rb +7 -0
- data/lib/trophy_api_client/types/create_attributes_response.rb +74 -0
- data/lib/trophy_api_client/types/create_metric_request_item.rb +87 -0
- data/lib/trophy_api_client/types/create_metric_request_item_unit_type.rb +9 -0
- data/lib/trophy_api_client/types/create_metrics_request.rb +7 -0
- data/lib/trophy_api_client/types/create_metrics_response.rb +74 -0
- data/lib/trophy_api_client/types/created_metric.rb +88 -0
- data/lib/trophy_api_client/types/created_metric_unit_type.rb +9 -0
- data/lib/trophy_api_client/types/delete_attributes_response.rb +75 -0
- data/lib/trophy_api_client/types/delete_metrics_response.rb +75 -0
- data/lib/trophy_api_client/types/delete_points_boosts_response.rb +2 -2
- data/lib/trophy_api_client/types/list_attributes_response.rb +7 -0
- data/lib/trophy_api_client/types/list_metrics_response.rb +7 -0
- data/lib/trophy_api_client/types/metric_response.rb +2 -17
- data/lib/trophy_api_client/types/update_attribute_request_item.rb +69 -0
- data/lib/trophy_api_client/types/update_attributes_request.rb +7 -0
- data/lib/trophy_api_client/types/update_attributes_response.rb +75 -0
- data/lib/trophy_api_client/types/update_metric_request_item.rb +86 -0
- data/lib/trophy_api_client/types/update_metric_request_item_unit_type.rb +9 -0
- data/lib/trophy_api_client/types/update_metrics_request.rb +7 -0
- data/lib/trophy_api_client/types/update_metrics_response.rb +75 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +23 -1
- metadata +26 -2
- data/lib/trophy_api_client/types/metric_status.rb +0 -9
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../../requests"
|
|
4
|
+
require_relative "../../types/list_metrics_response"
|
|
5
|
+
require "json"
|
|
6
|
+
require_relative "../../types/create_metrics_request"
|
|
7
|
+
require_relative "../../types/create_metrics_response"
|
|
8
|
+
require_relative "../../types/delete_metrics_response"
|
|
9
|
+
require_relative "../../types/update_metrics_request"
|
|
10
|
+
require_relative "../../types/update_metrics_response"
|
|
11
|
+
require_relative "../../types/created_metric"
|
|
12
|
+
require "async"
|
|
13
|
+
|
|
14
|
+
module TrophyApiClient
|
|
15
|
+
module Admin
|
|
16
|
+
class MetricsClient
|
|
17
|
+
# @return [TrophyApiClient::RequestClient]
|
|
18
|
+
attr_reader :request_client
|
|
19
|
+
|
|
20
|
+
# @param request_client [TrophyApiClient::RequestClient]
|
|
21
|
+
# @return [TrophyApiClient::Admin::MetricsClient]
|
|
22
|
+
def initialize(request_client:)
|
|
23
|
+
@request_client = request_client
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# List metrics.
|
|
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_METRICS_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.metrics.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 = {
|
|
44
|
+
**(req.headers || {}),
|
|
45
|
+
**@request_client.get_headers,
|
|
46
|
+
**(request_options&.additional_headers || {})
|
|
47
|
+
}.compact
|
|
48
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "skip": skip }.compact
|
|
49
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
50
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
51
|
+
end
|
|
52
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
53
|
+
end
|
|
54
|
+
parsed_json = JSON.parse(response.body)
|
|
55
|
+
parsed_json&.map do |item|
|
|
56
|
+
item = item.to_json
|
|
57
|
+
TrophyApiClient::CreatedMetric.from_json(json_object: item)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Create metrics in bulk.
|
|
62
|
+
#
|
|
63
|
+
# @param request [TrophyApiClient::CREATE_METRICS_REQUEST]
|
|
64
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
65
|
+
# @return [TrophyApiClient::CreateMetricsResponse]
|
|
66
|
+
# @example
|
|
67
|
+
# api = TrophyApiClient::Client.new(
|
|
68
|
+
# base_url: "https://api.example.com",
|
|
69
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
70
|
+
# api_key: "YOUR_API_KEY"
|
|
71
|
+
# )
|
|
72
|
+
# api.admin.metrics.create(request: [{ name: "Invites Sent", key: "invites-sent" }, { name: "Revenue", key: "revenue", unit_type: CURRENCY, units: "USD" }])
|
|
73
|
+
def create(request:, request_options: nil)
|
|
74
|
+
response = @request_client.conn.post do |req|
|
|
75
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
76
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
77
|
+
req.headers = {
|
|
78
|
+
**(req.headers || {}),
|
|
79
|
+
**@request_client.get_headers,
|
|
80
|
+
**(request_options&.additional_headers || {})
|
|
81
|
+
}.compact
|
|
82
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
83
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
84
|
+
end
|
|
85
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
86
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
87
|
+
end
|
|
88
|
+
TrophyApiClient::CreateMetricsResponse.from_json(json_object: response.body)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Delete metrics in bulk by ID.
|
|
92
|
+
#
|
|
93
|
+
# @param ids [String] Metric IDs to delete. Repeat the query param or provide a comma-separated list.
|
|
94
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
95
|
+
# @return [TrophyApiClient::DeleteMetricsResponse]
|
|
96
|
+
# @example
|
|
97
|
+
# api = TrophyApiClient::Client.new(
|
|
98
|
+
# base_url: "https://api.example.com",
|
|
99
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
100
|
+
# api_key: "YOUR_API_KEY"
|
|
101
|
+
# )
|
|
102
|
+
# api.admin.metrics.delete
|
|
103
|
+
def delete(ids: nil, request_options: nil)
|
|
104
|
+
response = @request_client.conn.delete do |req|
|
|
105
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
106
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
107
|
+
req.headers = {
|
|
108
|
+
**(req.headers || {}),
|
|
109
|
+
**@request_client.get_headers,
|
|
110
|
+
**(request_options&.additional_headers || {})
|
|
111
|
+
}.compact
|
|
112
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
|
|
113
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
114
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
115
|
+
end
|
|
116
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
117
|
+
end
|
|
118
|
+
TrophyApiClient::DeleteMetricsResponse.from_json(json_object: response.body)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Update metrics in bulk by ID.
|
|
122
|
+
#
|
|
123
|
+
# @param request [TrophyApiClient::UPDATE_METRICS_REQUEST]
|
|
124
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
125
|
+
# @return [TrophyApiClient::UpdateMetricsResponse]
|
|
126
|
+
# @example
|
|
127
|
+
# api = TrophyApiClient::Client.new(
|
|
128
|
+
# base_url: "https://api.example.com",
|
|
129
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
130
|
+
# api_key: "YOUR_API_KEY"
|
|
131
|
+
# )
|
|
132
|
+
# api.admin.metrics.update(request: [{ id: "550e8400-e29b-41d4-a716-446655440000", name: "Invites Completed", units: "invites" }, { id: "550e8400-e29b-41d4-a716-446655440001", unit_type: NUMBER, units: "dollars" }])
|
|
133
|
+
def update(request:, request_options: nil)
|
|
134
|
+
response = @request_client.conn.patch do |req|
|
|
135
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
136
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
137
|
+
req.headers = {
|
|
138
|
+
**(req.headers || {}),
|
|
139
|
+
**@request_client.get_headers,
|
|
140
|
+
**(request_options&.additional_headers || {})
|
|
141
|
+
}.compact
|
|
142
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
143
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
144
|
+
end
|
|
145
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
146
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
147
|
+
end
|
|
148
|
+
TrophyApiClient::UpdateMetricsResponse.from_json(json_object: response.body)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Get a metric by ID.
|
|
152
|
+
#
|
|
153
|
+
# @param id [String] The UUID of the metric to retrieve.
|
|
154
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
155
|
+
# @return [TrophyApiClient::CreatedMetric]
|
|
156
|
+
# @example
|
|
157
|
+
# api = TrophyApiClient::Client.new(
|
|
158
|
+
# base_url: "https://api.example.com",
|
|
159
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
160
|
+
# api_key: "YOUR_API_KEY"
|
|
161
|
+
# )
|
|
162
|
+
# api.admin.metrics.get(id: "550e8400-e29b-41d4-a716-446655440000")
|
|
163
|
+
def get(id:, request_options: nil)
|
|
164
|
+
response = @request_client.conn.get do |req|
|
|
165
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
166
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
167
|
+
req.headers = {
|
|
168
|
+
**(req.headers || {}),
|
|
169
|
+
**@request_client.get_headers,
|
|
170
|
+
**(request_options&.additional_headers || {})
|
|
171
|
+
}.compact
|
|
172
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
173
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
174
|
+
end
|
|
175
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
176
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
177
|
+
end
|
|
178
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics/#{id}"
|
|
179
|
+
end
|
|
180
|
+
TrophyApiClient::CreatedMetric.from_json(json_object: response.body)
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
class AsyncMetricsClient
|
|
185
|
+
# @return [TrophyApiClient::AsyncRequestClient]
|
|
186
|
+
attr_reader :request_client
|
|
187
|
+
|
|
188
|
+
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
|
189
|
+
# @return [TrophyApiClient::Admin::AsyncMetricsClient]
|
|
190
|
+
def initialize(request_client:)
|
|
191
|
+
@request_client = request_client
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# List metrics.
|
|
195
|
+
#
|
|
196
|
+
# @param limit [Integer] Number of records to return.
|
|
197
|
+
# @param skip [Integer] Number of records to skip from the start of the list.
|
|
198
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
199
|
+
# @return [TrophyApiClient::LIST_METRICS_RESPONSE]
|
|
200
|
+
# @example
|
|
201
|
+
# api = TrophyApiClient::Client.new(
|
|
202
|
+
# base_url: "https://api.example.com",
|
|
203
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
204
|
+
# api_key: "YOUR_API_KEY"
|
|
205
|
+
# )
|
|
206
|
+
# api.admin.metrics.list(limit: 1, skip: 1)
|
|
207
|
+
def list(limit: nil, skip: nil, request_options: nil)
|
|
208
|
+
Async do
|
|
209
|
+
response = @request_client.conn.get do |req|
|
|
210
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
211
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
212
|
+
req.headers = {
|
|
213
|
+
**(req.headers || {}),
|
|
214
|
+
**@request_client.get_headers,
|
|
215
|
+
**(request_options&.additional_headers || {})
|
|
216
|
+
}.compact
|
|
217
|
+
req.params = {
|
|
218
|
+
**(request_options&.additional_query_parameters || {}),
|
|
219
|
+
"limit": limit,
|
|
220
|
+
"skip": skip
|
|
221
|
+
}.compact
|
|
222
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
223
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
224
|
+
end
|
|
225
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
226
|
+
end
|
|
227
|
+
parsed_json = JSON.parse(response.body)
|
|
228
|
+
parsed_json&.map do |item|
|
|
229
|
+
item = item.to_json
|
|
230
|
+
TrophyApiClient::CreatedMetric.from_json(json_object: item)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Create metrics in bulk.
|
|
236
|
+
#
|
|
237
|
+
# @param request [TrophyApiClient::CREATE_METRICS_REQUEST]
|
|
238
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
239
|
+
# @return [TrophyApiClient::CreateMetricsResponse]
|
|
240
|
+
# @example
|
|
241
|
+
# api = TrophyApiClient::Client.new(
|
|
242
|
+
# base_url: "https://api.example.com",
|
|
243
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
244
|
+
# api_key: "YOUR_API_KEY"
|
|
245
|
+
# )
|
|
246
|
+
# api.admin.metrics.create(request: [{ name: "Invites Sent", key: "invites-sent" }, { name: "Revenue", key: "revenue", unit_type: CURRENCY, units: "USD" }])
|
|
247
|
+
def create(request:, request_options: nil)
|
|
248
|
+
Async do
|
|
249
|
+
response = @request_client.conn.post do |req|
|
|
250
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
251
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
252
|
+
req.headers = {
|
|
253
|
+
**(req.headers || {}),
|
|
254
|
+
**@request_client.get_headers,
|
|
255
|
+
**(request_options&.additional_headers || {})
|
|
256
|
+
}.compact
|
|
257
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
258
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
259
|
+
end
|
|
260
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
261
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
262
|
+
end
|
|
263
|
+
TrophyApiClient::CreateMetricsResponse.from_json(json_object: response.body)
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Delete metrics in bulk by ID.
|
|
268
|
+
#
|
|
269
|
+
# @param ids [String] Metric IDs to delete. Repeat the query param or provide a comma-separated list.
|
|
270
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
271
|
+
# @return [TrophyApiClient::DeleteMetricsResponse]
|
|
272
|
+
# @example
|
|
273
|
+
# api = TrophyApiClient::Client.new(
|
|
274
|
+
# base_url: "https://api.example.com",
|
|
275
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
276
|
+
# api_key: "YOUR_API_KEY"
|
|
277
|
+
# )
|
|
278
|
+
# api.admin.metrics.delete
|
|
279
|
+
def delete(ids: nil, request_options: nil)
|
|
280
|
+
Async do
|
|
281
|
+
response = @request_client.conn.delete do |req|
|
|
282
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
283
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
284
|
+
req.headers = {
|
|
285
|
+
**(req.headers || {}),
|
|
286
|
+
**@request_client.get_headers,
|
|
287
|
+
**(request_options&.additional_headers || {})
|
|
288
|
+
}.compact
|
|
289
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
|
|
290
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
291
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
292
|
+
end
|
|
293
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
294
|
+
end
|
|
295
|
+
TrophyApiClient::DeleteMetricsResponse.from_json(json_object: response.body)
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Update metrics in bulk by ID.
|
|
300
|
+
#
|
|
301
|
+
# @param request [TrophyApiClient::UPDATE_METRICS_REQUEST]
|
|
302
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
303
|
+
# @return [TrophyApiClient::UpdateMetricsResponse]
|
|
304
|
+
# @example
|
|
305
|
+
# api = TrophyApiClient::Client.new(
|
|
306
|
+
# base_url: "https://api.example.com",
|
|
307
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
308
|
+
# api_key: "YOUR_API_KEY"
|
|
309
|
+
# )
|
|
310
|
+
# api.admin.metrics.update(request: [{ id: "550e8400-e29b-41d4-a716-446655440000", name: "Invites Completed", units: "invites" }, { id: "550e8400-e29b-41d4-a716-446655440001", unit_type: NUMBER, units: "dollars" }])
|
|
311
|
+
def update(request:, request_options: nil)
|
|
312
|
+
Async do
|
|
313
|
+
response = @request_client.conn.patch do |req|
|
|
314
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
315
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
316
|
+
req.headers = {
|
|
317
|
+
**(req.headers || {}),
|
|
318
|
+
**@request_client.get_headers,
|
|
319
|
+
**(request_options&.additional_headers || {})
|
|
320
|
+
}.compact
|
|
321
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
322
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
323
|
+
end
|
|
324
|
+
req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
|
|
325
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics"
|
|
326
|
+
end
|
|
327
|
+
TrophyApiClient::UpdateMetricsResponse.from_json(json_object: response.body)
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Get a metric by ID.
|
|
332
|
+
#
|
|
333
|
+
# @param id [String] The UUID of the metric to retrieve.
|
|
334
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
335
|
+
# @return [TrophyApiClient::CreatedMetric]
|
|
336
|
+
# @example
|
|
337
|
+
# api = TrophyApiClient::Client.new(
|
|
338
|
+
# base_url: "https://api.example.com",
|
|
339
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
340
|
+
# api_key: "YOUR_API_KEY"
|
|
341
|
+
# )
|
|
342
|
+
# api.admin.metrics.get(id: "550e8400-e29b-41d4-a716-446655440000")
|
|
343
|
+
def get(id:, request_options: nil)
|
|
344
|
+
Async do
|
|
345
|
+
response = @request_client.conn.get do |req|
|
|
346
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
347
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
348
|
+
req.headers = {
|
|
349
|
+
**(req.headers || {}),
|
|
350
|
+
**@request_client.get_headers,
|
|
351
|
+
**(request_options&.additional_headers || {})
|
|
352
|
+
}.compact
|
|
353
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
354
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
355
|
+
end
|
|
356
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
357
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
358
|
+
end
|
|
359
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/metrics/#{id}"
|
|
360
|
+
end
|
|
361
|
+
TrophyApiClient::CreatedMetric.from_json(json_object: response.body)
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "admin_attribute_type"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
# An attribute returned from the admin attributes endpoints.
|
|
9
|
+
class AdminAttribute
|
|
10
|
+
# @return [String] The UUID of the attribute.
|
|
11
|
+
attr_reader :id
|
|
12
|
+
# @return [String] The attribute name.
|
|
13
|
+
attr_reader :name
|
|
14
|
+
# @return [String] The attribute key.
|
|
15
|
+
attr_reader :key
|
|
16
|
+
# @return [TrophyApiClient::AdminAttributeType] The attribute type.
|
|
17
|
+
attr_reader :type
|
|
18
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
19
|
+
attr_reader :additional_properties
|
|
20
|
+
# @return [Object]
|
|
21
|
+
attr_reader :_field_set
|
|
22
|
+
protected :_field_set
|
|
23
|
+
|
|
24
|
+
OMIT = Object.new
|
|
25
|
+
|
|
26
|
+
# @param id [String] The UUID of the attribute.
|
|
27
|
+
# @param name [String] The attribute name.
|
|
28
|
+
# @param key [String] The attribute key.
|
|
29
|
+
# @param type [TrophyApiClient::AdminAttributeType] The attribute type.
|
|
30
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
31
|
+
# @return [TrophyApiClient::AdminAttribute]
|
|
32
|
+
def initialize(id:, name:, key:, type:, additional_properties: nil)
|
|
33
|
+
@id = id
|
|
34
|
+
@name = name
|
|
35
|
+
@key = key
|
|
36
|
+
@type = type
|
|
37
|
+
@additional_properties = additional_properties
|
|
38
|
+
@_field_set = { "id": id, "name": name, "key": key, "type": type }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Deserialize a JSON object to an instance of AdminAttribute
|
|
42
|
+
#
|
|
43
|
+
# @param json_object [String]
|
|
44
|
+
# @return [TrophyApiClient::AdminAttribute]
|
|
45
|
+
def self.from_json(json_object:)
|
|
46
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
47
|
+
parsed_json = JSON.parse(json_object)
|
|
48
|
+
id = parsed_json["id"]
|
|
49
|
+
name = parsed_json["name"]
|
|
50
|
+
key = parsed_json["key"]
|
|
51
|
+
type = parsed_json["type"]
|
|
52
|
+
new(
|
|
53
|
+
id: id,
|
|
54
|
+
name: name,
|
|
55
|
+
key: key,
|
|
56
|
+
type: type,
|
|
57
|
+
additional_properties: struct
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Serialize an instance of AdminAttribute to a JSON object
|
|
62
|
+
#
|
|
63
|
+
# @return [String]
|
|
64
|
+
def to_json(*_args)
|
|
65
|
+
@_field_set&.to_json
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
69
|
+
# hash and check each fields type against the current object's property
|
|
70
|
+
# definitions.
|
|
71
|
+
#
|
|
72
|
+
# @param obj [Object]
|
|
73
|
+
# @return [Void]
|
|
74
|
+
def self.validate_raw(obj:)
|
|
75
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
76
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
77
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
78
|
+
obj.type.is_a?(TrophyApiClient::AdminAttributeType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "create_attribute_request_item_type"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
# An attribute to create.
|
|
9
|
+
class CreateAttributeRequestItem
|
|
10
|
+
# @return [String] The attribute name.
|
|
11
|
+
attr_reader :name
|
|
12
|
+
# @return [String] The attribute key. Only alphanumeric characters, hyphens, and underscores are
|
|
13
|
+
# permitted.
|
|
14
|
+
attr_reader :key
|
|
15
|
+
# @return [TrophyApiClient::CreateAttributeRequestItemType] The attribute type.
|
|
16
|
+
attr_reader :type
|
|
17
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
18
|
+
attr_reader :additional_properties
|
|
19
|
+
# @return [Object]
|
|
20
|
+
attr_reader :_field_set
|
|
21
|
+
protected :_field_set
|
|
22
|
+
|
|
23
|
+
OMIT = Object.new
|
|
24
|
+
|
|
25
|
+
# @param name [String] The attribute name.
|
|
26
|
+
# @param key [String] The attribute key. Only alphanumeric characters, hyphens, and underscores are
|
|
27
|
+
# permitted.
|
|
28
|
+
# @param type [TrophyApiClient::CreateAttributeRequestItemType] The attribute type.
|
|
29
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
30
|
+
# @return [TrophyApiClient::CreateAttributeRequestItem]
|
|
31
|
+
def initialize(name:, key:, type:, additional_properties: nil)
|
|
32
|
+
@name = name
|
|
33
|
+
@key = key
|
|
34
|
+
@type = type
|
|
35
|
+
@additional_properties = additional_properties
|
|
36
|
+
@_field_set = { "name": name, "key": key, "type": type }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Deserialize a JSON object to an instance of CreateAttributeRequestItem
|
|
40
|
+
#
|
|
41
|
+
# @param json_object [String]
|
|
42
|
+
# @return [TrophyApiClient::CreateAttributeRequestItem]
|
|
43
|
+
def self.from_json(json_object:)
|
|
44
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
45
|
+
parsed_json = JSON.parse(json_object)
|
|
46
|
+
name = parsed_json["name"]
|
|
47
|
+
key = parsed_json["key"]
|
|
48
|
+
type = parsed_json["type"]
|
|
49
|
+
new(
|
|
50
|
+
name: name,
|
|
51
|
+
key: key,
|
|
52
|
+
type: type,
|
|
53
|
+
additional_properties: struct
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Serialize an instance of CreateAttributeRequestItem to a JSON object
|
|
58
|
+
#
|
|
59
|
+
# @return [String]
|
|
60
|
+
def to_json(*_args)
|
|
61
|
+
@_field_set&.to_json
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
65
|
+
# hash and check each fields type against the current object's property
|
|
66
|
+
# definitions.
|
|
67
|
+
#
|
|
68
|
+
# @param obj [Object]
|
|
69
|
+
# @return [Void]
|
|
70
|
+
def self.validate_raw(obj:)
|
|
71
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
72
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
73
|
+
obj.type.is_a?(TrophyApiClient::CreateAttributeRequestItemType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "admin_attribute"
|
|
4
|
+
require_relative "admin_issue"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
# Response containing created attributes and any per-item issues.
|
|
10
|
+
class CreateAttributesResponse
|
|
11
|
+
# @return [Array<TrophyApiClient::AdminAttribute>] Array of successfully created attributes.
|
|
12
|
+
attr_reader :created
|
|
13
|
+
# @return [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during attribute creation.
|
|
14
|
+
attr_reader :issues
|
|
15
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
16
|
+
attr_reader :additional_properties
|
|
17
|
+
# @return [Object]
|
|
18
|
+
attr_reader :_field_set
|
|
19
|
+
protected :_field_set
|
|
20
|
+
|
|
21
|
+
OMIT = Object.new
|
|
22
|
+
|
|
23
|
+
# @param created [Array<TrophyApiClient::AdminAttribute>] Array of successfully created attributes.
|
|
24
|
+
# @param issues [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during attribute creation.
|
|
25
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
|
+
# @return [TrophyApiClient::CreateAttributesResponse]
|
|
27
|
+
def initialize(created:, issues:, additional_properties: nil)
|
|
28
|
+
@created = created
|
|
29
|
+
@issues = issues
|
|
30
|
+
@additional_properties = additional_properties
|
|
31
|
+
@_field_set = { "created": created, "issues": issues }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Deserialize a JSON object to an instance of CreateAttributesResponse
|
|
35
|
+
#
|
|
36
|
+
# @param json_object [String]
|
|
37
|
+
# @return [TrophyApiClient::CreateAttributesResponse]
|
|
38
|
+
def self.from_json(json_object:)
|
|
39
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
40
|
+
parsed_json = JSON.parse(json_object)
|
|
41
|
+
created = parsed_json["created"]&.map do |item|
|
|
42
|
+
item = item.to_json
|
|
43
|
+
TrophyApiClient::AdminAttribute.from_json(json_object: item)
|
|
44
|
+
end
|
|
45
|
+
issues = parsed_json["issues"]&.map do |item|
|
|
46
|
+
item = item.to_json
|
|
47
|
+
TrophyApiClient::AdminIssue.from_json(json_object: item)
|
|
48
|
+
end
|
|
49
|
+
new(
|
|
50
|
+
created: created,
|
|
51
|
+
issues: issues,
|
|
52
|
+
additional_properties: struct
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Serialize an instance of CreateAttributesResponse to a JSON object
|
|
57
|
+
#
|
|
58
|
+
# @return [String]
|
|
59
|
+
def to_json(*_args)
|
|
60
|
+
@_field_set&.to_json
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
64
|
+
# hash and check each fields type against the current object's property
|
|
65
|
+
# definitions.
|
|
66
|
+
#
|
|
67
|
+
# @param obj [Object]
|
|
68
|
+
# @return [Void]
|
|
69
|
+
def self.validate_raw(obj:)
|
|
70
|
+
obj.created.is_a?(Array) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
71
|
+
obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|