Class: TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil) ⇒ TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem

Parameters:

  • status (TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus)

    The status of the leaderboard.

  • 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)

    The key of the attribute to break down this leaderboard 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)

    The user-facing description of the leaderboard.

  • start (String)

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

  • end_ (String) (defaults to: OMIT)

    The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.

  • 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)

    The interval between repetitions, relative to the start date and repetition type.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



76
77
78
79
80
81
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
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 76

def initialize(status:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, breakdown_attribute: OMIT, metric_key: OMIT,
               metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
  @status = status
  @id = id
  @name = name
  @key = key
  @rank_by = rank_by
  @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
  @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
  @start = start
  @end_ = end_ if end_ != OMIT
  @max_participants = max_participants
  @run_unit = run_unit if run_unit != OMIT
  @run_interval = run_interval
  @additional_properties = additional_properties
  @_field_set = {
    "status": status,
    "id": id,
    "name": name,
    "key": key,
    "rankBy": rank_by,
    "breakdownAttribute": breakdown_attribute,
    "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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#breakdown_attributeString (readonly)

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

Returns:

  • (String)

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



23
24
25
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 23

def breakdown_attribute
  @breakdown_attribute
end

#descriptionString (readonly)

Returns The user-facing description of the leaderboard.

Returns:

  • (String)

    The user-facing description of the leaderboard.



33
34
35
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 33

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.

Returns:

  • (String)

    The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.



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

def end_
  @end_
end

#idString (readonly)

Returns The unique ID of the leaderboard.

Returns:

  • (String)

    The unique ID of the leaderboard.



15
16
17
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 15

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.



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

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.



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

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’.



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

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’.



27
28
29
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 27

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.



17
18
19
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 17

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’.



29
30
31
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 29

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’.



31
32
33
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 31

def points_system_name
  @points_system_name
end

#rank_byTrophyApiClient::LeaderboardResponseRankBy (readonly)

Returns What the leaderboard ranks by.

Returns:



21
22
23
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 21

def rank_by
  @rank_by
end

#run_intervalInteger (readonly)

Returns The interval between repetitions, relative to the start date and repetition type.

Returns:

  • (Integer)

    The interval between repetitions, relative to the start date and repetition type.



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

def run_interval
  @run_interval
end

#run_unitTrophyApiClient::LeaderboardResponseRunUnit (readonly)

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

Returns:



43
44
45
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 43

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.



35
36
37
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 35

def start
  @start
end

#statusTrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus (readonly)

Returns The status of the leaderboard.

Returns:



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

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem

Deserialize a JSON object to an instance of LeaderboardsAllResponseItem

Parameters:

  • json_object (String)

Returns:



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
150
151
152
153
154
155
156
157
158
159
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 121

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  status = parsed_json["status"]
  id = parsed_json["id"]
  name = parsed_json["name"]
  key = parsed_json["key"]
  rank_by = parsed_json["rankBy"]
  breakdown_attribute = parsed_json["breakdownAttribute"]
  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,
    id: id,
    name: name,
    key: key,
    rank_by: rank_by,
    breakdown_attribute: breakdown_attribute,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 174

def self.validate_raw(obj:)
  obj.status.is_a?(TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus) != false || raise("Passed value for field obj.status 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.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 LeaderboardsAllResponseItem to a JSON object

Returns:

  • (String)


164
165
166
# File 'lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb', line 164

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