trophy_api_client 1.6.0 → 1.8.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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/admin/attributes/client.rb +6 -6
  4. data/lib/trophy_api_client/admin/client.rb +14 -7
  5. data/lib/trophy_api_client/admin/leaderboards/client.rb +371 -0
  6. data/lib/trophy_api_client/admin/metrics/client.rb +6 -6
  7. data/lib/trophy_api_client/admin/points/boosts/client.rb +258 -39
  8. data/lib/trophy_api_client/admin/points/client.rb +21 -0
  9. data/lib/trophy_api_client/admin/points/levels/client.rb +402 -0
  10. data/lib/trophy_api_client/admin/points/systems/client.rb +374 -0
  11. data/lib/trophy_api_client/admin/points/triggers/client.rb +402 -0
  12. data/lib/trophy_api_client/types/admin_leaderboard.rb +171 -0
  13. data/lib/trophy_api_client/types/admin_leaderboard_rank_by.rb +10 -0
  14. data/lib/trophy_api_client/types/admin_leaderboard_run_unit.rb +10 -0
  15. data/lib/trophy_api_client/types/admin_leaderboard_status.rb +11 -0
  16. data/lib/trophy_api_client/types/{created_points_boost.rb → admin_points_boost.rb} +39 -23
  17. data/lib/trophy_api_client/types/{created_points_boost_rounding.rb → admin_points_boost_rounding.rb} +1 -1
  18. data/lib/trophy_api_client/types/{created_points_boost_status.rb → admin_points_boost_status.rb} +1 -1
  19. data/lib/trophy_api_client/types/admin_points_boost_user_attributes_item.rb +65 -0
  20. data/lib/trophy_api_client/types/admin_points_level.rb +109 -0
  21. data/lib/trophy_api_client/types/admin_points_level_badge.rb +55 -0
  22. data/lib/trophy_api_client/types/admin_points_system.rb +118 -0
  23. data/lib/trophy_api_client/types/admin_points_system_badge.rb +55 -0
  24. data/lib/trophy_api_client/types/admin_points_system_status.rb +9 -0
  25. data/lib/trophy_api_client/types/admin_points_trigger.rb +175 -0
  26. data/lib/trophy_api_client/types/admin_points_trigger_event_attributes_item.rb +66 -0
  27. data/lib/trophy_api_client/types/admin_points_trigger_status.rb +9 -0
  28. data/lib/trophy_api_client/types/admin_points_trigger_time_unit.rb +9 -0
  29. data/lib/trophy_api_client/types/admin_points_trigger_type.rb +12 -0
  30. data/lib/trophy_api_client/types/admin_points_trigger_user_attributes_item.rb +65 -0
  31. data/lib/trophy_api_client/types/create_leaderboard_request_item.rb +171 -0
  32. data/lib/trophy_api_client/types/create_leaderboard_request_item_rank_by.rb +10 -0
  33. data/lib/trophy_api_client/types/create_leaderboard_request_item_run_unit.rb +11 -0
  34. data/lib/trophy_api_client/types/create_leaderboard_request_item_status.rb +13 -0
  35. data/lib/trophy_api_client/types/create_leaderboards_request.rb +7 -0
  36. data/lib/trophy_api_client/types/create_leaderboards_response.rb +74 -0
  37. data/lib/trophy_api_client/types/create_points_boost_request_item.rb +125 -0
  38. data/lib/trophy_api_client/types/create_points_boost_request_item_rounding.rb +10 -0
  39. data/lib/trophy_api_client/types/create_points_boost_request_item_user_attributes_item.rb +67 -0
  40. data/lib/trophy_api_client/types/create_points_boosts_request.rb +7 -0
  41. data/lib/trophy_api_client/types/create_points_boosts_response.rb +4 -4
  42. data/lib/trophy_api_client/types/create_points_level_request_item.rb +103 -0
  43. data/lib/trophy_api_client/types/create_points_level_request_item_badge.rb +56 -0
  44. data/lib/trophy_api_client/types/create_points_levels_request.rb +7 -0
  45. data/lib/trophy_api_client/types/create_points_levels_response.rb +74 -0
  46. data/lib/trophy_api_client/types/create_points_system_request_item.rb +140 -0
  47. data/lib/trophy_api_client/types/create_points_system_request_item_badge.rb +55 -0
  48. data/lib/trophy_api_client/types/create_points_systems_request.rb +7 -0
  49. data/lib/trophy_api_client/types/create_points_systems_response.rb +74 -0
  50. data/lib/trophy_api_client/types/create_points_trigger_request_item.rb +167 -0
  51. data/lib/trophy_api_client/types/create_points_trigger_request_item_event_attributes_item.rb +67 -0
  52. data/lib/trophy_api_client/types/create_points_trigger_request_item_status.rb +9 -0
  53. data/lib/trophy_api_client/types/create_points_trigger_request_item_time_unit.rb +9 -0
  54. data/lib/trophy_api_client/types/create_points_trigger_request_item_type.rb +12 -0
  55. data/lib/trophy_api_client/types/create_points_trigger_request_item_user_attributes_item.rb +67 -0
  56. data/lib/trophy_api_client/types/create_points_triggers_request.rb +7 -0
  57. data/lib/trophy_api_client/types/create_points_triggers_response.rb +74 -0
  58. data/lib/trophy_api_client/types/created_admin_points_system.rb +163 -0
  59. data/lib/trophy_api_client/types/delete_leaderboards_response.rb +75 -0
  60. data/lib/trophy_api_client/types/delete_points_levels_response.rb +74 -0
  61. data/lib/trophy_api_client/types/delete_points_systems_response.rb +74 -0
  62. data/lib/trophy_api_client/types/delete_points_triggers_response.rb +75 -0
  63. data/lib/trophy_api_client/types/list_leaderboards_response.rb +7 -0
  64. data/lib/trophy_api_client/types/list_points_boosts_response.rb +7 -0
  65. data/lib/trophy_api_client/types/list_points_levels_response.rb +7 -0
  66. data/lib/trophy_api_client/types/list_points_systems_response.rb +7 -0
  67. data/lib/trophy_api_client/types/list_points_triggers_response.rb +7 -0
  68. data/lib/trophy_api_client/types/patch_points_boosts_request.rb +7 -0
  69. data/lib/trophy_api_client/types/patch_points_boosts_request_item.rb +118 -0
  70. data/lib/trophy_api_client/types/patch_points_boosts_request_item_rounding.rb +10 -0
  71. data/lib/trophy_api_client/types/patch_points_boosts_request_item_user_attributes_item.rb +67 -0
  72. data/lib/trophy_api_client/types/patch_points_boosts_response.rb +74 -0
  73. data/lib/trophy_api_client/types/patch_points_levels_request.rb +7 -0
  74. data/lib/trophy_api_client/types/patch_points_levels_request_item.rb +100 -0
  75. data/lib/trophy_api_client/types/patch_points_levels_request_item_badge.rb +55 -0
  76. data/lib/trophy_api_client/types/patch_points_levels_response.rb +74 -0
  77. data/lib/trophy_api_client/types/patch_points_triggers_request.rb +7 -0
  78. data/lib/trophy_api_client/types/patch_points_triggers_request_item.rb +174 -0
  79. data/lib/trophy_api_client/types/patch_points_triggers_request_item_event_attributes_item.rb +67 -0
  80. data/lib/trophy_api_client/types/patch_points_triggers_request_item_status.rb +9 -0
  81. data/lib/trophy_api_client/types/patch_points_triggers_request_item_time_unit.rb +9 -0
  82. data/lib/trophy_api_client/types/patch_points_triggers_request_item_type.rb +13 -0
  83. data/lib/trophy_api_client/types/patch_points_triggers_request_item_user_attributes_item.rb +67 -0
  84. data/lib/trophy_api_client/types/patch_points_triggers_response.rb +74 -0
  85. data/lib/trophy_api_client/types/update_leaderboard_request_item.rb +179 -0
  86. data/lib/trophy_api_client/types/update_leaderboard_request_item_rank_by.rb +11 -0
  87. data/lib/trophy_api_client/types/update_leaderboard_request_item_run_unit.rb +9 -0
  88. data/lib/trophy_api_client/types/update_leaderboard_request_item_status.rb +12 -0
  89. data/lib/trophy_api_client/types/update_leaderboards_request.rb +7 -0
  90. data/lib/trophy_api_client/types/update_leaderboards_response.rb +75 -0
  91. data/lib/trophy_api_client/types/update_points_system_request_item.rb +102 -0
  92. data/lib/trophy_api_client/types/update_points_system_request_item_badge.rb +55 -0
  93. data/lib/trophy_api_client/types/update_points_systems_request.rb +7 -0
  94. data/lib/trophy_api_client/types/update_points_systems_response.rb +74 -0
  95. data/lib/trophy_api_client/users/client.rb +2 -2
  96. data/lib/trophy_api_client/version.rb +1 -1
  97. data/lib/types_export.rb +93 -17
  98. metadata +87 -7
  99. data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb +0 -111
  100. data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item_rounding.rb +0 -16
  101. data/lib/trophy_api_client/types/notification_type.rb +0 -11
