trophy_api_client 1.1.2 → 1.3.4
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/leaderboards/types/leaderboards_all_response_item.rb +12 -4
- data/lib/trophy_api_client/points/client.rb +152 -0
- data/lib/trophy_api_client/types/achievement_response.rb +23 -11
- data/lib/trophy_api_client/types/achievement_response_event_attribute.rb +2 -2
- data/lib/trophy_api_client/types/achievement_response_event_attributes_item.rb +66 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +23 -11
- data/lib/trophy_api_client/types/get_user_points_response.rb +38 -22
- data/lib/trophy_api_client/types/leaderboard_response.rb +12 -4
- data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +12 -4
- data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +30 -8
- data/lib/trophy_api_client/types/metric_event_leaderboard_response_breakdown_attribute_values_item.rb +67 -0
- 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/points_system_response.rb +4 -4
- data/lib/trophy_api_client/types/points_trigger.rb +101 -9
- data/lib/trophy_api_client/types/{points_trigger_response_event_attribute.rb → points_trigger_event_attribute.rb} +7 -7
- data/lib/trophy_api_client/types/points_trigger_event_attributes_item.rb +65 -0
- data/lib/trophy_api_client/types/{points_trigger_response_status.rb → points_trigger_status.rb} +2 -1
- data/lib/trophy_api_client/types/{points_trigger_response_user_attributes_item.rb → points_trigger_user_attributes_item.rb} +7 -9
- data/lib/trophy_api_client/types/streak_response.rb +4 -2
- data/lib/trophy_api_client/types/user_achievement_response.rb +23 -11
- data/lib/trophy_api_client/types/user_achievement_with_stats_response.rb +23 -11
- data/lib/trophy_api_client/types/user_leaderboard_response.rb +12 -4
- data/lib/trophy_api_client/types/user_leaderboard_response_with_history.rb +12 -4
- data/lib/trophy_api_client/types/webhook_user_leaderboard_response.rb +11 -3
- 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 +12 -6
- metadata +14 -8
- data/lib/trophy_api_client/types/points_trigger_response.rb +0 -211
- data/lib/trophy_api_client/types/points_trigger_response_time_unit.rb +0 -9
- data/lib/trophy_api_client/types/points_trigger_response_type.rb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cb9d52fcaab5cf68909f48fb282a528d76efa4d788b57fe4ca290590a27126e
|
|
4
|
+
data.tar.gz: 07be917c807d0d55ff077b67e758f1265c5bf2e34e98af77fc7835ef14b525d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d012a7bb3f7adf0a59a1e538a5e5baa3861b6ab771a88d0b54cbc30d837aa5cee38d21df5e8aa3b7dd70bb10b30cd05e1966d9cf90b48faef932ceb5b97ed5fb
|
|
7
|
+
data.tar.gz: a224b34e74c972fddbfad0ba495c1ca61327146d523120203e9c1401da8dc8a096ae4fcb40a21a76a717c0b58e23713a84f9b3f3a7346d1a03b083794c1511f7
|
data/lib/gemconfig.rb
CHANGED
|
@@ -19,8 +19,10 @@ module TrophyApiClient
|
|
|
19
19
|
attr_reader :key
|
|
20
20
|
# @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
|
21
21
|
attr_reader :rank_by
|
|
22
|
-
# @return [String] The key of the attribute to break down this leaderboard by.
|
|
22
|
+
# @return [String] Deprecated. The key of the attribute to break down this leaderboard by.
|
|
23
23
|
attr_reader :breakdown_attribute
|
|
24
|
+
# @return [Array<String>] The user attribute keys that this leaderboard is broken down by.
|
|
25
|
+
attr_reader :breakdown_attributes
|
|
24
26
|
# @return [String] The key of the metric to rank by, if rankBy is 'metric'.
|
|
25
27
|
attr_reader :metric_key
|
|
26
28
|
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
|
|
@@ -57,7 +59,8 @@ module TrophyApiClient
|
|
|
57
59
|
# @param name [String] The user-facing name of the leaderboard.
|
|
58
60
|
# @param key [String] The unique key used to reference the leaderboard in APIs.
|
|
59
61
|
# @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
|
60
|
-
# @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
|
|
62
|
+
# @param breakdown_attribute [String] Deprecated. The key of the attribute to break down this leaderboard by.
|
|
63
|
+
# @param breakdown_attributes [Array<String>] The user attribute keys that this leaderboard is broken down by.
|
|
61
64
|
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
|
|
62
65
|
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
|
|
63
66
|
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
|
|
@@ -73,14 +76,15 @@ module TrophyApiClient
|
|
|
73
76
|
# type. Null for one-time leaderboards.
|
|
74
77
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
75
78
|
# @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem]
|
|
76
|
-
def initialize(status:, id:, name:, key:, rank_by:, start:, max_participants:, breakdown_attribute: OMIT,
|
|
77
|
-
metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
|
|
79
|
+
def initialize(status:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, breakdown_attribute: OMIT,
|
|
80
|
+
metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
|
|
78
81
|
@status = status
|
|
79
82
|
@id = id
|
|
80
83
|
@name = name
|
|
81
84
|
@key = key
|
|
82
85
|
@rank_by = rank_by
|
|
83
86
|
@breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
|
|
87
|
+
@breakdown_attributes = breakdown_attributes
|
|
84
88
|
@metric_key = metric_key if metric_key != OMIT
|
|
85
89
|
@metric_name = metric_name if metric_name != OMIT
|
|
86
90
|
@points_system_key = points_system_key if points_system_key != OMIT
|
|
@@ -99,6 +103,7 @@ module TrophyApiClient
|
|
|
99
103
|
"key": key,
|
|
100
104
|
"rankBy": rank_by,
|
|
101
105
|
"breakdownAttribute": breakdown_attribute,
|
|
106
|
+
"breakdownAttributes": breakdown_attributes,
|
|
102
107
|
"metricKey": metric_key,
|
|
103
108
|
"metricName": metric_name,
|
|
104
109
|
"pointsSystemKey": points_system_key,
|
|
@@ -127,6 +132,7 @@ module TrophyApiClient
|
|
|
127
132
|
key = parsed_json["key"]
|
|
128
133
|
rank_by = parsed_json["rankBy"]
|
|
129
134
|
breakdown_attribute = parsed_json["breakdownAttribute"]
|
|
135
|
+
breakdown_attributes = parsed_json["breakdownAttributes"]
|
|
130
136
|
metric_key = parsed_json["metricKey"]
|
|
131
137
|
metric_name = parsed_json["metricName"]
|
|
132
138
|
points_system_key = parsed_json["pointsSystemKey"]
|
|
@@ -144,6 +150,7 @@ module TrophyApiClient
|
|
|
144
150
|
key: key,
|
|
145
151
|
rank_by: rank_by,
|
|
146
152
|
breakdown_attribute: breakdown_attribute,
|
|
153
|
+
breakdown_attributes: breakdown_attributes,
|
|
147
154
|
metric_key: metric_key,
|
|
148
155
|
metric_name: metric_name,
|
|
149
156
|
points_system_key: points_system_key,
|
|
@@ -178,6 +185,7 @@ module TrophyApiClient
|
|
|
178
185
|
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
179
186
|
obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
|
|
180
187
|
obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
|
|
188
|
+
obj.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
|
|
181
189
|
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
|
|
182
190
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
183
191
|
obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
|
|
@@ -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
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative "achievement_response_trigger"
|
|
4
4
|
require_relative "achievement_response_user_attributes_item"
|
|
5
5
|
require_relative "achievement_response_event_attribute"
|
|
6
|
+
require_relative "achievement_response_event_attributes_item"
|
|
6
7
|
require "ostruct"
|
|
7
8
|
require "json"
|
|
8
9
|
|
|
@@ -37,11 +38,13 @@ module TrophyApiClient
|
|
|
37
38
|
# trigger = 'metric')
|
|
38
39
|
attr_reader :metric_name
|
|
39
40
|
# @return [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
40
|
-
# Only present if the achievement has user attribute filters configured.
|
|
41
41
|
attr_reader :user_attributes
|
|
42
|
-
# @return [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be
|
|
43
|
-
# Only present if the achievement has an event filter configured.
|
|
42
|
+
# @return [TrophyApiClient::AchievementResponseEventAttribute] Deprecated. Event attribute filter that must be met for this achievement to be
|
|
43
|
+
# completed. Only present if the achievement has an event filter configured.
|
|
44
44
|
attr_reader :event_attribute
|
|
45
|
+
# @return [Array<TrophyApiClient::AchievementResponseEventAttributesItem>] Event attribute filters that must be met for this achievement to be completed.
|
|
46
|
+
# Omitted for non-metric achievements.
|
|
47
|
+
attr_reader :event_attributes
|
|
45
48
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
46
49
|
attr_reader :additional_properties
|
|
47
50
|
# @return [Object]
|
|
@@ -68,13 +71,14 @@ module TrophyApiClient
|
|
|
68
71
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
|
69
72
|
# trigger = 'metric')
|
|
70
73
|
# @param user_attributes [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
+
# @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Deprecated. Event attribute filter that must be met for this achievement to be
|
|
75
|
+
# completed. Only present if the achievement has an event filter configured.
|
|
76
|
+
# @param event_attributes [Array<TrophyApiClient::AchievementResponseEventAttributesItem>] Event attribute filters that must be met for this achievement to be completed.
|
|
77
|
+
# Omitted for non-metric achievements.
|
|
74
78
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
75
79
|
# @return [TrophyApiClient::AchievementResponse]
|
|
76
|
-
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
|
|
77
|
-
achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT,
|
|
80
|
+
def initialize(id:, name:, trigger:, user_attributes:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
|
|
81
|
+
achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, event_attribute: OMIT, event_attributes: OMIT, additional_properties: nil)
|
|
78
82
|
@id = id
|
|
79
83
|
@name = name
|
|
80
84
|
@trigger = trigger
|
|
@@ -86,8 +90,9 @@ module TrophyApiClient
|
|
|
86
90
|
@metric_id = metric_id if metric_id != OMIT
|
|
87
91
|
@metric_value = metric_value if metric_value != OMIT
|
|
88
92
|
@metric_name = metric_name if metric_name != OMIT
|
|
89
|
-
@user_attributes = user_attributes
|
|
93
|
+
@user_attributes = user_attributes
|
|
90
94
|
@event_attribute = event_attribute if event_attribute != OMIT
|
|
95
|
+
@event_attributes = event_attributes if event_attributes != OMIT
|
|
91
96
|
@additional_properties = additional_properties
|
|
92
97
|
@_field_set = {
|
|
93
98
|
"id": id,
|
|
@@ -102,7 +107,8 @@ module TrophyApiClient
|
|
|
102
107
|
"metricValue": metric_value,
|
|
103
108
|
"metricName": metric_name,
|
|
104
109
|
"userAttributes": user_attributes,
|
|
105
|
-
"eventAttribute": event_attribute
|
|
110
|
+
"eventAttribute": event_attribute,
|
|
111
|
+
"eventAttributes": event_attributes
|
|
106
112
|
}.reject do |_k, v|
|
|
107
113
|
v == OMIT
|
|
108
114
|
end
|
|
@@ -136,6 +142,10 @@ module TrophyApiClient
|
|
|
136
142
|
event_attribute = parsed_json["eventAttribute"].to_json
|
|
137
143
|
event_attribute = TrophyApiClient::AchievementResponseEventAttribute.from_json(json_object: event_attribute)
|
|
138
144
|
end
|
|
145
|
+
event_attributes = parsed_json["eventAttributes"]&.map do |item|
|
|
146
|
+
item = item.to_json
|
|
147
|
+
TrophyApiClient::AchievementResponseEventAttributesItem.from_json(json_object: item)
|
|
148
|
+
end
|
|
139
149
|
new(
|
|
140
150
|
id: id,
|
|
141
151
|
name: name,
|
|
@@ -150,6 +160,7 @@ module TrophyApiClient
|
|
|
150
160
|
metric_name: metric_name,
|
|
151
161
|
user_attributes: user_attributes,
|
|
152
162
|
event_attribute: event_attribute,
|
|
163
|
+
event_attributes: event_attributes,
|
|
153
164
|
additional_properties: struct
|
|
154
165
|
)
|
|
155
166
|
end
|
|
@@ -179,8 +190,9 @@ module TrophyApiClient
|
|
|
179
190
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
180
191
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
181
192
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
182
|
-
obj.user_attributes
|
|
193
|
+
obj.user_attributes.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
183
194
|
obj.event_attribute.nil? || TrophyApiClient::AchievementResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
195
|
+
obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes is not the expected type, validation failed.")
|
|
184
196
|
end
|
|
185
197
|
end
|
|
186
198
|
end
|
|
@@ -4,8 +4,8 @@ require "ostruct"
|
|
|
4
4
|
require "json"
|
|
5
5
|
|
|
6
6
|
module TrophyApiClient
|
|
7
|
-
# Event attribute filter that must be met for this achievement to be
|
|
8
|
-
# Only present if the achievement has an event filter configured.
|
|
7
|
+
# Deprecated. Event attribute filter that must be met for this achievement to be
|
|
8
|
+
# completed. Only present if the achievement has an event filter configured.
|
|
9
9
|
class AchievementResponseEventAttribute
|
|
10
10
|
# @return [String] The key of the event attribute.
|
|
11
11
|
attr_reader :key
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
class AchievementResponseEventAttributesItem
|
|
8
|
+
# @return [String] The key of the event attribute.
|
|
9
|
+
attr_reader :key
|
|
10
|
+
# @return [String] The value of the event attribute.
|
|
11
|
+
attr_reader :value
|
|
12
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
13
|
+
attr_reader :additional_properties
|
|
14
|
+
# @return [Object]
|
|
15
|
+
attr_reader :_field_set
|
|
16
|
+
protected :_field_set
|
|
17
|
+
|
|
18
|
+
OMIT = Object.new
|
|
19
|
+
|
|
20
|
+
# @param key [String] The key of the event attribute.
|
|
21
|
+
# @param value [String] The value of the event attribute.
|
|
22
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
23
|
+
# @return [TrophyApiClient::AchievementResponseEventAttributesItem]
|
|
24
|
+
def initialize(key:, value:, additional_properties: nil)
|
|
25
|
+
@key = key
|
|
26
|
+
@value = value
|
|
27
|
+
@additional_properties = additional_properties
|
|
28
|
+
@_field_set = { "key": key, "value": value }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Deserialize a JSON object to an instance of
|
|
32
|
+
# AchievementResponseEventAttributesItem
|
|
33
|
+
#
|
|
34
|
+
# @param json_object [String]
|
|
35
|
+
# @return [TrophyApiClient::AchievementResponseEventAttributesItem]
|
|
36
|
+
def self.from_json(json_object:)
|
|
37
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
38
|
+
parsed_json = JSON.parse(json_object)
|
|
39
|
+
key = parsed_json["key"]
|
|
40
|
+
value = parsed_json["value"]
|
|
41
|
+
new(
|
|
42
|
+
key: key,
|
|
43
|
+
value: value,
|
|
44
|
+
additional_properties: struct
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Serialize an instance of AchievementResponseEventAttributesItem to a JSON object
|
|
49
|
+
#
|
|
50
|
+
# @return [String]
|
|
51
|
+
def to_json(*_args)
|
|
52
|
+
@_field_set&.to_json
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
56
|
+
# hash and check each fields type against the current object's property
|
|
57
|
+
# definitions.
|
|
58
|
+
#
|
|
59
|
+
# @param obj [Object]
|
|
60
|
+
# @return [Void]
|
|
61
|
+
def self.validate_raw(obj:)
|
|
62
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
63
|
+
obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative "achievement_response_trigger"
|
|
4
4
|
require_relative "achievement_response_user_attributes_item"
|
|
5
5
|
require_relative "achievement_response_event_attribute"
|
|
6
|
+
require_relative "achievement_response_event_attributes_item"
|
|
6
7
|
require "ostruct"
|
|
7
8
|
require "json"
|
|
8
9
|
|
|
@@ -41,11 +42,13 @@ module TrophyApiClient
|
|
|
41
42
|
# trigger = 'metric')
|
|
42
43
|
attr_reader :metric_name
|
|
43
44
|
# @return [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
44
|
-
# Only present if the achievement has user attribute filters configured.
|
|
45
45
|
attr_reader :user_attributes
|
|
46
|
-
# @return [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be
|
|
47
|
-
# Only present if the achievement has an event filter configured.
|
|
46
|
+
# @return [TrophyApiClient::AchievementResponseEventAttribute] Deprecated. Event attribute filter that must be met for this achievement to be
|
|
47
|
+
# completed. Only present if the achievement has an event filter configured.
|
|
48
48
|
attr_reader :event_attribute
|
|
49
|
+
# @return [Array<TrophyApiClient::AchievementResponseEventAttributesItem>] Event attribute filters that must be met for this achievement to be completed.
|
|
50
|
+
# Omitted for non-metric achievements.
|
|
51
|
+
attr_reader :event_attributes
|
|
49
52
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
50
53
|
attr_reader :additional_properties
|
|
51
54
|
# @return [Object]
|
|
@@ -74,13 +77,14 @@ module TrophyApiClient
|
|
|
74
77
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
|
75
78
|
# trigger = 'metric')
|
|
76
79
|
# @param user_attributes [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
77
|
-
#
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
+
# @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Deprecated. Event attribute filter that must be met for this achievement to be
|
|
81
|
+
# completed. Only present if the achievement has an event filter configured.
|
|
82
|
+
# @param event_attributes [Array<TrophyApiClient::AchievementResponseEventAttributesItem>] Event attribute filters that must be met for this achievement to be completed.
|
|
83
|
+
# Omitted for non-metric achievements.
|
|
80
84
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
81
85
|
# @return [TrophyApiClient::AchievementWithStatsResponse]
|
|
82
|
-
def initialize(completions:, rarity:, id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT,
|
|
83
|
-
streak_length: OMIT, achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT,
|
|
86
|
+
def initialize(completions:, rarity:, id:, name:, trigger:, user_attributes:, description: OMIT, badge_url: OMIT, key: OMIT,
|
|
87
|
+
streak_length: OMIT, achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, event_attribute: OMIT, event_attributes: OMIT, additional_properties: nil)
|
|
84
88
|
@completions = completions
|
|
85
89
|
@rarity = rarity
|
|
86
90
|
@id = id
|
|
@@ -94,8 +98,9 @@ module TrophyApiClient
|
|
|
94
98
|
@metric_id = metric_id if metric_id != OMIT
|
|
95
99
|
@metric_value = metric_value if metric_value != OMIT
|
|
96
100
|
@metric_name = metric_name if metric_name != OMIT
|
|
97
|
-
@user_attributes = user_attributes
|
|
101
|
+
@user_attributes = user_attributes
|
|
98
102
|
@event_attribute = event_attribute if event_attribute != OMIT
|
|
103
|
+
@event_attributes = event_attributes if event_attributes != OMIT
|
|
99
104
|
@additional_properties = additional_properties
|
|
100
105
|
@_field_set = {
|
|
101
106
|
"completions": completions,
|
|
@@ -112,7 +117,8 @@ module TrophyApiClient
|
|
|
112
117
|
"metricValue": metric_value,
|
|
113
118
|
"metricName": metric_name,
|
|
114
119
|
"userAttributes": user_attributes,
|
|
115
|
-
"eventAttribute": event_attribute
|
|
120
|
+
"eventAttribute": event_attribute,
|
|
121
|
+
"eventAttributes": event_attributes
|
|
116
122
|
}.reject do |_k, v|
|
|
117
123
|
v == OMIT
|
|
118
124
|
end
|
|
@@ -148,6 +154,10 @@ module TrophyApiClient
|
|
|
148
154
|
event_attribute = parsed_json["eventAttribute"].to_json
|
|
149
155
|
event_attribute = TrophyApiClient::AchievementResponseEventAttribute.from_json(json_object: event_attribute)
|
|
150
156
|
end
|
|
157
|
+
event_attributes = parsed_json["eventAttributes"]&.map do |item|
|
|
158
|
+
item = item.to_json
|
|
159
|
+
TrophyApiClient::AchievementResponseEventAttributesItem.from_json(json_object: item)
|
|
160
|
+
end
|
|
151
161
|
new(
|
|
152
162
|
completions: completions,
|
|
153
163
|
rarity: rarity,
|
|
@@ -164,6 +174,7 @@ module TrophyApiClient
|
|
|
164
174
|
metric_name: metric_name,
|
|
165
175
|
user_attributes: user_attributes,
|
|
166
176
|
event_attribute: event_attribute,
|
|
177
|
+
event_attributes: event_attributes,
|
|
167
178
|
additional_properties: struct
|
|
168
179
|
)
|
|
169
180
|
end
|
|
@@ -195,8 +206,9 @@ module TrophyApiClient
|
|
|
195
206
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
196
207
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
197
208
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
198
|
-
obj.user_attributes
|
|
209
|
+
obj.user_attributes.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
199
210
|
obj.event_attribute.nil? || TrophyApiClient::AchievementResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
211
|
+
obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes is not the expected type, validation failed.")
|
|
200
212
|
end
|
|
201
213
|
end
|
|
202
214
|
end
|