trophy_api_client 1.4.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/admin/points/boosts/client.rb +6 -74
- 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 +5 -6
- data/lib/trophy_api_client/types/deleted_resource.rb +3 -3
- 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
|
|
@@ -60,7 +60,7 @@ module TrophyApiClient
|
|
|
60
60
|
TrophyApiClient::CreatePointsBoostsResponse.from_json(json_object: response.body)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
#
|
|
63
|
+
# Delete multiple points boosts by ID.
|
|
64
64
|
#
|
|
65
65
|
# @param ids [String] A list of up to 100 boost IDs.
|
|
66
66
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
@@ -71,8 +71,8 @@ module TrophyApiClient
|
|
|
71
71
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
72
72
|
# api_key: "YOUR_API_KEY"
|
|
73
73
|
# )
|
|
74
|
-
# api.admin.points.boosts.
|
|
75
|
-
def
|
|
74
|
+
# api.admin.points.boosts.delete
|
|
75
|
+
def delete(ids: nil, request_options: nil)
|
|
76
76
|
response = @request_client.conn.delete do |req|
|
|
77
77
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
78
78
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
@@ -89,39 +89,6 @@ module TrophyApiClient
|
|
|
89
89
|
end
|
|
90
90
|
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
|
|
91
91
|
end
|
|
92
|
-
|
|
93
|
-
# Archive a points boost by ID.
|
|
94
|
-
#
|
|
95
|
-
# @param id [String] The UUID of the points boost to archive
|
|
96
|
-
# @param request_options [TrophyApiClient::RequestOptions]
|
|
97
|
-
# @return [TrophyApiClient::DeletePointsBoostsResponse]
|
|
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.points.boosts.archive(id: "id")
|
|
105
|
-
def archive(id:, 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 = {
|
|
110
|
-
**(req.headers || {}),
|
|
111
|
-
**@request_client.get_headers,
|
|
112
|
-
**(request_options&.additional_headers || {})
|
|
113
|
-
}.compact
|
|
114
|
-
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
115
|
-
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
116
|
-
end
|
|
117
|
-
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
118
|
-
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
119
|
-
end
|
|
120
|
-
req.url "#{@request_client.get_url(environment: admin,
|
|
121
|
-
request_options: request_options)}/points/boosts/#{id}"
|
|
122
|
-
end
|
|
123
|
-
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
|
|
124
|
-
end
|
|
125
92
|
end
|
|
126
93
|
|
|
127
94
|
class AsyncBoostsClient
|
|
@@ -177,7 +144,7 @@ module TrophyApiClient
|
|
|
177
144
|
end
|
|
178
145
|
end
|
|
179
146
|
|
|
180
|
-
#
|
|
147
|
+
# Delete multiple points boosts by ID.
|
|
181
148
|
#
|
|
182
149
|
# @param ids [String] A list of up to 100 boost IDs.
|
|
183
150
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
@@ -188,8 +155,8 @@ module TrophyApiClient
|
|
|
188
155
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
189
156
|
# api_key: "YOUR_API_KEY"
|
|
190
157
|
# )
|
|
191
|
-
# api.admin.points.boosts.
|
|
192
|
-
def
|
|
158
|
+
# api.admin.points.boosts.delete
|
|
159
|
+
def delete(ids: nil, request_options: nil)
|
|
193
160
|
Async do
|
|
194
161
|
response = @request_client.conn.delete do |req|
|
|
195
162
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
@@ -208,41 +175,6 @@ module TrophyApiClient
|
|
|
208
175
|
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
|
|
209
176
|
end
|
|
210
177
|
end
|
|
211
|
-
|
|
212
|
-
# Archive a points boost by ID.
|
|
213
|
-
#
|
|
214
|
-
# @param id [String] The UUID of the points boost to archive
|
|
215
|
-
# @param request_options [TrophyApiClient::RequestOptions]
|
|
216
|
-
# @return [TrophyApiClient::DeletePointsBoostsResponse]
|
|
217
|
-
# @example
|
|
218
|
-
# api = TrophyApiClient::Client.new(
|
|
219
|
-
# base_url: "https://api.example.com",
|
|
220
|
-
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
221
|
-
# api_key: "YOUR_API_KEY"
|
|
222
|
-
# )
|
|
223
|
-
# api.admin.points.boosts.archive(id: "id")
|
|
224
|
-
def archive(id:, request_options: nil)
|
|
225
|
-
Async do
|
|
226
|
-
response = @request_client.conn.delete do |req|
|
|
227
|
-
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
228
|
-
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
229
|
-
req.headers = {
|
|
230
|
-
**(req.headers || {}),
|
|
231
|
-
**@request_client.get_headers,
|
|
232
|
-
**(request_options&.additional_headers || {})
|
|
233
|
-
}.compact
|
|
234
|
-
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
235
|
-
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
236
|
-
end
|
|
237
|
-
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
238
|
-
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
239
|
-
end
|
|
240
|
-
req.url "#{@request_client.get_url(environment: admin,
|
|
241
|
-
request_options: request_options)}/points/boosts/#{id}"
|
|
242
|
-
end
|
|
243
|
-
TrophyApiClient::DeletePointsBoostsResponse.from_json(json_object: response.body)
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
178
|
end
|
|
247
179
|
end
|
|
248
180
|
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
|