@@ -0,0 +1,402 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../../requests"
4
+ require_relative "../../../types/list_points_triggers_response"
5
+ require "json"
6
+ require_relative "../../../types/create_points_triggers_request"
7
+ require_relative "../../../types/create_points_triggers_response"
8
+ require_relative "../../../types/delete_points_triggers_response"
9
+ require_relative "../../../types/patch_points_triggers_request"
10
+ require_relative "../../../types/patch_points_triggers_response"
11
+ require_relative "../../../types/admin_points_trigger"
12
+ require "async"
13
+
14
+ module TrophyApiClient
15
+ module Admin
16
+ module Points
17
+ class TriggersClient
18
+ # @return [TrophyApiClient::RequestClient]
19
+ attr_reader :request_client
20
+
21
+ # @param request_client [TrophyApiClient::RequestClient]
22
+ # @return [TrophyApiClient::Admin::Points::TriggersClient]
23
+ def initialize(request_client:)
24
+ @request_client = request_client
25
+ end
26
+
27
+ # List points triggers for a system.
28
+ #
29
+ # @param system_id [String] The UUID of the points system.
30
+ # @param limit [Integer] Maximum number of results to return (1-100, default 10).
31
+ # @param skip [Integer] Number of results to skip for pagination (default 0).
32
+ # @param request_options [TrophyApiClient::RequestOptions]
33
+ # @return [TrophyApiClient::LIST_POINTS_TRIGGERS_RESPONSE]
34
+ # @example
35
+ # api = TrophyApiClient::Client.new(
36
+ # base_url: "https://api.example.com",
37
+ # environment: TrophyApiClient::Environment::PRODUCTION,
38
+ # api_key: "YOUR_API_KEY"
39
+ # )
40
+ # api.admin.points.triggers.list(
41
+ # system_id: "550e8400-e29b-41d4-a716-446655440000",
42
+ # limit: 1,
43
+ # skip: 1
44
+ # )
45
+ def list(system_id:, limit: nil, skip: nil, request_options: nil)
46
+ response = @request_client.conn.get do |req|
47
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
48
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
49
+ req.headers = {
50
+ **(req.headers || {}),
51
+ **@request_client.get_headers,
52
+ **(request_options&.additional_headers || {})
53
+ }.compact
54
+ req.params = {
55
+ **(request_options&.additional_query_parameters || {}),
56
+ "limit": limit,
57
+ "skip": skip
58
+ }.compact
59
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
60
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
61
+ end
62
+ req.url "#{@request_client.get_url(environment: admin,
63
+ request_options: request_options)}/points/#{system_id}/triggers"
64
+ end
65
+ parsed_json = JSON.parse(response.body)
66
+ parsed_json&.map do |item|
67
+ item = item.to_json
68
+ TrophyApiClient::AdminPointsTrigger.from_json(json_object: item)
69
+ end
70
+ end
71
+
72
+ # Create points triggers in bulk. Maximum 100 triggers per request.
73
+ #
74
+ # @param system_id [String] The UUID of the points system.
75
+ # @param request [TrophyApiClient::CREATE_POINTS_TRIGGERS_REQUEST]
76
+ # @param request_options [TrophyApiClient::RequestOptions]
77
+ # @return [TrophyApiClient::CreatePointsTriggersResponse]
78
+ # @example
79
+ # api = TrophyApiClient::Client.new(
80
+ # base_url: "https://api.example.com",
81
+ # environment: TrophyApiClient::Environment::PRODUCTION,
82
+ # api_key: "YOUR_API_KEY"
83
+ # )
84
+ # api.admin.points.triggers.create(system_id: "550e8400-e29b-41d4-a716-446655440000", request: [{ type: METRIC, points: 10 }])
85
+ def create(system_id:, request:, request_options: nil)
86
+ response = @request_client.conn.post do |req|
87
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
88
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
89
+ req.headers = {
90
+ **(req.headers || {}),
91
+ **@request_client.get_headers,
92
+ **(request_options&.additional_headers || {})
93
+ }.compact
94
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
95
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
96
+ end
97
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
98
+ req.url "#{@request_client.get_url(environment: admin,
99
+ request_options: request_options)}/points/#{system_id}/triggers"
100
+ end
101
+ TrophyApiClient::CreatePointsTriggersResponse.from_json(json_object: response.body)
102
+ end
103
+
104
+ # Delete (archive) points triggers by ID. Maximum 100 trigger IDs per request.
105
+ #
106
+ # @param system_id [String] The UUID of the points system.
107
+ # @param ids [String] Trigger IDs to delete. Can be repeated or comma-separated.
108
+ # @param request_options [TrophyApiClient::RequestOptions]
109
+ # @return [TrophyApiClient::DeletePointsTriggersResponse]
110
+ # @example
111
+ # api = TrophyApiClient::Client.new(
112
+ # base_url: "https://api.example.com",
113
+ # environment: TrophyApiClient::Environment::PRODUCTION,
114
+ # api_key: "YOUR_API_KEY"
115
+ # )
116
+ # api.admin.points.triggers.delete
117
+ def delete(system_id:, ids: nil, request_options: nil)
118
+ response = @request_client.conn.delete do |req|
119
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
120
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
121
+ req.headers = {
122
+ **(req.headers || {}),
123
+ **@request_client.get_headers,
124
+ **(request_options&.additional_headers || {})
125
+ }.compact
126
+ req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
127
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
128
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
129
+ end
130
+ req.url "#{@request_client.get_url(environment: admin,
131
+ request_options: request_options)}/points/#{system_id}/triggers"
132
+ end
133
+ TrophyApiClient::DeletePointsTriggersResponse.from_json(json_object: response.body)
134
+ end
135
+
136
+ # Update points triggers in bulk. Maximum 100 triggers per request. Only provided
137
+ # fields are updated; omitted fields are preserved.
138
+ #
139
+ # @param system_id [String] The UUID of the points system.
140
+ # @param request [TrophyApiClient::PATCH_POINTS_TRIGGERS_REQUEST]
141
+ # @param request_options [TrophyApiClient::RequestOptions]
142
+ # @return [TrophyApiClient::PatchPointsTriggersResponse]
143
+ # @example
144
+ # api = TrophyApiClient::Client.new(
145
+ # base_url: "https://api.example.com",
146
+ # environment: TrophyApiClient::Environment::PRODUCTION,
147
+ # api_key: "YOUR_API_KEY"
148
+ # )
149
+ # api.admin.points.triggers.update(system_id: "550e8400-e29b-41d4-a716-446655440000", request: [{ id: "id" }])
150
+ def update(system_id:, request:, request_options: nil)
151
+ response = @request_client.conn.patch do |req|
152
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
153
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
154
+ req.headers = {
155
+ **(req.headers || {}),
156
+ **@request_client.get_headers,
157
+ **(request_options&.additional_headers || {})
158
+ }.compact
159
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
160
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
161
+ end
162
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
163
+ req.url "#{@request_client.get_url(environment: admin,
164
+ request_options: request_options)}/points/#{system_id}/triggers"
165
+ end
166
+ TrophyApiClient::PatchPointsTriggersResponse.from_json(json_object: response.body)
167
+ end
168
+
169
+ # Get a single points trigger by ID.
170
+ #
171
+ # @param system_id [String] The UUID of the points system.
172
+ # @param id [String] The UUID of the points trigger.
173
+ # @param request_options [TrophyApiClient::RequestOptions]
174
+ # @return [TrophyApiClient::AdminPointsTrigger]
175
+ # @example
176
+ # api = TrophyApiClient::Client.new(
177
+ # base_url: "https://api.example.com",
178
+ # environment: TrophyApiClient::Environment::PRODUCTION,
179
+ # api_key: "YOUR_API_KEY"
180
+ # )
181
+ # api.admin.points.triggers.get(system_id: "550e8400-e29b-41d4-a716-446655440000", id: "660f9500-f30c-42e5-b827-557766550001")
182
+ def get(system_id:, id:, request_options: nil)
183
+ response = @request_client.conn.get do |req|
184
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
185
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
186
+ req.headers = {
187
+ **(req.headers || {}),
188
+ **@request_client.get_headers,
189
+ **(request_options&.additional_headers || {})
190
+ }.compact
191
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
192
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
193
+ end
194
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
195
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
196
+ end
197
+ req.url "#{@request_client.get_url(environment: admin,
198
+ request_options: request_options)}/points/#{system_id}/triggers/#{id}"
199
+ end
200
+ TrophyApiClient::AdminPointsTrigger.from_json(json_object: response.body)
201
+ end
202
+ end
203
+
204
+ class AsyncTriggersClient
205
+ # @return [TrophyApiClient::AsyncRequestClient]
206
+ attr_reader :request_client
207
+
208
+ # @param request_client [TrophyApiClient::AsyncRequestClient]
209
+ # @return [TrophyApiClient::Admin::Points::AsyncTriggersClient]
210
+ def initialize(request_client:)
211
+ @request_client = request_client
212
+ end
213
+
214
+ # List points triggers for a system.
215
+ #
216
+ # @param system_id [String] The UUID of the points system.
217
+ # @param limit [Integer] Maximum number of results to return (1-100, default 10).
218
+ # @param skip [Integer] Number of results to skip for pagination (default 0).
219
+ # @param request_options [TrophyApiClient::RequestOptions]
220
+ # @return [TrophyApiClient::LIST_POINTS_TRIGGERS_RESPONSE]
221
+ # @example
222
+ # api = TrophyApiClient::Client.new(
223
+ # base_url: "https://api.example.com",
224
+ # environment: TrophyApiClient::Environment::PRODUCTION,
225
+ # api_key: "YOUR_API_KEY"
226
+ # )
227
+ # api.admin.points.triggers.list(
228
+ # system_id: "550e8400-e29b-41d4-a716-446655440000",
229
+ # limit: 1,
230
+ # skip: 1
231
+ # )
232
+ def list(system_id:, limit: nil, skip: nil, request_options: nil)
233
+ Async do
234
+ response = @request_client.conn.get do |req|
235
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
236
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
237
+ req.headers = {
238
+ **(req.headers || {}),
239
+ **@request_client.get_headers,
240
+ **(request_options&.additional_headers || {})
241
+ }.compact
242
+ req.params = {
243
+ **(request_options&.additional_query_parameters || {}),
244
+ "limit": limit,
245
+ "skip": skip
246
+ }.compact
247
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
248
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
249
+ end
250
+ req.url "#{@request_client.get_url(environment: admin,
251
+ request_options: request_options)}/points/#{system_id}/triggers"
252
+ end
253
+ parsed_json = JSON.parse(response.body)
254
+ parsed_json&.map do |item|
255
+ item = item.to_json
256
+ TrophyApiClient::AdminPointsTrigger.from_json(json_object: item)
257
+ end
258
+ end
259
+ end
260
+
261
+ # Create points triggers in bulk. Maximum 100 triggers per request.
262
+ #
263
+ # @param system_id [String] The UUID of the points system.
264
+ # @param request [TrophyApiClient::CREATE_POINTS_TRIGGERS_REQUEST]
265
+ # @param request_options [TrophyApiClient::RequestOptions]
266
+ # @return [TrophyApiClient::CreatePointsTriggersResponse]
267
+ # @example
268
+ # api = TrophyApiClient::Client.new(
269
+ # base_url: "https://api.example.com",
270
+ # environment: TrophyApiClient::Environment::PRODUCTION,
271
+ # api_key: "YOUR_API_KEY"
272
+ # )
273
+ # api.admin.points.triggers.create(system_id: "550e8400-e29b-41d4-a716-446655440000", request: [{ type: METRIC, points: 10 }])
274
+ def create(system_id:, request:, request_options: nil)
275
+ Async do
276
+ response = @request_client.conn.post do |req|
277
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
278
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
279
+ req.headers = {
280
+ **(req.headers || {}),
281
+ **@request_client.get_headers,
282
+ **(request_options&.additional_headers || {})
283
+ }.compact
284
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
285
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
286
+ end
287
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
288
+ req.url "#{@request_client.get_url(environment: admin,
289
+ request_options: request_options)}/points/#{system_id}/triggers"
290
+ end
291
+ TrophyApiClient::CreatePointsTriggersResponse.from_json(json_object: response.body)
292
+ end
293
+ end
294
+
295
+ # Delete (archive) points triggers by ID. Maximum 100 trigger IDs per request.
296
+ #
297
+ # @param system_id [String] The UUID of the points system.
298
+ # @param ids [String] Trigger IDs to delete. Can be repeated or comma-separated.
299
+ # @param request_options [TrophyApiClient::RequestOptions]
300
+ # @return [TrophyApiClient::DeletePointsTriggersResponse]
301
+ # @example
302
+ # api = TrophyApiClient::Client.new(
303
+ # base_url: "https://api.example.com",
304
+ # environment: TrophyApiClient::Environment::PRODUCTION,
305
+ # api_key: "YOUR_API_KEY"
306
+ # )
307
+ # api.admin.points.triggers.delete
308
+ def delete(system_id:, ids: nil, request_options: nil)
309
+ Async do
310
+ response = @request_client.conn.delete do |req|
311
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
312
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
313
+ req.headers = {
314
+ **(req.headers || {}),
315
+ **@request_client.get_headers,
316
+ **(request_options&.additional_headers || {})
317
+ }.compact
318
+ req.params = { **(request_options&.additional_query_parameters || {}), "ids": ids }.compact
319
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
320
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
321
+ end
322
+ req.url "#{@request_client.get_url(environment: admin,
323
+ request_options: request_options)}/points/#{system_id}/triggers"
324
+ end
325
+ TrophyApiClient::DeletePointsTriggersResponse.from_json(json_object: response.body)
326
+ end
327
+ end
328
+
329
+ # Update points triggers in bulk. Maximum 100 triggers per request. Only provided
330
+ # fields are updated; omitted fields are preserved.
331
+ #
332
+ # @param system_id [String] The UUID of the points system.
333
+ # @param request [TrophyApiClient::PATCH_POINTS_TRIGGERS_REQUEST]
334
+ # @param request_options [TrophyApiClient::RequestOptions]
335
+ # @return [TrophyApiClient::PatchPointsTriggersResponse]
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.points.triggers.update(system_id: "550e8400-e29b-41d4-a716-446655440000", request: [{ id: "id" }])
343
+ def update(system_id:, request:, request_options: nil)
344
+ Async do
345
+ response = @request_client.conn.patch 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
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
357
+ req.url "#{@request_client.get_url(environment: admin,
358
+ request_options: request_options)}/points/#{system_id}/triggers"
359
+ end
360
+ TrophyApiClient::PatchPointsTriggersResponse.from_json(json_object: response.body)
361
+ end
362
+ end
363
+
364
+ # Get a single points trigger by ID.
365
+ #
366
+ # @param system_id [String] The UUID of the points system.
367
+ # @param id [String] The UUID of the points trigger.
368
+ # @param request_options [TrophyApiClient::RequestOptions]
369
+ # @return [TrophyApiClient::AdminPointsTrigger]
370
+ # @example
371
+ # api = TrophyApiClient::Client.new(
372
+ # base_url: "https://api.example.com",
373
+ # environment: TrophyApiClient::Environment::PRODUCTION,
374
+ # api_key: "YOUR_API_KEY"
375
+ # )
376
+ # api.admin.points.triggers.get(system_id: "550e8400-e29b-41d4-a716-446655440000", id: "660f9500-f30c-42e5-b827-557766550001")
377
+ def get(system_id:, id:, request_options: nil)
378
+ Async do
379
+ response = @request_client.conn.get do |req|
380
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
381
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
382
+ req.headers = {
383
+ **(req.headers || {}),
384
+ **@request_client.get_headers,
385
+ **(request_options&.additional_headers || {})
386
+ }.compact
387
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
388
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
389
+ end
390
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
391
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
392
+ end
393
+ req.url "#{@request_client.get_url(environment: admin,
394
+ request_options: request_options)}/points/#{system_id}/triggers/#{id}"
395
+ end
396
+ TrophyApiClient::AdminPointsTrigger.from_json(json_object: response.body)
397
+ end
398
+ end
399
+ end
400
+ end
401
+ end
402
+ 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