trophy_api_client 1.5.0 → 1.7.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/admin/attributes/client.rb +368 -0
  4. data/lib/trophy_api_client/admin/client.rb +21 -0
  5. data/lib/trophy_api_client/admin/leaderboards/client.rb +371 -0
  6. data/lib/trophy_api_client/admin/metrics/client.rb +366 -0
  7. data/lib/trophy_api_client/types/admin_attribute.rb +81 -0
  8. data/lib/trophy_api_client/types/admin_attribute_type.rb +9 -0
  9. data/lib/trophy_api_client/types/admin_leaderboard.rb +171 -0
  10. data/lib/trophy_api_client/types/admin_leaderboard_rank_by.rb +10 -0
  11. data/lib/trophy_api_client/types/admin_leaderboard_run_unit.rb +10 -0
  12. data/lib/trophy_api_client/types/admin_leaderboard_status.rb +11 -0
  13. data/lib/trophy_api_client/types/create_attribute_request_item.rb +76 -0
  14. data/lib/trophy_api_client/types/create_attribute_request_item_type.rb +9 -0
  15. data/lib/trophy_api_client/types/create_attributes_request.rb +7 -0
  16. data/lib/trophy_api_client/types/create_attributes_response.rb +74 -0
  17. data/lib/trophy_api_client/types/create_leaderboard_request_item.rb +171 -0
  18. data/lib/trophy_api_client/types/create_leaderboard_request_item_rank_by.rb +10 -0
  19. data/lib/trophy_api_client/types/create_leaderboard_request_item_run_unit.rb +11 -0
  20. data/lib/trophy_api_client/types/create_leaderboard_request_item_status.rb +13 -0
  21. data/lib/trophy_api_client/types/create_leaderboards_request.rb +7 -0
  22. data/lib/trophy_api_client/types/create_leaderboards_response.rb +74 -0
  23. data/lib/trophy_api_client/types/create_metric_request_item.rb +87 -0
  24. data/lib/trophy_api_client/types/create_metric_request_item_unit_type.rb +9 -0
  25. data/lib/trophy_api_client/types/create_metrics_request.rb +7 -0
  26. data/lib/trophy_api_client/types/create_metrics_response.rb +74 -0
  27. data/lib/trophy_api_client/types/created_metric.rb +88 -0
  28. data/lib/trophy_api_client/types/created_metric_unit_type.rb +9 -0
  29. data/lib/trophy_api_client/types/delete_attributes_response.rb +75 -0
  30. data/lib/trophy_api_client/types/delete_leaderboards_response.rb +75 -0
  31. data/lib/trophy_api_client/types/delete_metrics_response.rb +75 -0
  32. data/lib/trophy_api_client/types/delete_points_boosts_response.rb +2 -2
  33. data/lib/trophy_api_client/types/list_attributes_response.rb +7 -0
  34. data/lib/trophy_api_client/types/list_leaderboards_response.rb +7 -0
  35. data/lib/trophy_api_client/types/list_metrics_response.rb +7 -0
  36. data/lib/trophy_api_client/types/metric_response.rb +2 -17
  37. data/lib/trophy_api_client/types/update_attribute_request_item.rb +69 -0
  38. data/lib/trophy_api_client/types/update_attributes_request.rb +7 -0
  39. data/lib/trophy_api_client/types/update_attributes_response.rb +75 -0
  40. data/lib/trophy_api_client/types/update_leaderboard_request_item.rb +179 -0
  41. data/lib/trophy_api_client/types/update_leaderboard_request_item_rank_by.rb +11 -0
  42. data/lib/trophy_api_client/types/update_leaderboard_request_item_run_unit.rb +9 -0
  43. data/lib/trophy_api_client/types/update_leaderboard_request_item_status.rb +12 -0
  44. data/lib/trophy_api_client/types/update_leaderboards_request.rb +7 -0
  45. data/lib/trophy_api_client/types/update_leaderboards_response.rb +75 -0
  46. data/lib/trophy_api_client/types/update_metric_request_item.rb +86 -0
  47. data/lib/trophy_api_client/types/update_metric_request_item_unit_type.rb +9 -0
  48. data/lib/trophy_api_client/types/update_metrics_request.rb +7 -0
  49. data/lib/trophy_api_client/types/update_metrics_response.rb +75 -0
  50. data/lib/trophy_api_client/users/client.rb +2 -2
  51. data/lib/trophy_api_client/version.rb +1 -1
  52. data/lib/types_export.rb +51 -12
  53. metadata +45 -3
  54. data/lib/trophy_api_client/types/metric_status.rb +0 -9
  55. data/lib/trophy_api_client/types/notification_type.rb +0 -11
