Class: TrophyApiClient::CreateLeaderboardRequestItem

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

Overview

A leaderboard to create.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, key:, rank_by:, description: OMIT, status: OMIT, metric_id: OMIT, points_system_id: OMIT, max_participants: OMIT, start: OMIT, end_: OMIT, breakdown_attributes: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreateLeaderboardRequestItem

Parameters:

  • name (String)

    The leaderboard name.

  • key (String)

    The leaderboard key. Only alphanumeric characters, hyphens, and underscores are permitted.

  • description (String) (defaults to: OMIT)

    The leaderboard description.

  • status (TrophyApiClient::CreateLeaderboardRequestItemStatus) (defaults to: OMIT)

    The initial user-facing status. Defaults to ‘inactive`. Use `scheduled` for leaderboards that should be active in the future and `finished` only when creating a leaderboard with an end date in the past.

  • rank_by (TrophyApiClient::CreateLeaderboardRequestItemRankBy)

    What the leaderboard ranks by.

  • metric_id (String) (defaults to: OMIT)

    The metric ID to rank by when ‘rankBy` is `metric`.

  • points_system_id (String) (defaults to: OMIT)

    The points system ID to rank by when ‘rankBy` is `points`.

  • max_participants (Integer) (defaults to: OMIT)

    The maximum number of participants. Defaults to ‘1000`.

  • start (String) (defaults to: OMIT)

    The leaderboard start date in YYYY-MM-DD format. Defaults to today when omitted.

  • end_ (String) (defaults to: OMIT)

    The optional leaderboard end date in YYYY-MM-DD format.

  • breakdown_attributes (Array<String>) (defaults to: OMIT)

    The UUIDs of the active user attributes to break rankings down by.

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

    How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak leaderboards cannot repeat.

  • run_interval (Integer) (defaults to: OMIT)

    The number of ‘runUnit`s between repeats. Required when `runUnit` is set.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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
100
101
102
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 69

def initialize(name:, key:, rank_by:, description: OMIT, status: OMIT, metric_id: OMIT, points_system_id: OMIT,
               max_participants: OMIT, start: OMIT, end_: OMIT, breakdown_attributes: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
  @name = name
  @key = key
  @description = description if description != OMIT
  @status = status if status != OMIT
  @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 if max_participants != OMIT
  @start = start if start != OMIT
  @end_ = end_ if end_ != OMIT
  @breakdown_attributes = breakdown_attributes if breakdown_attributes != OMIT
  @run_unit = run_unit if run_unit != OMIT
  @run_interval = run_interval if run_interval != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#breakdown_attributesArray<String> (readonly)

Returns The UUIDs of the active user attributes to break rankings down by.

Returns:

  • (Array<String>)

    The UUIDs of the active user attributes to break rankings down by.



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

def breakdown_attributes
  @breakdown_attributes
end

#descriptionString (readonly)

Returns The leaderboard description.

Returns:

  • (String)

    The leaderboard description.



18
19
20
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 18

def description
  @description
end

#end_String (readonly)

Returns The optional leaderboard end date in YYYY-MM-DD format.

Returns:

  • (String)

    The optional leaderboard end date in YYYY-MM-DD format.



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

def end_
  @end_
end

#keyString (readonly)

Returns The leaderboard key. Only alphanumeric characters, hyphens, and underscores are permitted.

Returns:

  • (String)

    The leaderboard key. Only alphanumeric characters, hyphens, and underscores are permitted.



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

def key
  @key
end

#max_participantsInteger (readonly)

Returns The maximum number of participants. Defaults to ‘1000`.

Returns:

  • (Integer)

    The maximum number of participants. Defaults to ‘1000`.



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

def max_participants
  @max_participants
end

#metric_idString (readonly)

Returns The metric ID to rank by when ‘rankBy` is `metric`.

Returns:

  • (String)

    The metric ID to rank by when ‘rankBy` is `metric`.



26
27
28
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 26

def metric_id
  @metric_id
end

#nameString (readonly)

Returns The leaderboard name.

Returns:

  • (String)

    The leaderboard name.



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

def name
  @name
end

#points_system_idString (readonly)

Returns The points system ID to rank by when ‘rankBy` is `points`.

Returns:

  • (String)

    The points system ID to rank by when ‘rankBy` is `points`.



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

def points_system_id
  @points_system_id
end

#rank_byTrophyApiClient::CreateLeaderboardRequestItemRankBy (readonly)

Returns What the leaderboard ranks by.

Returns:



24
25
26
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 24

def rank_by
  @rank_by
end

#run_intervalInteger (readonly)

Returns The number of ‘runUnit`s between repeats. Required when `runUnit` is set.

Returns:

  • (Integer)

    The number of ‘runUnit`s between repeats. Required when `runUnit` is set.



41
42
43
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 41

def run_interval
  @run_interval
end

#run_unitTrophyApiClient::CreateLeaderboardRequestItemRunUnit (readonly)

Returns How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak leaderboards cannot repeat.

Returns:



39
40
41
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 39

def run_unit
  @run_unit
end

#startString (readonly)

Returns The leaderboard start date in YYYY-MM-DD format. Defaults to today when omitted.

Returns:

  • (String)

    The leaderboard start date in YYYY-MM-DD format. Defaults to today when omitted.



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

def start
  @start
end

#statusTrophyApiClient::CreateLeaderboardRequestItemStatus (readonly)

Returns The initial user-facing status. Defaults to ‘inactive`. Use `scheduled` for leaderboards that should be active in the future and `finished` only when creating a leaderboard with an end date in the past.

Returns:

  • (TrophyApiClient::CreateLeaderboardRequestItemStatus)

    The initial user-facing status. Defaults to ‘inactive`. Use `scheduled` for leaderboards that should be active in the future and `finished` only when creating a leaderboard with an end date in the past.



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

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::CreateLeaderboardRequestItem

Deserialize a JSON object to an instance of CreateLeaderboardRequestItem

Parameters:

  • json_object (String)

Returns:



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
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 108

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  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(
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 155

def self.validate_raw(obj:)
  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::CreateLeaderboardRequestItemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.rank_by.is_a?(TrophyApiClient::CreateLeaderboardRequestItemRankBy) != 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::CreateLeaderboardRequestItemRunUnit) != 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 CreateLeaderboardRequestItem to a JSON object

Returns:

  • (String)


145
146
147
# File 'lib/trophy_api_client/types/create_leaderboard_request_item.rb', line 145

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