trophy_api_client 1.0.23 → 1.0.25
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/client.rb +197 -0
- data/lib/trophy_api_client/types/event_response.rb +16 -5
- data/lib/trophy_api_client/types/leaderboard_event.rb +101 -0
- data/lib/trophy_api_client/types/leaderboard_ranking.rb +82 -0
- data/lib/trophy_api_client/types/leaderboard_response.rb +184 -0
- data/lib/trophy_api_client/types/leaderboard_response_rank_by.rb +10 -0
- data/lib/trophy_api_client/types/leaderboard_response_status.rb +10 -0
- data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +195 -0
- data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +213 -0
- data/lib/trophy_api_client/types/user_leaderboard_response.rb +216 -0
- data/lib/trophy_api_client/users/client.rb +77 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/trophy_api_client.rb +7 -0
- data/lib/types_export.rb +8 -0
- metadata +10 -1
@@ -0,0 +1,195 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "leaderboard_ranking"
|
4
|
+
require_relative "leaderboard_response_status"
|
5
|
+
require_relative "leaderboard_response_rank_by"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module TrophyApiClient
|
10
|
+
class LeaderboardResponseWithRankings
|
11
|
+
# @return [Array<TrophyApiClient::LeaderboardRanking>] Array of user rankings for the leaderboard.
|
12
|
+
attr_reader :rankings
|
13
|
+
# @return [String] The unique ID of the leaderboard.
|
14
|
+
attr_reader :id
|
15
|
+
# @return [String] The user-facing name of the leaderboard.
|
16
|
+
attr_reader :name
|
17
|
+
# @return [String] The unique key used to reference the leaderboard in APIs.
|
18
|
+
attr_reader :key
|
19
|
+
# @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
|
20
|
+
attr_reader :status
|
21
|
+
# @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
22
|
+
attr_reader :rank_by
|
23
|
+
# @return [String] The key of the metric to rank by, if rankBy is 'metric'.
|
24
|
+
attr_reader :metric_key
|
25
|
+
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
|
26
|
+
attr_reader :metric_name
|
27
|
+
# @return [String] The key of the points system to rank by, if rankBy is 'points'.
|
28
|
+
attr_reader :points_system_key
|
29
|
+
# @return [String] The name of the points system to rank by, if rankBy is 'points'.
|
30
|
+
attr_reader :points_system_name
|
31
|
+
# @return [String] The user-facing description of the leaderboard.
|
32
|
+
attr_reader :description
|
33
|
+
# @return [String] The start date of the leaderboard in YYYY-MM-DD format.
|
34
|
+
attr_reader :start
|
35
|
+
# @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
|
36
|
+
# forever.
|
37
|
+
attr_reader :end_
|
38
|
+
# @return [Integer] The maximum number of participants in the leaderboard.
|
39
|
+
attr_reader :max_participants
|
40
|
+
# @return [String] The repetition type for recurring leaderboards, or null for one-time
|
41
|
+
# leaderboards.
|
42
|
+
attr_reader :run_unit
|
43
|
+
# @return [Integer] The interval between repetitions, relative to the start date and repetition
|
44
|
+
# type.
|
45
|
+
attr_reader :run_interval
|
46
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
47
|
+
attr_reader :additional_properties
|
48
|
+
# @return [Object]
|
49
|
+
attr_reader :_field_set
|
50
|
+
protected :_field_set
|
51
|
+
|
52
|
+
OMIT = Object.new
|
53
|
+
|
54
|
+
# @param rankings [Array<TrophyApiClient::LeaderboardRanking>] Array of user rankings for the leaderboard.
|
55
|
+
# @param id [String] The unique ID of the leaderboard.
|
56
|
+
# @param name [String] The user-facing name of the leaderboard.
|
57
|
+
# @param key [String] The unique key used to reference the leaderboard in APIs.
|
58
|
+
# @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
|
59
|
+
# @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
60
|
+
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
|
61
|
+
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
|
62
|
+
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
|
63
|
+
# @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
|
64
|
+
# @param description [String] The user-facing description of the leaderboard.
|
65
|
+
# @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
|
66
|
+
# @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
|
67
|
+
# forever.
|
68
|
+
# @param max_participants [Integer] The maximum number of participants in the leaderboard.
|
69
|
+
# @param run_unit [String] The repetition type for recurring leaderboards, or null for one-time
|
70
|
+
# leaderboards.
|
71
|
+
# @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
|
72
|
+
# type.
|
73
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
74
|
+
# @return [TrophyApiClient::LeaderboardResponseWithRankings]
|
75
|
+
def initialize(rankings:, id:, name:, key:, rank_by:, start:, max_participants:, run_interval:, status: OMIT, metric_key: OMIT, metric_name: OMIT,
|
76
|
+
points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
|
77
|
+
@rankings = rankings
|
78
|
+
@id = id
|
79
|
+
@name = name
|
80
|
+
@key = key
|
81
|
+
@status = status if status != OMIT
|
82
|
+
@rank_by = rank_by
|
83
|
+
@metric_key = metric_key if metric_key != OMIT
|
84
|
+
@metric_name = metric_name if metric_name != OMIT
|
85
|
+
@points_system_key = points_system_key if points_system_key != OMIT
|
86
|
+
@points_system_name = points_system_name if points_system_name != OMIT
|
87
|
+
@description = description if description != OMIT
|
88
|
+
@start = start
|
89
|
+
@end_ = end_ if end_ != OMIT
|
90
|
+
@max_participants = max_participants
|
91
|
+
@run_unit = run_unit if run_unit != OMIT
|
92
|
+
@run_interval = run_interval
|
93
|
+
@additional_properties = additional_properties
|
94
|
+
@_field_set = {
|
95
|
+
"rankings": rankings,
|
96
|
+
"id": id,
|
97
|
+
"name": name,
|
98
|
+
"key": key,
|
99
|
+
"status": status,
|
100
|
+
"rankBy": rank_by,
|
101
|
+
"metricKey": metric_key,
|
102
|
+
"metricName": metric_name,
|
103
|
+
"pointsSystemKey": points_system_key,
|
104
|
+
"pointsSystemName": points_system_name,
|
105
|
+
"description": description,
|
106
|
+
"start": start,
|
107
|
+
"end": end_,
|
108
|
+
"maxParticipants": max_participants,
|
109
|
+
"runUnit": run_unit,
|
110
|
+
"runInterval": run_interval
|
111
|
+
}.reject do |_k, v|
|
112
|
+
v == OMIT
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Deserialize a JSON object to an instance of LeaderboardResponseWithRankings
|
117
|
+
#
|
118
|
+
# @param json_object [String]
|
119
|
+
# @return [TrophyApiClient::LeaderboardResponseWithRankings]
|
120
|
+
def self.from_json(json_object:)
|
121
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
122
|
+
parsed_json = JSON.parse(json_object)
|
123
|
+
rankings = parsed_json["rankings"]&.map do |item|
|
124
|
+
item = item.to_json
|
125
|
+
TrophyApiClient::LeaderboardRanking.from_json(json_object: item)
|
126
|
+
end
|
127
|
+
id = parsed_json["id"]
|
128
|
+
name = parsed_json["name"]
|
129
|
+
key = parsed_json["key"]
|
130
|
+
status = parsed_json["status"]
|
131
|
+
rank_by = parsed_json["rankBy"]
|
132
|
+
metric_key = parsed_json["metricKey"]
|
133
|
+
metric_name = parsed_json["metricName"]
|
134
|
+
points_system_key = parsed_json["pointsSystemKey"]
|
135
|
+
points_system_name = parsed_json["pointsSystemName"]
|
136
|
+
description = parsed_json["description"]
|
137
|
+
start = parsed_json["start"]
|
138
|
+
end_ = parsed_json["end"]
|
139
|
+
max_participants = parsed_json["maxParticipants"]
|
140
|
+
run_unit = parsed_json["runUnit"]
|
141
|
+
run_interval = parsed_json["runInterval"]
|
142
|
+
new(
|
143
|
+
rankings: rankings,
|
144
|
+
id: id,
|
145
|
+
name: name,
|
146
|
+
key: key,
|
147
|
+
status: status,
|
148
|
+
rank_by: rank_by,
|
149
|
+
metric_key: metric_key,
|
150
|
+
metric_name: metric_name,
|
151
|
+
points_system_key: points_system_key,
|
152
|
+
points_system_name: points_system_name,
|
153
|
+
description: description,
|
154
|
+
start: start,
|
155
|
+
end_: end_,
|
156
|
+
max_participants: max_participants,
|
157
|
+
run_unit: run_unit,
|
158
|
+
run_interval: run_interval,
|
159
|
+
additional_properties: struct
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Serialize an instance of LeaderboardResponseWithRankings to a JSON object
|
164
|
+
#
|
165
|
+
# @return [String]
|
166
|
+
def to_json(*_args)
|
167
|
+
@_field_set&.to_json
|
168
|
+
end
|
169
|
+
|
170
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
171
|
+
# hash and check each fields type against the current object's property
|
172
|
+
# definitions.
|
173
|
+
#
|
174
|
+
# @param obj [Object]
|
175
|
+
# @return [Void]
|
176
|
+
def self.validate_raw(obj:)
|
177
|
+
obj.rankings.is_a?(Array) != false || raise("Passed value for field obj.rankings is not the expected type, validation failed.")
|
178
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
179
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
180
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
181
|
+
obj.status&.is_a?(TrophyApiClient::LeaderboardResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
182
|
+
obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
|
183
|
+
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
|
184
|
+
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
185
|
+
obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
|
186
|
+
obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
|
187
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
188
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
189
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
190
|
+
obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
|
191
|
+
obj.run_unit&.is_a?(String) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
|
192
|
+
obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "leaderboard_response_status"
|
4
|
+
require_relative "leaderboard_response_rank_by"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module TrophyApiClient
|
9
|
+
class MetricEventLeaderboardResponse
|
10
|
+
# @return [String] The end date of the current run of the leaderboard, or null if the run never
|
11
|
+
# ends.
|
12
|
+
attr_reader :end_
|
13
|
+
# @return [Integer] The user's rank in the leaderboard, or null if the user is not on the
|
14
|
+
# leaderboard.
|
15
|
+
attr_reader :rank
|
16
|
+
# @return [Integer] The user's rank in the leaderboard before the event, or null if the user was not
|
17
|
+
# on the leaderboard before the event.
|
18
|
+
attr_reader :previous_rank
|
19
|
+
# @return [Float] The minimum value required to enter the leaderboard according to its current
|
20
|
+
# rankings.
|
21
|
+
attr_reader :threshold
|
22
|
+
# @return [String] The unique ID of the leaderboard.
|
23
|
+
attr_reader :id
|
24
|
+
# @return [String] The user-facing name of the leaderboard.
|
25
|
+
attr_reader :name
|
26
|
+
# @return [String] The unique key used to reference the leaderboard in APIs.
|
27
|
+
attr_reader :key
|
28
|
+
# @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
|
29
|
+
attr_reader :status
|
30
|
+
# @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
31
|
+
attr_reader :rank_by
|
32
|
+
# @return [String] The key of the metric to rank by, if rankBy is 'metric'.
|
33
|
+
attr_reader :metric_key
|
34
|
+
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
|
35
|
+
attr_reader :metric_name
|
36
|
+
# @return [String] The key of the points system to rank by, if rankBy is 'points'.
|
37
|
+
attr_reader :points_system_key
|
38
|
+
# @return [String] The name of the points system to rank by, if rankBy is 'points'.
|
39
|
+
attr_reader :points_system_name
|
40
|
+
# @return [String] The user-facing description of the leaderboard.
|
41
|
+
attr_reader :description
|
42
|
+
# @return [String] The start date of the leaderboard in YYYY-MM-DD format.
|
43
|
+
attr_reader :start
|
44
|
+
# @return [Integer] The maximum number of participants in the leaderboard.
|
45
|
+
attr_reader :max_participants
|
46
|
+
# @return [String] The repetition type for recurring leaderboards, or null for one-time
|
47
|
+
# leaderboards.
|
48
|
+
attr_reader :run_unit
|
49
|
+
# @return [Integer] The interval between repetitions, relative to the start date and repetition
|
50
|
+
# type.
|
51
|
+
attr_reader :run_interval
|
52
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
53
|
+
attr_reader :additional_properties
|
54
|
+
# @return [Object]
|
55
|
+
attr_reader :_field_set
|
56
|
+
protected :_field_set
|
57
|
+
|
58
|
+
OMIT = Object.new
|
59
|
+
|
60
|
+
# @param end_ [String] The end date of the current run of the leaderboard, or null if the run never
|
61
|
+
# ends.
|
62
|
+
# @param rank [Integer] The user's rank in the leaderboard, or null if the user is not on the
|
63
|
+
# leaderboard.
|
64
|
+
# @param previous_rank [Integer] The user's rank in the leaderboard before the event, or null if the user was not
|
65
|
+
# on the leaderboard before the event.
|
66
|
+
# @param threshold [Float] The minimum value required to enter the leaderboard according to its current
|
67
|
+
# rankings.
|
68
|
+
# @param id [String] The unique ID of the leaderboard.
|
69
|
+
# @param name [String] The user-facing name of the leaderboard.
|
70
|
+
# @param key [String] The unique key used to reference the leaderboard in APIs.
|
71
|
+
# @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
|
72
|
+
# @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
73
|
+
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
|
74
|
+
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
|
75
|
+
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
|
76
|
+
# @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
|
77
|
+
# @param description [String] The user-facing description of the leaderboard.
|
78
|
+
# @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
|
79
|
+
# @param max_participants [Integer] The maximum number of participants in the leaderboard.
|
80
|
+
# @param run_unit [String] The repetition type for recurring leaderboards, or null for one-time
|
81
|
+
# leaderboards.
|
82
|
+
# @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
|
83
|
+
# type.
|
84
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
85
|
+
# @return [TrophyApiClient::MetricEventLeaderboardResponse]
|
86
|
+
def initialize(threshold:, id:, name:, key:, rank_by:, start:, max_participants:, run_interval:, end_: OMIT, rank: OMIT, previous_rank: OMIT, status: OMIT,
|
87
|
+
metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, run_unit: OMIT, additional_properties: nil)
|
88
|
+
@end_ = end_ if end_ != OMIT
|
89
|
+
@rank = rank if rank != OMIT
|
90
|
+
@previous_rank = previous_rank if previous_rank != OMIT
|
91
|
+
@threshold = threshold
|
92
|
+
@id = id
|
93
|
+
@name = name
|
94
|
+
@key = key
|
95
|
+
@status = status if status != OMIT
|
96
|
+
@rank_by = rank_by
|
97
|
+
@metric_key = metric_key if metric_key != OMIT
|
98
|
+
@metric_name = metric_name if metric_name != OMIT
|
99
|
+
@points_system_key = points_system_key if points_system_key != OMIT
|
100
|
+
@points_system_name = points_system_name if points_system_name != OMIT
|
101
|
+
@description = description if description != OMIT
|
102
|
+
@start = start
|
103
|
+
@max_participants = max_participants
|
104
|
+
@run_unit = run_unit if run_unit != OMIT
|
105
|
+
@run_interval = run_interval
|
106
|
+
@additional_properties = additional_properties
|
107
|
+
@_field_set = {
|
108
|
+
"end": end_,
|
109
|
+
"rank": rank,
|
110
|
+
"previousRank": previous_rank,
|
111
|
+
"threshold": threshold,
|
112
|
+
"id": id,
|
113
|
+
"name": name,
|
114
|
+
"key": key,
|
115
|
+
"status": status,
|
116
|
+
"rankBy": rank_by,
|
117
|
+
"metricKey": metric_key,
|
118
|
+
"metricName": metric_name,
|
119
|
+
"pointsSystemKey": points_system_key,
|
120
|
+
"pointsSystemName": points_system_name,
|
121
|
+
"description": description,
|
122
|
+
"start": start,
|
123
|
+
"maxParticipants": max_participants,
|
124
|
+
"runUnit": run_unit,
|
125
|
+
"runInterval": run_interval
|
126
|
+
}.reject do |_k, v|
|
127
|
+
v == OMIT
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Deserialize a JSON object to an instance of MetricEventLeaderboardResponse
|
132
|
+
#
|
133
|
+
# @param json_object [String]
|
134
|
+
# @return [TrophyApiClient::MetricEventLeaderboardResponse]
|
135
|
+
def self.from_json(json_object:)
|
136
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
137
|
+
parsed_json = JSON.parse(json_object)
|
138
|
+
end_ = parsed_json["end"]
|
139
|
+
rank = parsed_json["rank"]
|
140
|
+
previous_rank = parsed_json["previousRank"]
|
141
|
+
threshold = parsed_json["threshold"]
|
142
|
+
id = parsed_json["id"]
|
143
|
+
name = parsed_json["name"]
|
144
|
+
key = parsed_json["key"]
|
145
|
+
status = parsed_json["status"]
|
146
|
+
rank_by = parsed_json["rankBy"]
|
147
|
+
metric_key = parsed_json["metricKey"]
|
148
|
+
metric_name = parsed_json["metricName"]
|
149
|
+
points_system_key = parsed_json["pointsSystemKey"]
|
150
|
+
points_system_name = parsed_json["pointsSystemName"]
|
151
|
+
description = parsed_json["description"]
|
152
|
+
start = parsed_json["start"]
|
153
|
+
max_participants = parsed_json["maxParticipants"]
|
154
|
+
run_unit = parsed_json["runUnit"]
|
155
|
+
run_interval = parsed_json["runInterval"]
|
156
|
+
new(
|
157
|
+
end_: end_,
|
158
|
+
rank: rank,
|
159
|
+
previous_rank: previous_rank,
|
160
|
+
threshold: threshold,
|
161
|
+
id: id,
|
162
|
+
name: name,
|
163
|
+
key: key,
|
164
|
+
status: status,
|
165
|
+
rank_by: rank_by,
|
166
|
+
metric_key: metric_key,
|
167
|
+
metric_name: metric_name,
|
168
|
+
points_system_key: points_system_key,
|
169
|
+
points_system_name: points_system_name,
|
170
|
+
description: description,
|
171
|
+
start: start,
|
172
|
+
max_participants: max_participants,
|
173
|
+
run_unit: run_unit,
|
174
|
+
run_interval: run_interval,
|
175
|
+
additional_properties: struct
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Serialize an instance of MetricEventLeaderboardResponse to a JSON object
|
180
|
+
#
|
181
|
+
# @return [String]
|
182
|
+
def to_json(*_args)
|
183
|
+
@_field_set&.to_json
|
184
|
+
end
|
185
|
+
|
186
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
187
|
+
# hash and check each fields type against the current object's property
|
188
|
+
# definitions.
|
189
|
+
#
|
190
|
+
# @param obj [Object]
|
191
|
+
# @return [Void]
|
192
|
+
def self.validate_raw(obj:)
|
193
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
194
|
+
obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
|
195
|
+
obj.previous_rank&.is_a?(Integer) != false || raise("Passed value for field obj.previous_rank is not the expected type, validation failed.")
|
196
|
+
obj.threshold.is_a?(Float) != false || raise("Passed value for field obj.threshold is not the expected type, validation failed.")
|
197
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
198
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
199
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
200
|
+
obj.status&.is_a?(TrophyApiClient::LeaderboardResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
201
|
+
obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
|
202
|
+
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
|
203
|
+
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
204
|
+
obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
|
205
|
+
obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
|
206
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
207
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
208
|
+
obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
|
209
|
+
obj.run_unit&.is_a?(String) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
|
210
|
+
obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "leaderboard_event"
|
4
|
+
require_relative "leaderboard_response_status"
|
5
|
+
require_relative "leaderboard_response_rank_by"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module TrophyApiClient
|
10
|
+
# A user's data for a specific leaderboard including rank, value, and history.
|
11
|
+
class UserLeaderboardResponse
|
12
|
+
# @return [Integer] The user's current rank in this leaderboard. Null if the user is not on the
|
13
|
+
# leaderboard.
|
14
|
+
attr_reader :rank
|
15
|
+
# @return [Integer] The user's current value in this leaderboard. Null if the user is not on the
|
16
|
+
# leaderboard.
|
17
|
+
attr_reader :value
|
18
|
+
# @return [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
|
19
|
+
attr_reader :history
|
20
|
+
# @return [String] The unique ID of the leaderboard.
|
21
|
+
attr_reader :id
|
22
|
+
# @return [String] The user-facing name of the leaderboard.
|
23
|
+
attr_reader :name
|
24
|
+
# @return [String] The unique key used to reference the leaderboard in APIs.
|
25
|
+
attr_reader :key
|
26
|
+
# @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
|
27
|
+
attr_reader :status
|
28
|
+
# @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
29
|
+
attr_reader :rank_by
|
30
|
+
# @return [String] The key of the metric to rank by, if rankBy is 'metric'.
|
31
|
+
attr_reader :metric_key
|
32
|
+
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
|
33
|
+
attr_reader :metric_name
|
34
|
+
# @return [String] The key of the points system to rank by, if rankBy is 'points'.
|
35
|
+
attr_reader :points_system_key
|
36
|
+
# @return [String] The name of the points system to rank by, if rankBy is 'points'.
|
37
|
+
attr_reader :points_system_name
|
38
|
+
# @return [String] The user-facing description of the leaderboard.
|
39
|
+
attr_reader :description
|
40
|
+
# @return [String] The start date of the leaderboard in YYYY-MM-DD format.
|
41
|
+
attr_reader :start
|
42
|
+
# @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
|
43
|
+
# forever.
|
44
|
+
attr_reader :end_
|
45
|
+
# @return [Integer] The maximum number of participants in the leaderboard.
|
46
|
+
attr_reader :max_participants
|
47
|
+
# @return [String] The repetition type for recurring leaderboards, or null for one-time
|
48
|
+
# leaderboards.
|
49
|
+
attr_reader :run_unit
|
50
|
+
# @return [Integer] The interval between repetitions, relative to the start date and repetition
|
51
|
+
# type.
|
52
|
+
attr_reader :run_interval
|
53
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
54
|
+
attr_reader :additional_properties
|
55
|
+
# @return [Object]
|
56
|
+
attr_reader :_field_set
|
57
|
+
protected :_field_set
|
58
|
+
|
59
|
+
OMIT = Object.new
|
60
|
+
|
61
|
+
# @param rank [Integer] The user's current rank in this leaderboard. Null if the user is not on the
|
62
|
+
# leaderboard.
|
63
|
+
# @param value [Integer] The user's current value in this leaderboard. Null if the user is not on the
|
64
|
+
# leaderboard.
|
65
|
+
# @param history [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
|
66
|
+
# @param id [String] The unique ID of the leaderboard.
|
67
|
+
# @param name [String] The user-facing name of the leaderboard.
|
68
|
+
# @param key [String] The unique key used to reference the leaderboard in APIs.
|
69
|
+
# @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
|
70
|
+
# @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
71
|
+
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
|
72
|
+
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
|
73
|
+
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
|
74
|
+
# @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
|
75
|
+
# @param description [String] The user-facing description of the leaderboard.
|
76
|
+
# @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
|
77
|
+
# @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
|
78
|
+
# forever.
|
79
|
+
# @param max_participants [Integer] The maximum number of participants in the leaderboard.
|
80
|
+
# @param run_unit [String] The repetition type for recurring leaderboards, or null for one-time
|
81
|
+
# leaderboards.
|
82
|
+
# @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
|
83
|
+
# type.
|
84
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
85
|
+
# @return [TrophyApiClient::UserLeaderboardResponse]
|
86
|
+
def initialize(history:, id:, name:, key:, rank_by:, start:, max_participants:, run_interval:, rank: OMIT, value: OMIT, status: OMIT, metric_key: OMIT,
|
87
|
+
metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
|
88
|
+
@rank = rank if rank != OMIT
|
89
|
+
@value = value if value != OMIT
|
90
|
+
@history = history
|
91
|
+
@id = id
|
92
|
+
@name = name
|
93
|
+
@key = key
|
94
|
+
@status = status if status != OMIT
|
95
|
+
@rank_by = rank_by
|
96
|
+
@metric_key = metric_key if metric_key != OMIT
|
97
|
+
@metric_name = metric_name if metric_name != OMIT
|
98
|
+
@points_system_key = points_system_key if points_system_key != OMIT
|
99
|
+
@points_system_name = points_system_name if points_system_name != OMIT
|
100
|
+
@description = description if description != OMIT
|
101
|
+
@start = start
|
102
|
+
@end_ = end_ if end_ != OMIT
|
103
|
+
@max_participants = max_participants
|
104
|
+
@run_unit = run_unit if run_unit != OMIT
|
105
|
+
@run_interval = run_interval
|
106
|
+
@additional_properties = additional_properties
|
107
|
+
@_field_set = {
|
108
|
+
"rank": rank,
|
109
|
+
"value": value,
|
110
|
+
"history": history,
|
111
|
+
"id": id,
|
112
|
+
"name": name,
|
113
|
+
"key": key,
|
114
|
+
"status": status,
|
115
|
+
"rankBy": rank_by,
|
116
|
+
"metricKey": metric_key,
|
117
|
+
"metricName": metric_name,
|
118
|
+
"pointsSystemKey": points_system_key,
|
119
|
+
"pointsSystemName": points_system_name,
|
120
|
+
"description": description,
|
121
|
+
"start": start,
|
122
|
+
"end": end_,
|
123
|
+
"maxParticipants": max_participants,
|
124
|
+
"runUnit": run_unit,
|
125
|
+
"runInterval": run_interval
|
126
|
+
}.reject do |_k, v|
|
127
|
+
v == OMIT
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Deserialize a JSON object to an instance of UserLeaderboardResponse
|
132
|
+
#
|
133
|
+
# @param json_object [String]
|
134
|
+
# @return [TrophyApiClient::UserLeaderboardResponse]
|
135
|
+
def self.from_json(json_object:)
|
136
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
137
|
+
parsed_json = JSON.parse(json_object)
|
138
|
+
rank = parsed_json["rank"]
|
139
|
+
value = parsed_json["value"]
|
140
|
+
history = parsed_json["history"]&.map do |item|
|
141
|
+
item = item.to_json
|
142
|
+
TrophyApiClient::LeaderboardEvent.from_json(json_object: item)
|
143
|
+
end
|
144
|
+
id = parsed_json["id"]
|
145
|
+
name = parsed_json["name"]
|
146
|
+
key = parsed_json["key"]
|
147
|
+
status = parsed_json["status"]
|
148
|
+
rank_by = parsed_json["rankBy"]
|
149
|
+
metric_key = parsed_json["metricKey"]
|
150
|
+
metric_name = parsed_json["metricName"]
|
151
|
+
points_system_key = parsed_json["pointsSystemKey"]
|
152
|
+
points_system_name = parsed_json["pointsSystemName"]
|
153
|
+
description = parsed_json["description"]
|
154
|
+
start = parsed_json["start"]
|
155
|
+
end_ = parsed_json["end"]
|
156
|
+
max_participants = parsed_json["maxParticipants"]
|
157
|
+
run_unit = parsed_json["runUnit"]
|
158
|
+
run_interval = parsed_json["runInterval"]
|
159
|
+
new(
|
160
|
+
rank: rank,
|
161
|
+
value: value,
|
162
|
+
history: history,
|
163
|
+
id: id,
|
164
|
+
name: name,
|
165
|
+
key: key,
|
166
|
+
status: status,
|
167
|
+
rank_by: rank_by,
|
168
|
+
metric_key: metric_key,
|
169
|
+
metric_name: metric_name,
|
170
|
+
points_system_key: points_system_key,
|
171
|
+
points_system_name: points_system_name,
|
172
|
+
description: description,
|
173
|
+
start: start,
|
174
|
+
end_: end_,
|
175
|
+
max_participants: max_participants,
|
176
|
+
run_unit: run_unit,
|
177
|
+
run_interval: run_interval,
|
178
|
+
additional_properties: struct
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Serialize an instance of UserLeaderboardResponse to a JSON object
|
183
|
+
#
|
184
|
+
# @return [String]
|
185
|
+
def to_json(*_args)
|
186
|
+
@_field_set&.to_json
|
187
|
+
end
|
188
|
+
|
189
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
190
|
+
# hash and check each fields type against the current object's property
|
191
|
+
# definitions.
|
192
|
+
#
|
193
|
+
# @param obj [Object]
|
194
|
+
# @return [Void]
|
195
|
+
def self.validate_raw(obj:)
|
196
|
+
obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
|
197
|
+
obj.value&.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
198
|
+
obj.history.is_a?(Array) != false || raise("Passed value for field obj.history is not the expected type, validation failed.")
|
199
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
200
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
201
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
202
|
+
obj.status&.is_a?(TrophyApiClient::LeaderboardResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
203
|
+
obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
|
204
|
+
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
|
205
|
+
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
206
|
+
obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
|
207
|
+
obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
|
208
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
209
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
210
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
211
|
+
obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
|
212
|
+
obj.run_unit&.is_a?(String) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
|
213
|
+
obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|