Class: TrophyApiClient::MetricEventLeaderboardResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/metric_event_leaderboard_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(threshold:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, end_: OMIT, rank: OMIT, previous_rank: OMIT, breakdown_attribute_value: OMIT, breakdown_attribute_values: OMIT, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil) ⇒ TrophyApiClient::MetricEventLeaderboardResponse

Parameters:

  • end_ (String) (defaults to: OMIT)

    The end date of the current run of the leaderboard, or null if the run never ends.

  • rank (Integer) (defaults to: OMIT)

    The user’s rank in the leaderboard, or null if the user is not on the leaderboard.

  • previous_rank (Integer) (defaults to: OMIT)

    The user’s rank in the leaderboard before the event, or null if the user was not on the leaderboard before the event.

  • threshold (Integer)

    The minimum value required to enter the leaderboard according to its current rankings.

  • breakdown_attribute_value (String) (defaults to: OMIT)

    Deprecated. For leaderboards with a single breakdown attribute, the value of that attribute for the user.

  • breakdown_attribute_values (Array<TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem>) (defaults to: OMIT)

    For leaderboards with breakdown attributes, the user’s values for each breakdown attribute.

  • id (String)

    The unique ID of the leaderboard.

  • name (String)

    The user-facing name of the leaderboard.

  • key (String)

    The unique key used to reference the leaderboard in APIs.

  • rank_by (TrophyApiClient::LeaderboardResponseRankBy)

    What the leaderboard ranks by.

  • breakdown_attribute (String) (defaults to: OMIT)

    Deprecated. The key of the attribute to break down this leaderboard by.

  • breakdown_attributes (Array<String>)

    The user attribute keys that this leaderboard is broken down by.

  • metric_key (String) (defaults to: OMIT)

    The key of the metric to rank by, if rankBy is ‘metric’.

  • metric_name (String) (defaults to: OMIT)

    The name of the metric to rank by, if rankBy is ‘metric’.

  • points_system_key (String) (defaults to: OMIT)

    The key of the points system to rank by, if rankBy is ‘points’.

  • points_system_name (String) (defaults to: OMIT)

    The name of the points system to rank by, if rankBy is ‘points’.

  • description (String) (defaults to: OMIT)

    The user-facing description of the leaderboard.

  • start (String)

    The start date of the leaderboard in YYYY-MM-DD format.

  • max_participants (Integer)

    The maximum number of participants in the leaderboard.

  • run_unit (TrophyApiClient::LeaderboardResponseRunUnit) (defaults to: OMIT)

    The repetition type for recurring leaderboards, or null for one-time leaderboards.

  • run_interval (Integer) (defaults to: OMIT)

    The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 100