@@ -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.
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 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 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.
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 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 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,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The attribute type.
5
+ class AdminAttributeType
6
+ USER = "user"
7
+ EVENT = "event"
8
+ end
9
+ end
@@ -0,0 +1,171 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "admin_leaderboard_status"
4
+ require_relative "admin_leaderboard_rank_by"
5
+ require_relative "admin_leaderboard_run_unit"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module TrophyApiClient
10
+ # A leaderboard returned from the admin leaderboards endpoints.
11
+ class AdminLeaderboard
12
+ # @return [String] The UUID of the leaderboard.
13
+ attr_reader :id
14
+ # @return [String] The leaderboard name.
15
+ attr_reader :name
16
+ # @return [String] The leaderboard key.
17
+ attr_reader :key
18
+ # @return [String] The leaderboard description.
19
+ attr_reader :description
20
+ # @return [TrophyApiClient::AdminLeaderboardStatus] The current user-facing status of the leaderboard.
21
+ attr_reader :status
22
+ # @return [TrophyApiClient::AdminLeaderboardRankBy] What the leaderboard ranks by.
23
+ attr_reader :rank_by
24
+ # @return [String] The metric ID used when `rankBy` is `metric`.
25
+ attr_reader :metric_id
26
+ # @return [String] The points system ID used when `rankBy` is `points`.
27
+ attr_reader :points_system_id
28
+ # @return [Integer] The maximum number of participants.
29
+ attr_reader :max_participants
30
+ # @return [String] The leaderboard start date in YYYY-MM-DD format.
31
+ attr_reader :start
32
+ # @return [String] The optional leaderboard end date in YYYY-MM-DD format.
33
+ attr_reader :end_
34
+ # @return [Array<String>] The UUIDs of the user attributes used for ranking breakdowns.
35
+ attr_reader :breakdown_attributes
36
+ # @return [TrophyApiClient::AdminLeaderboardRunUnit] The recurrence unit when the leaderboard repeats.
37
+ attr_reader :run_unit
38
+ # @return [Integer] The number of recurrence units between leaderboard runs.
39
+ attr_reader :run_interval
40
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
41
+ attr_reader :additional_properties
42
+ # @return [Object]
43
+ attr_reader :_field_set
44
+ protected :_field_set
45
+
46
+ OMIT = Object.new
47
+
48
+ # @param id [String] The UUID of the leaderboard.
49
+ # @param name [String] The leaderboard name.
50
+ # @param key [String] The leaderboard key.
51
+ # @param description [String] The leaderboard description.
52
+ # @param status [TrophyApiClient::AdminLeaderboardStatus] The current user-facing status of the leaderboard.
53
+ # @param rank_by [TrophyApiClient::AdminLeaderboardRankBy] What the leaderboard ranks by.
54
+ # @param metric_id [String] The metric ID used when `rankBy` is `metric`.
55
+ # @param points_system_id [String] The points system ID used when `rankBy` is `points`.
56
+ # @param max_participants [Integer] The maximum number of participants.
57
+ # @param start [String] The leaderboard start date in YYYY-MM-DD format.
58
+ # @param end_ [String] The optional leaderboard end date in YYYY-MM-DD format.
59
+ # @param breakdown_attributes [Array<String>] The UUIDs of the user attributes used for ranking breakdowns.
60
+ # @param run_unit [TrophyApiClient::AdminLeaderboardRunUnit] The recurrence unit when the leaderboard repeats.
61
+ # @param run_interval [Integer] The number of recurrence units between leaderboard runs.
62
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
63
+ # @return [TrophyApiClient::AdminLeaderboard]
64
+ def initialize(id:, name:, key:, status:, rank_by:, max_participants:, start:, breakdown_attributes:,
65
+ description: OMIT, metric_id: OMIT, points_system_id: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
66
+ @id = id
67
+ @name = name
68
+ @key = key
69
+ @description = description if description != OMIT
70
+ @status = status
71
+ @rank_by = rank_by
72
+ @metric_id = metric_id if metric_id != OMIT
73
+ @points_system_id = points_system_id if points_system_id != OMIT
74
+ @max_participants = max_participants
75
+ @start = start
76
+ @end_ = end_ if end_ != OMIT
77
+ @breakdown_attributes = breakdown_attributes
78
+ @run_unit = run_unit if run_unit != OMIT
79
+ @run_interval = run_interval if run_interval != OMIT
80
+ @additional_properties = additional_properties
81
+ @_field_set = {
82
+ "id": id,
83
+ "name": name,
84
+ "key": key,
85
+ "description": description,
86
+ "status": status,
87
+ "rankBy": rank_by,
88
+ "metricId": metric_id,
89
+ "pointsSystemId": points_system_id,
90
+ "maxParticipants": max_participants,
91
+ "start": start,
92
+ "end": end_,
93
+ "breakdownAttributes": breakdown_attributes,
94
+ "runUnit": run_unit,
95
+ "runInterval": run_interval
96
+ }.reject do |_k, v|
97
+ v == OMIT
98
+ end
99
+ end
100
+
101
+ # Deserialize a JSON object to an instance of AdminLeaderboard
102
+ #
103
+ # @param json_object [String]
104
+ # @return [TrophyApiClient::AdminLeaderboard]
105
+ def self.from_json(json_object:)
106
+ struct = JSON.parse(json_object, object_class: OpenStruct)
107
+ parsed_json = JSON.parse(json_object)
108
+ id = parsed_json["id"]
109
+ name = parsed_json["name"]
110
+ key = parsed_json["key"]
111
+ description = parsed_json["description"]
112
+ status = parsed_json["status"]
113
+ rank_by = parsed_json["rankBy"]
114
+ metric_id = parsed_json["metricId"]
115
+ points_system_id = parsed_json["pointsSystemId"]
116
+ max_participants = parsed_json["maxParticipants"]
117
+ start = parsed_json["start"]
118
+ end_ = parsed_json["end"]
119
+ breakdown_attributes = parsed_json["breakdownAttributes"]
120
+ run_unit = parsed_json["runUnit"]
121
+ run_interval = parsed_json["runInterval"]
122
+ new(
123
+ id: id,
124
+ name: name,
125
+ key: key,
126
+ description: description,
127
+ status: status,
128
+ rank_by: rank_by,
129
+ metric_id: metric_id,
130
+ points_system_id: points_system_id,
131
+ max_participants: max_participants,
132
+ start: start,
133
+ end_: end_,
134
+ breakdown_attributes: breakdown_attributes,
135
+ run_unit: run_unit,
136
+ run_interval: run_interval,
137
+ additional_properties: struct
138
+ )
139
+ end
140
+
141
+ # Serialize an instance of AdminLeaderboard to a JSON object
142
+ #
143
+ # @return [String]
144
+ def to_json(*_args)
145
+ @_field_set&.to_json
146
+ end
147
+
148
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
149
+ # hash and check each fields type against the current object's property
150
+ # definitions.
151
+ #
152
+ # @param obj [Object]
153
+ # @return [Void]
154
+ def self.validate_raw(obj:)
155
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
156
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
157
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
158
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
159
+ obj.status.is_a?(TrophyApiClient::AdminLeaderboardStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
160
+ obj.rank_by.is_a?(TrophyApiClient::AdminLeaderboardRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
161
+ obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
162
+ obj.points_system_id&.is_a?(String) != false || raise("Passed value for field obj.points_system_id is not the expected type, validation failed.")
163
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
164
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
165
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
166
+ obj.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
167
+ obj.run_unit&.is_a?(TrophyApiClient::AdminLeaderboardRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
168
+ obj.run_interval&.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # What the leaderboard ranks by.
5
+ class AdminLeaderboardRankBy
6
+ METRIC = "metric"
7
+ STREAK = "streak"
8
+ POINTS = "points"
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The recurrence unit when the leaderboard repeats.
5
+ class AdminLeaderboardRunUnit
6
+ DAY = "day"
7
+ MONTH = "month"
8
+ YEAR = "year"
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The current user-facing status of the leaderboard.
5
+ class AdminLeaderboardStatus
6
+ INACTIVE = "inactive"
7
+ ACTIVE = "active"
8
+ SCHEDULED = "scheduled"
9
+ FINISHED = "finished"
10
+ end
11
+ end