Class: TrophyApiClient::LeaderboardResponseWithRankings
- Inherits:
-
Object
- Object
- TrophyApiClient::LeaderboardResponseWithRankings
- Defined in:
- lib/trophy_api_client/types/leaderboard_response_with_rankings.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#breakdown_attribute ⇒ String
readonly
Deprecated.
-
#breakdown_attributes ⇒ Array<String>
readonly
The user attribute keys that this leaderboard is broken down by.
-
#description ⇒ String
readonly
The user-facing description of the leaderboard.
-
#end_ ⇒ String
readonly
The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.
-
#id ⇒ String
readonly
The unique ID of the leaderboard.
-
#key ⇒ String
readonly
The unique key used to reference the leaderboard in APIs.
-
#max_participants ⇒ Integer
readonly
The maximum number of participants in the leaderboard.
-
#metric_key ⇒ String
readonly
The key of the metric to rank by, if rankBy is ‘metric’.
-
#metric_name ⇒ String
readonly
The name of the metric to rank by, if rankBy is ‘metric’.
-
#name ⇒ String
readonly
The user-facing name of the leaderboard.
-
#points_system_key ⇒ String
readonly
The key of the points system to rank by, if rankBy is ‘points’.
-
#points_system_name ⇒ String
readonly
The name of the points system to rank by, if rankBy is ‘points’.
-
#rank_by ⇒ TrophyApiClient::LeaderboardResponseRankBy
readonly
What the leaderboard ranks by.
-
#rankings ⇒ Array<TrophyApiClient::LeaderboardRanking>
readonly
Array of user rankings for the leaderboard.
-
#run_interval ⇒ Integer
readonly
The interval between repetitions, relative to the start date and repetition type.
-
#run_unit ⇒ TrophyApiClient::LeaderboardResponseRunUnit
readonly
The repetition type for recurring leaderboards, or null for one-time leaderboards.
-
#start ⇒ String
readonly
The start date of the leaderboard in YYYY-MM-DD format.
-
#status ⇒ TrophyApiClient::LeaderboardResponseWithRankingsStatus
readonly
The status of the leaderboard.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::LeaderboardResponseWithRankings
Deserialize a JSON object to an instance of LeaderboardResponseWithRankings.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(status:, rankings:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, breakdown_attribute: OMIT, 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) ⇒ TrophyApiClient::LeaderboardResponseWithRankings constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of LeaderboardResponseWithRankings to a JSON object.
Constructor Details
#initialize(status:, rankings:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, breakdown_attribute: OMIT, 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) ⇒ TrophyApiClient::LeaderboardResponseWithRankings
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 82 def initialize(status:, rankings:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, breakdown_attribute: OMIT, 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) @status = status @rankings = rankings @id = id @name = name @key = key @rank_by = rank_by @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT @breakdown_attributes = breakdown_attributes @metric_key = metric_key if metric_key != OMIT @metric_name = metric_name if metric_name != OMIT @points_system_key = points_system_key if points_system_key != OMIT @points_system_name = points_system_name if points_system_name != OMIT @description = description if description != OMIT @start = start @end_ = end_ if end_ != OMIT @max_participants = max_participants @run_unit = run_unit if run_unit != OMIT @run_interval = run_interval if run_interval != OMIT @additional_properties = additional_properties @_field_set = { "status": status, "rankings": rankings, "id": id, "name": name, "key": key, "rankBy": rank_by, "breakdownAttribute": breakdown_attribute, "breakdownAttributes": breakdown_attributes, "metricKey": metric_key, "metricName": metric_name, "pointsSystemKey": points_system_key, "pointsSystemName": points_system_name, "description": description, "start": start, "end": end_, "maxParticipants": max_participants, "runUnit": run_unit, "runInterval": run_interval }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
52 53 54 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 52 def additional_properties @additional_properties end |
#breakdown_attribute ⇒ String (readonly)
Returns Deprecated. The key of the attribute to break down this leaderboard by.
25 26 27 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 25 def breakdown_attribute @breakdown_attribute end |
#breakdown_attributes ⇒ Array<String> (readonly)
Returns The user attribute keys that this leaderboard is broken down by.
27 28 29 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 27 def breakdown_attributes @breakdown_attributes end |
#description ⇒ String (readonly)
Returns The user-facing description of the leaderboard.
37 38 39 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 37 def description @description end |
#end_ ⇒ String (readonly)
Returns The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.
42 43 44 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 42 def end_ @end_ end |
#id ⇒ String (readonly)
Returns The unique ID of the leaderboard.
17 18 19 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 17 def id @id end |
#key ⇒ String (readonly)
Returns The unique key used to reference the leaderboard in APIs.
21 22 23 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 21 def key @key end |
#max_participants ⇒ Integer (readonly)
Returns The maximum number of participants in the leaderboard.
44 45 46 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 44 def max_participants @max_participants end |
#metric_key ⇒ String (readonly)
Returns The key of the metric to rank by, if rankBy is ‘metric’.
29 30 31 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 29 def metric_key @metric_key end |
#metric_name ⇒ String (readonly)
Returns The name of the metric to rank by, if rankBy is ‘metric’.
31 32 33 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 31 def metric_name @metric_name end |
#name ⇒ String (readonly)
Returns The user-facing name of the leaderboard.
19 20 21 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 19 def name @name end |
#points_system_key ⇒ String (readonly)
Returns The key of the points system to rank by, if rankBy is ‘points’.
33 34 35 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 33 def points_system_key @points_system_key end |
#points_system_name ⇒ String (readonly)
Returns The name of the points system to rank by, if rankBy is ‘points’.
35 36 37 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 35 def points_system_name @points_system_name end |
#rank_by ⇒ TrophyApiClient::LeaderboardResponseRankBy (readonly)
Returns What the leaderboard ranks by.
23 24 25 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 23 def rank_by @rank_by end |
#rankings ⇒ Array<TrophyApiClient::LeaderboardRanking> (readonly)
Returns Array of user rankings for the leaderboard.
15 16 17 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 15 def rankings @rankings end |
#run_interval ⇒ Integer (readonly)
Returns The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.
50 51 52 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 50 def run_interval @run_interval end |
#run_unit ⇒ TrophyApiClient::LeaderboardResponseRunUnit (readonly)
Returns The repetition type for recurring leaderboards, or null for one-time leaderboards.
47 48 49 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 47 def run_unit @run_unit end |
#start ⇒ String (readonly)
Returns The start date of the leaderboard in YYYY-MM-DD format.
39 40 41 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 39 def start @start end |
#status ⇒ TrophyApiClient::LeaderboardResponseWithRankingsStatus (readonly)
Returns The status of the leaderboard.
13 14 15 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 13 def status @status end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::LeaderboardResponseWithRankings
Deserialize a JSON object to an instance of LeaderboardResponseWithRankings
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 131 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) status = parsed_json["status"] rankings = parsed_json["rankings"]&.map do |item| item = item.to_json TrophyApiClient::LeaderboardRanking.from_json(json_object: item) end id = parsed_json["id"] name = parsed_json["name"] key = parsed_json["key"] rank_by = parsed_json["rankBy"] breakdown_attribute = parsed_json["breakdownAttribute"] breakdown_attributes = parsed_json["breakdownAttributes"] metric_key = parsed_json["metricKey"] metric_name = parsed_json["metricName"] points_system_key = parsed_json["pointsSystemKey"] points_system_name = parsed_json["pointsSystemName"] description = parsed_json["description"] start = parsed_json["start"] end_ = parsed_json["end"] max_participants = parsed_json["maxParticipants"] run_unit = parsed_json["runUnit"] run_interval = parsed_json["runInterval"] new( status: status, rankings: rankings, id: id, name: name, key: key, rank_by: rank_by, breakdown_attribute: breakdown_attribute, breakdown_attributes: breakdown_attributes, metric_key: metric_key, metric_name: metric_name, points_system_key: points_system_key, points_system_name: points_system_name, description: description, start: start, end_: end_, max_participants: max_participants, run_unit: run_unit, run_interval: run_interval, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 191 def self.validate_raw(obj:) obj.status.is_a?(TrophyApiClient::LeaderboardResponseWithRankingsStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.rankings.is_a?(Array) != false || raise("Passed value for field obj.rankings is not the expected type, validation failed.") obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.") obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.") obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.") obj.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.") obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.") obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.") obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.") obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.") obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.") obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.") obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.") obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.") obj.run_interval&.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of LeaderboardResponseWithRankings to a JSON object
181 182 183 |
# File 'lib/trophy_api_client/types/leaderboard_response_with_rankings.rb', line 181 def to_json(*_args) @_field_set&.to_json end |