|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative "leaderboards_all_response_item_status" |
| 4 | +require_relative "../../types/leaderboard_response_rank_by" |
| 5 | +require_relative "../../types/leaderboard_response_run_unit" |
| 6 | +require "ostruct" |
| 7 | +require "json" |
| 8 | + |
| 9 | +module TrophyApiClient |
| 10 | + class Leaderboards |
| 11 | + class LeaderboardsAllResponseItem |
| 12 | + # @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus] The status of the leaderboard. |
| 13 | + attr_reader :status |
| 14 | + # @return [String] The unique ID of the leaderboard. |
| 15 | + attr_reader :id |
| 16 | + # @return [String] The user-facing name of the leaderboard. |
| 17 | + attr_reader :name |
| 18 | + # @return [String] The unique key used to reference the leaderboard in APIs. |
| 19 | + attr_reader :key |
| 20 | + # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by. |
| 21 | + attr_reader :rank_by |
| 22 | + # @return [String] The key of the metric to rank by, if rankBy is 'metric'. |
| 23 | + attr_reader :metric_key |
| 24 | + # @return [String] The name of the metric to rank by, if rankBy is 'metric'. |
| 25 | + attr_reader :metric_name |
| 26 | + # @return [String] The key of the points system to rank by, if rankBy is 'points'. |
| 27 | + attr_reader :points_system_key |
| 28 | + # @return [String] The name of the points system to rank by, if rankBy is 'points'. |
| 29 | + attr_reader :points_system_name |
| 30 | + # @return [String] The user-facing description of the leaderboard. |
| 31 | + attr_reader :description |
| 32 | + # @return [String] The start date of the leaderboard in YYYY-MM-DD format. |
| 33 | + attr_reader :start |
| 34 | + # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs |
| 35 | + # forever. |
| 36 | + attr_reader :end_ |
| 37 | + # @return [Integer] The maximum number of participants in the leaderboard. |
| 38 | + attr_reader :max_participants |
| 39 | + # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time |
| 40 | + # leaderboards. |
| 41 | + attr_reader :run_unit |
| 42 | + # @return [Integer] The interval between repetitions, relative to the start date and repetition |
| 43 | + # type. |
| 44 | + attr_reader :run_interval |
| 45 | + # @return [OpenStruct] Additional properties unmapped to the current class definition |
| 46 | + attr_reader :additional_properties |
| 47 | + # @return [Object] |
| 48 | + attr_reader :_field_set |
| 49 | + protected :_field_set |
| 50 | + |
| 51 | + OMIT = Object.new |
| 52 | + |
| 53 | + # @param status [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus] The status of the leaderboard. |
| 54 | + # @param id [String] The unique ID of the leaderboard. |
| 55 | + # @param name [String] The user-facing name of the leaderboard. |
| 56 | + # @param key [String] The unique key used to reference the leaderboard in APIs. |
| 57 | + # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by. |
| 58 | + # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'. |
| 59 | + # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'. |
| 60 | + # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'. |
| 61 | + # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'. |
| 62 | + # @param description [String] The user-facing description of the leaderboard. |
| 63 | + # @param start [String] The start date of the leaderboard in YYYY-MM-DD format. |
| 64 | + # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs |
| 65 | + # forever. |
| 66 | + # @param max_participants [Integer] The maximum number of participants in the leaderboard. |
| 67 | + # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time |
| 68 | + # leaderboards. |
| 69 | + # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition |
| 70 | + # type. |
| 71 | + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition |
| 72 | + # @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem] |
| 73 | + def initialize(status:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, |
| 74 | + points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil) |
| 75 | + @status = status |
| 76 | + @id = id |
| 77 | + @name = name |
| 78 | + @key = key |
| 79 | + @rank_by = rank_by |
| 80 | + @metric_key = metric_key if metric_key != OMIT |
| 81 | + @metric_name = metric_name if metric_name != OMIT |
| 82 | + @points_system_key = points_system_key if points_system_key != OMIT |
| 83 | + @points_system_name = points_system_name if points_system_name != OMIT |
| 84 | + @description = description |
| 85 | + @start = start |
| 86 | + @end_ = end_ if end_ != OMIT |
| 87 | + @max_participants = max_participants |
| 88 | + @run_unit = run_unit if run_unit != OMIT |
| 89 | + @run_interval = run_interval |
| 90 | + @additional_properties = additional_properties |
| 91 | + @_field_set = { |
| 92 | + "status": status, |
| 93 | + "id": id, |
| 94 | + "name": name, |
| 95 | + "key": key, |
| 96 | + "rankBy": rank_by, |
| 97 | + "metricKey": metric_key, |
| 98 | + "metricName": metric_name, |
| 99 | + "pointsSystemKey": points_system_key, |
| 100 | + "pointsSystemName": points_system_name, |
| 101 | + "description": description, |
| 102 | + "start": start, |
| 103 | + "end": end_, |
| 104 | + "maxParticipants": max_participants, |
| 105 | + "runUnit": run_unit, |
| 106 | + "runInterval": run_interval |
| 107 | + }.reject do |_k, v| |
| 108 | + v == OMIT |
| 109 | + end |
| 110 | + end |
| 111 | + |
| 112 | + # Deserialize a JSON object to an instance of LeaderboardsAllResponseItem |
| 113 | + # |
| 114 | + # @param json_object [String] |
| 115 | + # @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem] |
| 116 | + def self.from_json(json_object:) |
| 117 | + struct = JSON.parse(json_object, object_class: OpenStruct) |
| 118 | + parsed_json = JSON.parse(json_object) |
| 119 | + status = parsed_json["status"] |
| 120 | + id = parsed_json["id"] |
| 121 | + name = parsed_json["name"] |
| 122 | + key = parsed_json["key"] |
| 123 | + rank_by = parsed_json["rankBy"] |
| 124 | + metric_key = parsed_json["metricKey"] |
| 125 | + metric_name = parsed_json["metricName"] |
| 126 | + points_system_key = parsed_json["pointsSystemKey"] |
| 127 | + points_system_name = parsed_json["pointsSystemName"] |
| 128 | + description = parsed_json["description"] |
| 129 | + start = parsed_json["start"] |
| 130 | + end_ = parsed_json["end"] |
| 131 | + max_participants = parsed_json["maxParticipants"] |
| 132 | + run_unit = parsed_json["runUnit"] |
| 133 | + run_interval = parsed_json["runInterval"] |
| 134 | + new( |
| 135 | + status: status, |
| 136 | + id: id, |
| 137 | + name: name, |
| 138 | + key: key, |
| 139 | + rank_by: rank_by, |
| 140 | + metric_key: metric_key, |
| 141 | + metric_name: metric_name, |
| 142 | + points_system_key: points_system_key, |
| 143 | + points_system_name: points_system_name, |
| 144 | + description: description, |
| 145 | + start: start, |
| 146 | + end_: end_, |
| 147 | + max_participants: max_participants, |
| 148 | + run_unit: run_unit, |
| 149 | + run_interval: run_interval, |
| 150 | + additional_properties: struct |
| 151 | + ) |
| 152 | + end |
| 153 | + |
| 154 | + # Serialize an instance of LeaderboardsAllResponseItem to a JSON object |
| 155 | + # |
| 156 | + # @return [String] |
| 157 | + def to_json(*_args) |
| 158 | + @_field_set&.to_json |
| 159 | + end |
| 160 | + |
| 161 | + # Leveraged for Union-type generation, validate_raw attempts to parse the given |
| 162 | + # hash and check each fields type against the current object's property |
| 163 | + # definitions. |
| 164 | + # |
| 165 | + # @param obj [Object] |
| 166 | + # @return [Void] |
| 167 | + def self.validate_raw(obj:) |
| 168 | + obj.status.is_a?(TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") |
| 169 | + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") |
| 170 | + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") |
| 171 | + obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.") |
| 172 | + obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.") |
| 173 | + obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.") |
| 174 | + obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.") |
| 175 | + obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.") |
| 176 | + obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.") |
| 177 | + obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") |
| 178 | + obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.") |
| 179 | + obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.") |
| 180 | + obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.") |
| 181 | + obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.") |
| 182 | + obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.") |
| 183 | + end |
| 184 | + end |
| 185 | + end |
| 186 | +end |
0 commit comments