trophy_api_client 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/points/client.rb +152 -0
- data/lib/trophy_api_client/types/achievement_response.rb +11 -1
- data/lib/trophy_api_client/types/achievement_response_trigger.rb +1 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +11 -1
- data/lib/trophy_api_client/types/get_user_points_response.rb +38 -22
- data/lib/trophy_api_client/types/metric_event_points_response.rb +47 -31
- data/lib/trophy_api_client/types/points_level.rb +103 -0
- data/lib/trophy_api_client/types/points_level_summary_response.rb +7 -0
- data/lib/trophy_api_client/types/points_level_summary_response_item.rb +71 -0
- data/lib/trophy_api_client/types/points_response.rb +103 -0
- data/lib/trophy_api_client/types/user_achievement_response.rb +11 -1
- data/lib/trophy_api_client/types/user_achievement_with_stats_response.rb +11 -1
- data/lib/trophy_api_client/types/webhooks_points_level_changed_payload.rb +117 -0
- data/lib/trophy_api_client/types/webhooks_points_level_changed_payload_points.rb +114 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +6 -0
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74ccdc4a3dcbe88ed2254ca474165644225960617b4e4498f7deec3db6e209bc
|
|
4
|
+
data.tar.gz: 5f3cc5a4aa340463de78a5cdad7f043e56960cd5a9cdf50eb03c86934549d7e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9176a0b52777a98068243e21bf0d891fe3035b3643cb54dc9514f359c4198186197492fef8b664e911b5dba3b8d81c2f66c11501a23270a653919fa3dd500bb
|
|
7
|
+
data.tar.gz: 9b870ec63aa0b1cf14cd716ed095f0b252672b415f6d11ff992cb948867059794f216c8b0dd5e28d3da2c4ae33e1e569d1e31a59dc124d36159e70e00db51259
|
data/lib/gemconfig.rb
CHANGED
|
@@ -5,6 +5,8 @@ require_relative "../types/points_summary_response"
|
|
|
5
5
|
require "json"
|
|
6
6
|
require_relative "../types/points_system_response"
|
|
7
7
|
require_relative "../types/points_boost"
|
|
8
|
+
require_relative "../types/points_level"
|
|
9
|
+
require_relative "../types/points_level_summary_response"
|
|
8
10
|
require "async"
|
|
9
11
|
|
|
10
12
|
module TrophyApiClient
|
|
@@ -129,6 +131,79 @@ module TrophyApiClient
|
|
|
129
131
|
TrophyApiClient::PointsBoost.from_json(json_object: item)
|
|
130
132
|
end
|
|
131
133
|
end
|
|
134
|
+
|
|
135
|
+
# Get all levels for a points system.
|
|
136
|
+
#
|
|
137
|
+
# @param key [String] Key of the points system.
|
|
138
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
139
|
+
# @return [Array<TrophyApiClient::PointsLevel>]
|
|
140
|
+
# @example
|
|
141
|
+
# api = TrophyApiClient::Client.new(
|
|
142
|
+
# base_url: "https://api.example.com",
|
|
143
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
144
|
+
# api_key: "YOUR_API_KEY"
|
|
145
|
+
# )
|
|
146
|
+
# api.points.levels(key: "points-system-key")
|
|
147
|
+
def levels(key:, request_options: nil)
|
|
148
|
+
response = @request_client.conn.get do |req|
|
|
149
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
150
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
151
|
+
req.headers = {
|
|
152
|
+
**(req.headers || {}),
|
|
153
|
+
**@request_client.get_headers,
|
|
154
|
+
**(request_options&.additional_headers || {})
|
|
155
|
+
}.compact
|
|
156
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
157
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
158
|
+
end
|
|
159
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
160
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
161
|
+
end
|
|
162
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/points/#{key}/levels"
|
|
163
|
+
end
|
|
164
|
+
parsed_json = JSON.parse(response.body)
|
|
165
|
+
parsed_json&.map do |item|
|
|
166
|
+
item = item.to_json
|
|
167
|
+
TrophyApiClient::PointsLevel.from_json(json_object: item)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Get a breakdown of the number of users at each level in a points system.
|
|
172
|
+
#
|
|
173
|
+
# @param key [String] Key of the points system.
|
|
174
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
175
|
+
# @return [TrophyApiClient::POINTS_LEVEL_SUMMARY_RESPONSE]
|
|
176
|
+
# @example
|
|
177
|
+
# api = TrophyApiClient::Client.new(
|
|
178
|
+
# base_url: "https://api.example.com",
|
|
179
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
180
|
+
# api_key: "YOUR_API_KEY"
|
|
181
|
+
# )
|
|
182
|
+
# api.points.level_summary(key: "points-system-key")
|
|
183
|
+
def level_summary(key:, request_options: nil)
|
|
184
|
+
response = @request_client.conn.get do |req|
|
|
185
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
186
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
187
|
+
req.headers = {
|
|
188
|
+
**(req.headers || {}),
|
|
189
|
+
**@request_client.get_headers,
|
|
190
|
+
**(request_options&.additional_headers || {})
|
|
191
|
+
}.compact
|
|
192
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
193
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
194
|
+
end
|
|
195
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
196
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
197
|
+
end
|
|
198
|
+
req.url "#{@request_client.get_url(environment: api,
|
|
199
|
+
request_options: request_options)}/points/#{key}/level-summary"
|
|
200
|
+
end
|
|
201
|
+
parsed_json = JSON.parse(response.body)
|
|
202
|
+
parsed_json&.map do |item|
|
|
203
|
+
item = item.to_json
|
|
204
|
+
TrophyApiClient::PointsLevelSummaryResponseItem.from_json(json_object: item)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
132
207
|
end
|
|
133
208
|
|
|
134
209
|
class AsyncPointsClient
|
|
@@ -258,5 +333,82 @@ module TrophyApiClient
|
|
|
258
333
|
end
|
|
259
334
|
end
|
|
260
335
|
end
|
|
336
|
+
|
|
337
|
+
# Get all levels for a points system.
|
|
338
|
+
#
|
|
339
|
+
# @param key [String] Key of the points system.
|
|
340
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
341
|
+
# @return [Array<TrophyApiClient::PointsLevel>]
|
|
342
|
+
# @example
|
|
343
|
+
# api = TrophyApiClient::Client.new(
|
|
344
|
+
# base_url: "https://api.example.com",
|
|
345
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
346
|
+
# api_key: "YOUR_API_KEY"
|
|
347
|
+
# )
|
|
348
|
+
# api.points.levels(key: "points-system-key")
|
|
349
|
+
def levels(key:, request_options: nil)
|
|
350
|
+
Async do
|
|
351
|
+
response = @request_client.conn.get do |req|
|
|
352
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
353
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
354
|
+
req.headers = {
|
|
355
|
+
**(req.headers || {}),
|
|
356
|
+
**@request_client.get_headers,
|
|
357
|
+
**(request_options&.additional_headers || {})
|
|
358
|
+
}.compact
|
|
359
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
360
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
361
|
+
end
|
|
362
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
363
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
364
|
+
end
|
|
365
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/points/#{key}/levels"
|
|
366
|
+
end
|
|
367
|
+
parsed_json = JSON.parse(response.body)
|
|
368
|
+
parsed_json&.map do |item|
|
|
369
|
+
item = item.to_json
|
|
370
|
+
TrophyApiClient::PointsLevel.from_json(json_object: item)
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
# Get a breakdown of the number of users at each level in a points system.
|
|
376
|
+
#
|
|
377
|
+
# @param key [String] Key of the points system.
|
|
378
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
379
|
+
# @return [TrophyApiClient::POINTS_LEVEL_SUMMARY_RESPONSE]
|
|
380
|
+
# @example
|
|
381
|
+
# api = TrophyApiClient::Client.new(
|
|
382
|
+
# base_url: "https://api.example.com",
|
|
383
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
384
|
+
# api_key: "YOUR_API_KEY"
|
|
385
|
+
# )
|
|
386
|
+
# api.points.level_summary(key: "points-system-key")
|
|
387
|
+
def level_summary(key:, request_options: nil)
|
|
388
|
+
Async do
|
|
389
|
+
response = @request_client.conn.get do |req|
|
|
390
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
391
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
392
|
+
req.headers = {
|
|
393
|
+
**(req.headers || {}),
|
|
394
|
+
**@request_client.get_headers,
|
|
395
|
+
**(request_options&.additional_headers || {})
|
|
396
|
+
}.compact
|
|
397
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
398
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
399
|
+
end
|
|
400
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
401
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
402
|
+
end
|
|
403
|
+
req.url "#{@request_client.get_url(environment: api,
|
|
404
|
+
request_options: request_options)}/points/#{key}/level-summary"
|
|
405
|
+
end
|
|
406
|
+
parsed_json = JSON.parse(response.body)
|
|
407
|
+
parsed_json&.map do |item|
|
|
408
|
+
item = item.to_json
|
|
409
|
+
TrophyApiClient::PointsLevelSummaryResponseItem.from_json(json_object: item)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
end
|
|
261
413
|
end
|
|
262
414
|
end
|
|
@@ -24,6 +24,9 @@ module TrophyApiClient
|
|
|
24
24
|
# @return [Integer] The length of the streak required to complete the achievement (only applicable
|
|
25
25
|
# if trigger = 'streak')
|
|
26
26
|
attr_reader :streak_length
|
|
27
|
+
# @return [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
28
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
29
|
+
attr_reader :achievement_ids
|
|
27
30
|
# @return [String] The ID of the metric associated with this achievement (only applicable if
|
|
28
31
|
# trigger = 'metric')
|
|
29
32
|
attr_reader :metric_id
|
|
@@ -56,6 +59,8 @@ module TrophyApiClient
|
|
|
56
59
|
# trigger = 'api')
|
|
57
60
|
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
|
58
61
|
# if trigger = 'streak')
|
|
62
|
+
# @param achievement_ids [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
63
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
59
64
|
# @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
|
|
60
65
|
# trigger = 'metric')
|
|
61
66
|
# @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
|
|
@@ -69,7 +74,7 @@ module TrophyApiClient
|
|
|
69
74
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
70
75
|
# @return [TrophyApiClient::AchievementResponse]
|
|
71
76
|
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
|
|
72
|
-
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
77
|
+
achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
73
78
|
@id = id
|
|
74
79
|
@name = name
|
|
75
80
|
@trigger = trigger
|
|
@@ -77,6 +82,7 @@ module TrophyApiClient
|
|
|
77
82
|
@badge_url = badge_url if badge_url != OMIT
|
|
78
83
|
@key = key if key != OMIT
|
|
79
84
|
@streak_length = streak_length if streak_length != OMIT
|
|
85
|
+
@achievement_ids = achievement_ids if achievement_ids != OMIT
|
|
80
86
|
@metric_id = metric_id if metric_id != OMIT
|
|
81
87
|
@metric_value = metric_value if metric_value != OMIT
|
|
82
88
|
@metric_name = metric_name if metric_name != OMIT
|
|
@@ -91,6 +97,7 @@ module TrophyApiClient
|
|
|
91
97
|
"badgeUrl": badge_url,
|
|
92
98
|
"key": key,
|
|
93
99
|
"streakLength": streak_length,
|
|
100
|
+
"achievementIds": achievement_ids,
|
|
94
101
|
"metricId": metric_id,
|
|
95
102
|
"metricValue": metric_value,
|
|
96
103
|
"metricName": metric_name,
|
|
@@ -115,6 +122,7 @@ module TrophyApiClient
|
|
|
115
122
|
badge_url = parsed_json["badgeUrl"]
|
|
116
123
|
key = parsed_json["key"]
|
|
117
124
|
streak_length = parsed_json["streakLength"]
|
|
125
|
+
achievement_ids = parsed_json["achievementIds"]
|
|
118
126
|
metric_id = parsed_json["metricId"]
|
|
119
127
|
metric_value = parsed_json["metricValue"]
|
|
120
128
|
metric_name = parsed_json["metricName"]
|
|
@@ -136,6 +144,7 @@ module TrophyApiClient
|
|
|
136
144
|
badge_url: badge_url,
|
|
137
145
|
key: key,
|
|
138
146
|
streak_length: streak_length,
|
|
147
|
+
achievement_ids: achievement_ids,
|
|
139
148
|
metric_id: metric_id,
|
|
140
149
|
metric_value: metric_value,
|
|
141
150
|
metric_name: metric_name,
|
|
@@ -166,6 +175,7 @@ module TrophyApiClient
|
|
|
166
175
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
167
176
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
168
177
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
|
178
|
+
obj.achievement_ids&.is_a?(Array) != false || raise("Passed value for field obj.achievement_ids is not the expected type, validation failed.")
|
|
169
179
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
170
180
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
171
181
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
@@ -28,6 +28,9 @@ module TrophyApiClient
|
|
|
28
28
|
# @return [Integer] The length of the streak required to complete the achievement (only applicable
|
|
29
29
|
# if trigger = 'streak')
|
|
30
30
|
attr_reader :streak_length
|
|
31
|
+
# @return [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
32
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
33
|
+
attr_reader :achievement_ids
|
|
31
34
|
# @return [String] The ID of the metric associated with this achievement (only applicable if
|
|
32
35
|
# trigger = 'metric')
|
|
33
36
|
attr_reader :metric_id
|
|
@@ -62,6 +65,8 @@ module TrophyApiClient
|
|
|
62
65
|
# trigger = 'api')
|
|
63
66
|
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
|
64
67
|
# if trigger = 'streak')
|
|
68
|
+
# @param achievement_ids [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
69
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
65
70
|
# @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
|
|
66
71
|
# trigger = 'metric')
|
|
67
72
|
# @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
|
|
@@ -75,7 +80,7 @@ module TrophyApiClient
|
|
|
75
80
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
76
81
|
# @return [TrophyApiClient::AchievementWithStatsResponse]
|
|
77
82
|
def initialize(completions:, rarity:, id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT,
|
|
78
|
-
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
83
|
+
streak_length: OMIT, achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
79
84
|
@completions = completions
|
|
80
85
|
@rarity = rarity
|
|
81
86
|
@id = id
|
|
@@ -85,6 +90,7 @@ module TrophyApiClient
|
|
|
85
90
|
@badge_url = badge_url if badge_url != OMIT
|
|
86
91
|
@key = key if key != OMIT
|
|
87
92
|
@streak_length = streak_length if streak_length != OMIT
|
|
93
|
+
@achievement_ids = achievement_ids if achievement_ids != OMIT
|
|
88
94
|
@metric_id = metric_id if metric_id != OMIT
|
|
89
95
|
@metric_value = metric_value if metric_value != OMIT
|
|
90
96
|
@metric_name = metric_name if metric_name != OMIT
|
|
@@ -101,6 +107,7 @@ module TrophyApiClient
|
|
|
101
107
|
"badgeUrl": badge_url,
|
|
102
108
|
"key": key,
|
|
103
109
|
"streakLength": streak_length,
|
|
110
|
+
"achievementIds": achievement_ids,
|
|
104
111
|
"metricId": metric_id,
|
|
105
112
|
"metricValue": metric_value,
|
|
106
113
|
"metricName": metric_name,
|
|
@@ -127,6 +134,7 @@ module TrophyApiClient
|
|
|
127
134
|
badge_url = parsed_json["badgeUrl"]
|
|
128
135
|
key = parsed_json["key"]
|
|
129
136
|
streak_length = parsed_json["streakLength"]
|
|
137
|
+
achievement_ids = parsed_json["achievementIds"]
|
|
130
138
|
metric_id = parsed_json["metricId"]
|
|
131
139
|
metric_value = parsed_json["metricValue"]
|
|
132
140
|
metric_name = parsed_json["metricName"]
|
|
@@ -150,6 +158,7 @@ module TrophyApiClient
|
|
|
150
158
|
badge_url: badge_url,
|
|
151
159
|
key: key,
|
|
152
160
|
streak_length: streak_length,
|
|
161
|
+
achievement_ids: achievement_ids,
|
|
153
162
|
metric_id: metric_id,
|
|
154
163
|
metric_value: metric_value,
|
|
155
164
|
metric_name: metric_name,
|
|
@@ -182,6 +191,7 @@ module TrophyApiClient
|
|
|
182
191
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
183
192
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
184
193
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
|
194
|
+
obj.achievement_ids&.is_a?(Array) != false || raise("Passed value for field obj.achievement_ids is not the expected type, validation failed.")
|
|
185
195
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
186
196
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
187
197
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "points_level"
|
|
3
4
|
require_relative "points_award"
|
|
4
5
|
require "ostruct"
|
|
5
6
|
require "json"
|
|
6
7
|
|
|
7
8
|
module TrophyApiClient
|
|
8
9
|
class GetUserPointsResponse
|
|
10
|
+
# @return [Integer] The user's total points
|
|
11
|
+
attr_reader :total
|
|
12
|
+
# @return [TrophyApiClient::PointsLevel] The user's current level in this points system, or null if no levels are
|
|
13
|
+
# configured or the user hasn't reached any level yet.
|
|
14
|
+
attr_reader :level
|
|
15
|
+
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
16
|
+
attr_reader :awards
|
|
9
17
|
# @return [String] The ID of the points system
|
|
10
18
|
attr_reader :id
|
|
11
19
|
# @return [String] The key of the points system
|
|
@@ -18,10 +26,6 @@ module TrophyApiClient
|
|
|
18
26
|
attr_reader :badge_url
|
|
19
27
|
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
20
28
|
attr_reader :max_points
|
|
21
|
-
# @return [Integer] The user's total points
|
|
22
|
-
attr_reader :total
|
|
23
|
-
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
24
|
-
attr_reader :awards
|
|
25
29
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
30
|
attr_reader :additional_properties
|
|
27
31
|
# @return [Object]
|
|
@@ -30,36 +34,40 @@ module TrophyApiClient
|
|
|
30
34
|
|
|
31
35
|
OMIT = Object.new
|
|
32
36
|
|
|
37
|
+
# @param total [Integer] The user's total points
|
|
38
|
+
# @param level [TrophyApiClient::PointsLevel] The user's current level in this points system, or null if no levels are
|
|
39
|
+
# configured or the user hasn't reached any level yet.
|
|
40
|
+
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
33
41
|
# @param id [String] The ID of the points system
|
|
34
42
|
# @param key [String] The key of the points system
|
|
35
43
|
# @param name [String] The name of the points system
|
|
36
44
|
# @param description [String] The description of the points system
|
|
37
45
|
# @param badge_url [String] The URL of the badge image for the points system
|
|
38
46
|
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
39
|
-
# @param total [Integer] The user's total points
|
|
40
|
-
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
41
47
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
42
48
|
# @return [TrophyApiClient::GetUserPointsResponse]
|
|
43
|
-
def initialize(
|
|
44
|
-
additional_properties: nil)
|
|
49
|
+
def initialize(total:, awards:, id:, key:, name:, level: OMIT, description: OMIT, badge_url: OMIT,
|
|
50
|
+
max_points: OMIT, additional_properties: nil)
|
|
51
|
+
@total = total
|
|
52
|
+
@level = level if level != OMIT
|
|
53
|
+
@awards = awards
|
|
45
54
|
@id = id
|
|
46
55
|
@key = key
|
|
47
56
|
@name = name
|
|
48
57
|
@description = description if description != OMIT
|
|
49
58
|
@badge_url = badge_url if badge_url != OMIT
|
|
50
59
|
@max_points = max_points if max_points != OMIT
|
|
51
|
-
@total = total
|
|
52
|
-
@awards = awards
|
|
53
60
|
@additional_properties = additional_properties
|
|
54
61
|
@_field_set = {
|
|
62
|
+
"total": total,
|
|
63
|
+
"level": level,
|
|
64
|
+
"awards": awards,
|
|
55
65
|
"id": id,
|
|
56
66
|
"key": key,
|
|
57
67
|
"name": name,
|
|
58
68
|
"description": description,
|
|
59
69
|
"badgeUrl": badge_url,
|
|
60
|
-
"maxPoints": max_points
|
|
61
|
-
"total": total,
|
|
62
|
-
"awards": awards
|
|
70
|
+
"maxPoints": max_points
|
|
63
71
|
}.reject do |_k, v|
|
|
64
72
|
v == OMIT
|
|
65
73
|
end
|
|
@@ -72,26 +80,33 @@ module TrophyApiClient
|
|
|
72
80
|
def self.from_json(json_object:)
|
|
73
81
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
74
82
|
parsed_json = JSON.parse(json_object)
|
|
83
|
+
total = parsed_json["total"]
|
|
84
|
+
if parsed_json["level"].nil?
|
|
85
|
+
level = nil
|
|
86
|
+
else
|
|
87
|
+
level = parsed_json["level"].to_json
|
|
88
|
+
level = TrophyApiClient::PointsLevel.from_json(json_object: level)
|
|
89
|
+
end
|
|
90
|
+
awards = parsed_json["awards"]&.map do |item|
|
|
91
|
+
item = item.to_json
|
|
92
|
+
TrophyApiClient::PointsAward.from_json(json_object: item)
|
|
93
|
+
end
|
|
75
94
|
id = parsed_json["id"]
|
|
76
95
|
key = parsed_json["key"]
|
|
77
96
|
name = parsed_json["name"]
|
|
78
97
|
description = parsed_json["description"]
|
|
79
98
|
badge_url = parsed_json["badgeUrl"]
|
|
80
99
|
max_points = parsed_json["maxPoints"]
|
|
81
|
-
total = parsed_json["total"]
|
|
82
|
-
awards = parsed_json["awards"]&.map do |item|
|
|
83
|
-
item = item.to_json
|
|
84
|
-
TrophyApiClient::PointsAward.from_json(json_object: item)
|
|
85
|
-
end
|
|
86
100
|
new(
|
|
101
|
+
total: total,
|
|
102
|
+
level: level,
|
|
103
|
+
awards: awards,
|
|
87
104
|
id: id,
|
|
88
105
|
key: key,
|
|
89
106
|
name: name,
|
|
90
107
|
description: description,
|
|
91
108
|
badge_url: badge_url,
|
|
92
109
|
max_points: max_points,
|
|
93
|
-
total: total,
|
|
94
|
-
awards: awards,
|
|
95
110
|
additional_properties: struct
|
|
96
111
|
)
|
|
97
112
|
end
|
|
@@ -110,14 +125,15 @@ module TrophyApiClient
|
|
|
110
125
|
# @param obj [Object]
|
|
111
126
|
# @return [Void]
|
|
112
127
|
def self.validate_raw(obj:)
|
|
128
|
+
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
129
|
+
obj.level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
|
|
130
|
+
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
113
131
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
114
132
|
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
115
133
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
116
134
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
117
135
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
118
136
|
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
119
|
-
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
120
|
-
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
121
137
|
end
|
|
122
138
|
end
|
|
123
139
|
end
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "points_level"
|
|
3
4
|
require_relative "points_award"
|
|
4
5
|
require "ostruct"
|
|
5
6
|
require "json"
|
|
6
7
|
|
|
7
8
|
module TrophyApiClient
|
|
8
|
-
# Points system response for metric events.
|
|
9
|
+
# Points system response for metric events and achievement completions.
|
|
9
10
|
class MetricEventPointsResponse
|
|
11
|
+
# @return [Integer] The user's total points
|
|
12
|
+
attr_reader :total
|
|
13
|
+
# @return [TrophyApiClient::PointsLevel] The user's new level, included only when the level changed as a result of this
|
|
14
|
+
# event.
|
|
15
|
+
attr_reader :level
|
|
16
|
+
# @return [Integer] The points added by this event.
|
|
17
|
+
attr_reader :added
|
|
18
|
+
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
19
|
+
attr_reader :awards
|
|
10
20
|
# @return [String] The ID of the points system
|
|
11
21
|
attr_reader :id
|
|
12
22
|
# @return [String] The key of the points system
|
|
@@ -19,12 +29,6 @@ module TrophyApiClient
|
|
|
19
29
|
attr_reader :badge_url
|
|
20
30
|
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
21
31
|
attr_reader :max_points
|
|
22
|
-
# @return [Integer] The user's total points
|
|
23
|
-
attr_reader :total
|
|
24
|
-
# @return [Integer] The points added by this event.
|
|
25
|
-
attr_reader :added
|
|
26
|
-
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
27
|
-
attr_reader :awards
|
|
28
32
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
29
33
|
attr_reader :additional_properties
|
|
30
34
|
# @return [Object]
|
|
@@ -33,39 +37,43 @@ module TrophyApiClient
|
|
|
33
37
|
|
|
34
38
|
OMIT = Object.new
|
|
35
39
|
|
|
40
|
+
# @param total [Integer] The user's total points
|
|
41
|
+
# @param level [TrophyApiClient::PointsLevel] The user's new level, included only when the level changed as a result of this
|
|
42
|
+
# event.
|
|
43
|
+
# @param added [Integer] The points added by this event.
|
|
44
|
+
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
36
45
|
# @param id [String] The ID of the points system
|
|
37
46
|
# @param key [String] The key of the points system
|
|
38
47
|
# @param name [String] The name of the points system
|
|
39
48
|
# @param description [String] The description of the points system
|
|
40
49
|
# @param badge_url [String] The URL of the badge image for the points system
|
|
41
50
|
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
42
|
-
# @param total [Integer] The user's total points
|
|
43
|
-
# @param added [Integer] The points added by this event.
|
|
44
|
-
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
45
51
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
46
52
|
# @return [TrophyApiClient::MetricEventPointsResponse]
|
|
47
|
-
def initialize(
|
|
48
|
-
additional_properties: nil)
|
|
53
|
+
def initialize(total:, added:, awards:, id:, key:, name:, level: OMIT, description: OMIT, badge_url: OMIT,
|
|
54
|
+
max_points: OMIT, additional_properties: nil)
|
|
55
|
+
@total = total
|
|
56
|
+
@level = level if level != OMIT
|
|
57
|
+
@added = added
|
|
58
|
+
@awards = awards
|
|
49
59
|
@id = id
|
|
50
60
|
@key = key
|
|
51
61
|
@name = name
|
|
52
62
|
@description = description if description != OMIT
|
|
53
63
|
@badge_url = badge_url if badge_url != OMIT
|
|
54
64
|
@max_points = max_points if max_points != OMIT
|
|
55
|
-
@total = total
|
|
56
|
-
@added = added
|
|
57
|
-
@awards = awards
|
|
58
65
|
@additional_properties = additional_properties
|
|
59
66
|
@_field_set = {
|
|
67
|
+
"total": total,
|
|
68
|
+
"level": level,
|
|
69
|
+
"added": added,
|
|
70
|
+
"awards": awards,
|
|
60
71
|
"id": id,
|
|
61
72
|
"key": key,
|
|
62
73
|
"name": name,
|
|
63
74
|
"description": description,
|
|
64
75
|
"badgeUrl": badge_url,
|
|
65
|
-
"maxPoints": max_points
|
|
66
|
-
"total": total,
|
|
67
|
-
"added": added,
|
|
68
|
-
"awards": awards
|
|
76
|
+
"maxPoints": max_points
|
|
69
77
|
}.reject do |_k, v|
|
|
70
78
|
v == OMIT
|
|
71
79
|
end
|
|
@@ -78,28 +86,35 @@ module TrophyApiClient
|
|
|
78
86
|
def self.from_json(json_object:)
|
|
79
87
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
80
88
|
parsed_json = JSON.parse(json_object)
|
|
81
|
-
id = parsed_json["id"]
|
|
82
|
-
key = parsed_json["key"]
|
|
83
|
-
name = parsed_json["name"]
|
|
84
|
-
description = parsed_json["description"]
|
|
85
|
-
badge_url = parsed_json["badgeUrl"]
|
|
86
|
-
max_points = parsed_json["maxPoints"]
|
|
87
89
|
total = parsed_json["total"]
|
|
90
|
+
if parsed_json["level"].nil?
|
|
91
|
+
level = nil
|
|
92
|
+
else
|
|
93
|
+
level = parsed_json["level"].to_json
|
|
94
|
+
level = TrophyApiClient::PointsLevel.from_json(json_object: level)
|
|
95
|
+
end
|
|
88
96
|
added = parsed_json["added"]
|
|
89
97
|
awards = parsed_json["awards"]&.map do |item|
|
|
90
98
|
item = item.to_json
|
|
91
99
|
TrophyApiClient::PointsAward.from_json(json_object: item)
|
|
92
100
|
end
|
|
101
|
+
id = parsed_json["id"]
|
|
102
|
+
key = parsed_json["key"]
|
|
103
|
+
name = parsed_json["name"]
|
|
104
|
+
description = parsed_json["description"]
|
|
105
|
+
badge_url = parsed_json["badgeUrl"]
|
|
106
|
+
max_points = parsed_json["maxPoints"]
|
|
93
107
|
new(
|
|
108
|
+
total: total,
|
|
109
|
+
level: level,
|
|
110
|
+
added: added,
|
|
111
|
+
awards: awards,
|
|
94
112
|
id: id,
|
|
95
113
|
key: key,
|
|
96
114
|
name: name,
|
|
97
115
|
description: description,
|
|
98
116
|
badge_url: badge_url,
|
|
99
117
|
max_points: max_points,
|
|
100
|
-
total: total,
|
|
101
|
-
added: added,
|
|
102
|
-
awards: awards,
|
|
103
118
|
additional_properties: struct
|
|
104
119
|
)
|
|
105
120
|
end
|
|
@@ -118,15 +133,16 @@ module TrophyApiClient
|
|
|
118
133
|
# @param obj [Object]
|
|
119
134
|
# @return [Void]
|
|
120
135
|
def self.validate_raw(obj:)
|
|
136
|
+
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
137
|
+
obj.level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
|
|
138
|
+
obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
|
|
139
|
+
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
121
140
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
122
141
|
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
123
142
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
124
143
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
125
144
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
126
145
|
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
127
|
-
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
128
|
-
obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
|
|
129
|
-
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
130
146
|
end
|
|
131
147
|
end
|
|
132
148
|
end
|