def initialize(threshold:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, end_: OMIT, rank: OMIT, previous_rank: OMIT, breakdown_attribute_value: OMIT,
               breakdown_attribute_values: OMIT, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
  @end_ = end_ if end_ != OMIT
  @rank = rank if rank != OMIT
  @previous_rank = previous_rank if previous_rank != OMIT
  @threshold = threshold
  @breakdown_attribute_value = breakdown_attribute_value if breakdown_attribute_value != OMIT
  @breakdown_attribute_values = breakdown_attribute_values if breakdown_attribute_values != OMIT
  @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
  @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 = {
    "end": end_,
    "rank": rank,
    "previousRank": previous_rank,
    "threshold": threshold,
    "breakdownAttributeValue": breakdown_attribute_value,
    "breakdownAttributeValues": breakdown_attribute_values,
    "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,
    "maxParticipants": max_participants,
    "runUnit": run_unit,
    "runInterval": run_interval
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



62
63
64
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 62

def additional_properties
  @additional_properties
end

#breakdown_attributeString (readonly)

Returns Deprecated. The key of the attribute to break down this leaderboard by.

Returns:

  • (String)

    Deprecated. The key of the attribute to break down this leaderboard by.



38
39
40
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 38

def breakdown_attribute
  @breakdown_attribute
end

#breakdown_attribute_valueString (readonly)

Returns Deprecated. For leaderboards with a single breakdown attribute, the value of that attribute for the user.

Returns:

  • (String)

    Deprecated. For leaderboards with a single breakdown attribute, the value of that attribute for the user.



25
26
27
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 25

def breakdown_attribute_value
  @breakdown_attribute_value
end

#breakdown_attribute_valuesArray<TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem> (readonly)

Returns For leaderboards with breakdown attributes, the user’s values for each breakdown attribute.

Returns:



28
29
30
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 28

def breakdown_attribute_values
  @breakdown_attribute_values
end

#breakdown_attributesArray<String> (readonly)

Returns The user attribute keys that this leaderboard is broken down by.

Returns:

  • (Array<String>)

    The user attribute keys that this leaderboard is broken down by.



40
41
42
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 40

def breakdown_attributes
  @breakdown_attributes
end

#descriptionString (readonly)

Returns The user-facing description of the leaderboard.

Returns:

  • (String)

    The user-facing description of the leaderboard.



50
51
52
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 50

def description
  @description
end

#end_String (readonly)

Returns The end date of the current run of the leaderboard, or null if the run never ends.

Returns:

  • (String)

    The end date of the current run of the leaderboard, or null if the run never ends.



13
14
15
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 13

def end_
  @end_
end

#idString (readonly)

Returns The unique ID of the leaderboard.

Returns:

  • (String)

    The unique ID of the leaderboard.



30
31
32
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 30

def id
  @id
end

#keyString (readonly)

Returns The unique key used to reference the leaderboard in APIs.

Returns:

  • (String)

    The unique key used to reference the leaderboard in APIs.



34
35
36
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 34

def key
  @key
end

#max_participantsInteger (readonly)

Returns The maximum number of participants in the leaderboard.

Returns:

  • (Integer)

    The maximum number of participants in the leaderboard.



54
55
56
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 54

def max_participants
  @max_participants
end

#metric_keyString (readonly)

Returns The key of the metric to rank by, if rankBy is ‘metric’.

Returns:

  • (String)

    The key of the metric to rank by, if rankBy is ‘metric’.



42
43
44
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 42

def metric_key
  @metric_key
end

#metric_nameString (readonly)

Returns The name of the metric to rank by, if rankBy is ‘metric’.

Returns:

  • (String)

    The name of the metric to rank by, if rankBy is ‘metric’.



44
45
46
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 44

def metric_name
  @metric_name
end

#nameString (readonly)

Returns The user-facing name of the leaderboard.

Returns:

  • (String)

    The user-facing name of the leaderboard.



32
33
34
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 32

def name
  @name
end

#points_system_keyString (readonly)

Returns The key of the points system to rank by, if rankBy is ‘points’.

Returns:

  • (String)

    The key of the points system to rank by, if rankBy is ‘points’.



46
47
48
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 46

def points_system_key
  @points_system_key
end

#points_system_nameString (readonly)

Returns The name of the points system to rank by, if rankBy is ‘points’.

Returns:

  • (String)

    The name of the points system to rank by, if rankBy is ‘points’.



48
49
50
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 48

def points_system_name
  @points_system_name
end

#previous_rankInteger (readonly)

Returns The user’s rank in the leaderboard before the event, or null if the user was not on the leaderboard before the event.

Returns:

  • (Integer)

    The user’s rank in the leaderboard before the event, or null if the user was not on the leaderboard before the event.



19
20
21
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 19

def previous_rank
  @previous_rank
end

#rankInteger (readonly)

Returns The user’s rank in the leaderboard, or null if the user is not on the leaderboard.

Returns:

  • (Integer)

    The user’s rank in the leaderboard, or null if the user is not on the leaderboard.



16
17
18
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 16

def rank
  @rank
end

#rank_byTrophyApiClient::LeaderboardResponseRankBy (readonly)

Returns What the leaderboard ranks by.

Returns:



36
37
38
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 36

def rank_by
  @rank_by
end

#run_intervalInteger (readonly)

Returns The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.

Returns:

  • (Integer)

    The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.



60
61
62
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 60

def run_interval
  @run_interval
end

#run_unitTrophyApiClient::LeaderboardResponseRunUnit (readonly)

Returns The repetition type for recurring leaderboards, or null for one-time leaderboards.

Returns:



57
58
59
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 57

def run_unit
  @run_unit
end

#startString (readonly)

Returns The start date of the leaderboard in YYYY-MM-DD format.

Returns:

  • (String)

    The start date of the leaderboard in YYYY-MM-DD format.



52
53
54
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 52

def start
  @start
end

#thresholdInteger (readonly)

Returns The minimum value required to enter the leaderboard according to its current rankings.

Returns:

  • (Integer)

    The minimum value required to enter the leaderboard according to its current rankings.



22
23
24
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 22

def threshold
  @threshold
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::MetricEventLeaderboardResponse

Deserialize a JSON object to an instance of MetricEventLeaderboardResponse

Parameters:

  • json_object (String)

Returns:



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 155

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  end_ = parsed_json["end"]
  rank = parsed_json["rank"]
  previous_rank = parsed_json["previousRank"]
  threshold = parsed_json["threshold"]
  breakdown_attribute_value = parsed_json["breakdownAttributeValue"]
  breakdown_attribute_values = parsed_json["breakdownAttributeValues"]&.map do |item|
    item = item.to_json
    TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem.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"]
  max_participants = parsed_json["maxParticipants"]
  run_unit = parsed_json["runUnit"]
  run_interval = parsed_json["runInterval"]
  new(
    end_: end_,
    rank: rank,
    previous_rank: previous_rank,
    threshold: threshold,
    breakdown_attribute_value: breakdown_attribute_value,
    breakdown_attribute_values: breakdown_attribute_values,
    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,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 221

def self.validate_raw(obj:)
  obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
  obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
  obj.previous_rank&.is_a?(Integer) != false || raise("Passed value for field obj.previous_rank is not the expected type, validation failed.")
  obj.threshold.is_a?(Integer) != false || raise("Passed value for field obj.threshold is not the expected type, validation failed.")
  obj.breakdown_attribute_value&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute_value is not the expected type, validation failed.")
  obj.breakdown_attribute_values&.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attribute_values 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.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 MetricEventLeaderboardResponse to a JSON object

Returns:

  • (String)


211
212
213
# File 'lib/trophy_api_client/types/metric_event_leaderboard_response.rb', line 211

def to_json(*_args)
  @_field_set&.to_json
end