Class: TrophyApiClient::AdminLeaderboard
- Inherits:
-
Object
- Object
- TrophyApiClient::AdminLeaderboard
- Defined in:
- lib/trophy_api_client/types/admin_leaderboard.rb
Overview
A leaderboard returned from the admin leaderboards endpoints.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#breakdown_attributes ⇒ Array<String>
readonly
The UUIDs of the user attributes used for ranking breakdowns.
-
#description ⇒ String
readonly
The leaderboard description.
-
#end_ ⇒ String
readonly
The optional leaderboard end date in YYYY-MM-DD format.
-
#id ⇒ String
readonly
The UUID of the leaderboard.
-
#key ⇒ String
readonly
The leaderboard key.
-
#max_participants ⇒ Integer
readonly
The maximum number of participants.
-
#metric_id ⇒ String
readonly
The metric ID used when ‘rankBy` is `metric`.
-
#name ⇒ String
readonly
The leaderboard name.
-
#points_system_id ⇒ String
readonly
The points system ID used when ‘rankBy` is `points`.
-
#rank_by ⇒ TrophyApiClient::AdminLeaderboardRankBy
readonly
What the leaderboard ranks by.
-
#run_interval ⇒ Integer
readonly
The number of recurrence units between leaderboard runs.
-
#run_unit ⇒ TrophyApiClient::AdminLeaderboardRunUnit
readonly
The recurrence unit when the leaderboard repeats.
-
#start ⇒ String
readonly
The leaderboard start date in YYYY-MM-DD format.
-
#status ⇒ TrophyApiClient::AdminLeaderboardStatus
readonly
The current user-facing status of the leaderboard.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::AdminLeaderboard
Deserialize a JSON object to an instance of AdminLeaderboard.
-
.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(id:, name:, key:, status:, rank_by:, max_participants:, start:, breakdown_attributes:, description: OMIT, metric_id: OMIT, points_system_id: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminLeaderboard constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AdminLeaderboard to a JSON object.
Constructor Details
#initialize(id:, name:, key:, status:, rank_by:, max_participants:, start:, breakdown_attributes:, description: OMIT, metric_id: OMIT, points_system_id: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminLeaderboard
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 64 def initialize(id:, name:, key:, status:, rank_by:, max_participants:, start:, breakdown_attributes:, description: OMIT, metric_id: OMIT, points_system_id: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil) @id = id @name = name @key = key @description = description if description != OMIT @status = status @rank_by = rank_by @metric_id = metric_id if metric_id != OMIT @points_system_id = points_system_id if points_system_id != OMIT @max_participants = max_participants @start = start @end_ = end_ if end_ != OMIT @breakdown_attributes = breakdown_attributes @run_unit = run_unit if run_unit != OMIT @run_interval = run_interval if run_interval != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "name": name, "key": key, "description": description, "status": status, "rankBy": rank_by, "metricId": metric_id, "pointsSystemId": points_system_id, "maxParticipants": max_participants, "start": start, "end": end_, "breakdownAttributes": breakdown_attributes, "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.
41 42 43 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 41 def additional_properties @additional_properties end |
#breakdown_attributes ⇒ Array<String> (readonly)
Returns The UUIDs of the user attributes used for ranking breakdowns.
35 36 37 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 35 def breakdown_attributes @breakdown_attributes end |
#description ⇒ String (readonly)
Returns The leaderboard description.
19 20 21 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 19 def description @description end |
#end_ ⇒ String (readonly)
Returns The optional leaderboard end date in YYYY-MM-DD format.
33 34 35 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 33 def end_ @end_ end |
#id ⇒ String (readonly)
Returns The UUID of the leaderboard.
13 14 15 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 13 def id @id end |
#key ⇒ String (readonly)
Returns The leaderboard key.
17 18 19 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 17 def key @key end |
#max_participants ⇒ Integer (readonly)
Returns The maximum number of participants.
29 30 31 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 29 def max_participants @max_participants end |
#metric_id ⇒ String (readonly)
Returns The metric ID used when ‘rankBy` is `metric`.
25 26 27 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 25 def metric_id @metric_id end |
#name ⇒ String (readonly)
Returns The leaderboard name.
15 16 17 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 15 def name @name end |
#points_system_id ⇒ String (readonly)
Returns The points system ID used when ‘rankBy` is `points`.
27 28 29 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 27 def points_system_id @points_system_id end |
#rank_by ⇒ TrophyApiClient::AdminLeaderboardRankBy (readonly)
Returns What the leaderboard ranks by.
23 24 25 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 23 def rank_by @rank_by end |
#run_interval ⇒ Integer (readonly)
Returns The number of recurrence units between leaderboard runs.
39 40 41 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 39 def run_interval @run_interval end |
#run_unit ⇒ TrophyApiClient::AdminLeaderboardRunUnit (readonly)
Returns The recurrence unit when the leaderboard repeats.
37 38 39 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 37 def run_unit @run_unit end |
#start ⇒ String (readonly)
Returns The leaderboard start date in YYYY-MM-DD format.
31 32 33 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 31 def start @start end |
#status ⇒ TrophyApiClient::AdminLeaderboardStatus (readonly)
Returns The current user-facing status of the leaderboard.
21 22 23 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 21 def status @status end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::AdminLeaderboard
Deserialize a JSON object to an instance of AdminLeaderboard
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 105 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] name = parsed_json["name"] key = parsed_json["key"] description = parsed_json["description"] status = parsed_json["status"] rank_by = parsed_json["rankBy"] metric_id = parsed_json["metricId"] points_system_id = parsed_json["pointsSystemId"] max_participants = parsed_json["maxParticipants"] start = parsed_json["start"] end_ = parsed_json["end"] breakdown_attributes = parsed_json["breakdownAttributes"] run_unit = parsed_json["runUnit"] run_interval = parsed_json["runInterval"] new( id: id, name: name, key: key, description: description, status: status, rank_by: rank_by, metric_id: metric_id, points_system_id: points_system_id, max_participants: max_participants, start: start, end_: end_, breakdown_attributes: breakdown_attributes, 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.
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 154 def self.validate_raw(obj:) 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.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") obj.status.is_a?(TrophyApiClient::AdminLeaderboardStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.rank_by.is_a?(TrophyApiClient::AdminLeaderboardRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.") obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.") obj.points_system_id&.is_a?(String) != false || raise("Passed value for field obj.points_system_id 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.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.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.") obj.run_unit&.is_a?(TrophyApiClient::AdminLeaderboardRunUnit) != 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 AdminLeaderboard to a JSON object
144 145 146 |
# File 'lib/trophy_api_client/types/admin_leaderboard.rb', line 144 def to_json(*_args) @_field_set&.to_json end |