trophy_api_client 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,184 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_response_status"
4
+ require_relative "leaderboard_response_rank_by"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ # A leaderboard with its configuration details.
10
+ class LeaderboardResponse
11
+ # @return [String] The unique ID of the leaderboard.
12
+ attr_reader :id
13
+ # @return [String] The user-facing name of the leaderboard.
14
+ attr_reader :name
15
+ # @return [String] The unique key used to reference the leaderboard in APIs.
16
+ attr_reader :key
17
+ # @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
18
+ attr_reader :status
19
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
20
+ attr_reader :rank_by
21
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
22
+ attr_reader :metric_key
23
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
24
+ attr_reader :metric_name
25
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
26
+ attr_reader :points_system_key
27
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
28
+ attr_reader :points_system_name
29
+ # @return [String] The user-facing description of the leaderboard.
30
+ attr_reader :description
31
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
32
+ attr_reader :start
33
+ # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
34
+ # forever.
35
+ attr_reader :end_
36
+ # @return [Integer] The maximum number of participants in the leaderboard.
37
+ attr_reader :max_participants
38
+ # @return [String] The repetition type for recurring leaderboards, or null for one-time
39
+ # leaderboards.
40
+ attr_reader :run_unit
41
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
42
+ # type.
43
+ attr_reader :run_interval
44
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
45
+ attr_reader :additional_properties
46
+ # @return [Object]
47
+ attr_reader :_field_set
48
+ protected :_field_set
49
+
50
+ OMIT = Object.new
51
+
52
+ # @param id [String] The unique ID of the leaderboard.
53
+ # @param name [String] The user-facing name of the leaderboard.
54
+ # @param key [String] The unique key used to reference the leaderboard in APIs.
55
+ # @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
56
+ # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
57
+ # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
58
+ # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
59
+ # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
60
+ # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
61
+ # @param description [String] The user-facing description of the leaderboard.
62
+ # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
63
+ # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
64
+ # forever.
65
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
66
+ # @param run_unit [String] The repetition type for recurring leaderboards, or null for one-time
67
+ # leaderboards.
68
+ # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
69
+ # type.
70
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
71
+ # @return [TrophyApiClient::LeaderboardResponse]
72
+ def initialize(id:, name:, key:, rank_by:, start:, max_participants:, run_interval:, status: OMIT, metric_key: OMIT, metric_name: OMIT,
73
+ points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
74
+ @id = id
75
+ @name = name
76
+ @key = key
77
+ @status = status if status != OMIT
78
+ @rank_by = rank_by
79
+ @metric_key = metric_key if metric_key != OMIT
80
+ @metric_name = metric_name if metric_name != OMIT
81
+ @points_system_key = points_system_key if points_system_key != OMIT
82
+ @points_system_name = points_system_name if points_system_name != OMIT
83
+ @description = description if description != OMIT
84
+ @start = start
85
+ @end_ = end_ if end_ != OMIT
86
+ @max_participants = max_participants
87
+ @run_unit = run_unit if run_unit != OMIT
88
+ @run_interval = run_interval
89
+ @additional_properties = additional_properties
90
+ @_field_set = {
91
+ "id": id,
92
+ "name": name,
93
+ "key": key,
94
+ "status": status,
95
+ "rankBy": rank_by,
96
+ "metricKey": metric_key,
97
+ "metricName": metric_name,
98
+ "pointsSystemKey": points_system_key,
99
+ "pointsSystemName": points_system_name,
100
+ "description": description,
101
+ "start": start,
102
+ "end": end_,
103
+ "maxParticipants": max_participants,
104
+ "runUnit": run_unit,
105
+ "runInterval": run_interval
106
+ }.reject do |_k, v|
107
+ v == OMIT
108
+ end
109
+ end
110
+
111
+ # Deserialize a JSON object to an instance of LeaderboardResponse
112
+ #
113
+ # @param json_object [String]
114
+ # @return [TrophyApiClient::LeaderboardResponse]
115
+ def self.from_json(json_object:)
116
+ struct = JSON.parse(json_object, object_class: OpenStruct)
117
+ parsed_json = JSON.parse(json_object)
118
+ id = parsed_json["id"]
119
+ name = parsed_json["name"]
120
+ key = parsed_json["key"]
121
+ status = parsed_json["status"]
122
+ rank_by = parsed_json["rankBy"]
123
+ metric_key = parsed_json["metricKey"]
124
+ metric_name = parsed_json["metricName"]
125
+ points_system_key = parsed_json["pointsSystemKey"]
126
+ points_system_name = parsed_json["pointsSystemName"]
127
+ description = parsed_json["description"]
128
+ start = parsed_json["start"]
129
+ end_ = parsed_json["end"]
130
+ max_participants = parsed_json["maxParticipants"]
131
+ run_unit = parsed_json["runUnit"]
132
+ run_interval = parsed_json["runInterval"]
133
+ new(
134
+ id: id,
135
+ name: name,
136
+ key: key,
137
+ status: status,
138
+ rank_by: rank_by,
139
+ metric_key: metric_key,
140
+ metric_name: metric_name,
141
+ points_system_key: points_system_key,
142
+ points_system_name: points_system_name,
143
+ description: description,
144
+ start: start,
145
+ end_: end_,
146
+ max_participants: max_participants,
147
+ run_unit: run_unit,
148
+ run_interval: run_interval,
149
+ additional_properties: struct
150
+ )
151
+ end
152
+
153
+ # Serialize an instance of LeaderboardResponse to a JSON object
154
+ #
155
+ # @return [String]
156
+ def to_json(*_args)
157
+ @_field_set&.to_json
158
+ end
159
+
160
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
161
+ # hash and check each fields type against the current object's property
162
+ # definitions.
163
+ #
164
+ # @param obj [Object]
165
+ # @return [Void]
166
+ def self.validate_raw(obj:)
167
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
168
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
169
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
170
+ obj.status&.is_a?(TrophyApiClient::LeaderboardResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
171
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
172
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
173
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
174
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
175
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
176
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
177
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
178
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
179
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
180
+ obj.run_unit&.is_a?(String) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
181
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # What the leaderboard ranks by.
5
+ class LeaderboardResponseRankBy
6
+ POINTS = "points"
7
+ STREAK = "streak"
8
+ METRIC = "metric"
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The status of the leaderboard.
5
+ class LeaderboardResponseStatus
6
+ ACTIVE = "active"
7
+ SCHEDULED = "scheduled"
8
+ FINISHED = "finished"
9
+ end
10
+ end
@@ -0,0 +1,195 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_ranking"
4
+ require_relative "leaderboard_response_status"
5
+ require_relative "leaderboard_response_rank_by"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module TrophyApiClient
10
+ class LeaderboardResponseWithRankings
11
+ # @return [Array<TrophyApiClient::LeaderboardRanking>] Array of user rankings for the leaderboard.
12
+ attr_reader :rankings
13
+ # @return [String] The unique ID of the leaderboard.
14
+ attr_reader :id
15
+ # @return [String] The user-facing name of the leaderboard.
16
+ attr_reader :name
17
+ # @return [String] The unique key used to reference the leaderboard in APIs.
18
+ attr_reader :key
19
+ # @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
20
+ attr_reader :status
21
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
22
+ attr_reader :rank_by
23
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
24
+ attr_reader :metric_key
25
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
26
+ attr_reader :metric_name
27
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
28
+ attr_reader :points_system_key
29
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
30
+ attr_reader :points_system_name
31
+ # @return [String] The user-facing description of the leaderboard.
32
+ attr_reader :description
33
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
34
+ attr_reader :start
35
+ # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
36
+ # forever.
37
+ attr_reader :end_
38
+ # @return [Integer] The maximum number of participants in the leaderboard.
39
+ attr_reader :max_participants
40
+ # @return [String] The repetition type for recurring leaderboards, or null for one-time
41
+ # leaderboards.
42
+ attr_reader :run_unit
43
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
44
+ # type.
45
+ attr_reader :run_interval
46
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
47
+ attr_reader :additional_properties
48
+ # @return [Object]
49
+ attr_reader :_field_set
50
+ protected :_field_set
51
+
52
+ OMIT = Object.new
53
+
54
+ # @param rankings [Array<TrophyApiClient::LeaderboardRanking>] Array of user rankings for the leaderboard.
55
+ # @param id [String] The unique ID of the leaderboard.
56
+ # @param name [String] The user-facing name of the leaderboard.
57
+ # @param key [String] The unique key used to reference the leaderboard in APIs.
58
+ # @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
59
+ # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
60
+ # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
61
+ # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
62
+ # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
63
+ # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
64
+ # @param description [String] The user-facing description of the leaderboard.
65
+ # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
66
+ # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
67
+ # forever.
68
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
69
+ # @param run_unit [String] The repetition type for recurring leaderboards, or null for one-time
70
+ # leaderboards.
71
+ # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
72
+ # type.
73
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
74
+ # @return [TrophyApiClient::LeaderboardResponseWithRankings]
75
+ def initialize(rankings:, id:, name:, key:, rank_by:, start:, max_participants:, run_interval:, status: OMIT, metric_key: OMIT, metric_name: OMIT,
76
+ points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
77
+ @rankings = rankings
78
+ @id = id
79
+ @name = name
80
+ @key = key
81
+ @status = status if status != OMIT
82
+ @rank_by = rank_by
83
+ @metric_key = metric_key if metric_key != OMIT
84
+ @metric_name = metric_name if metric_name != OMIT
85
+ @points_system_key = points_system_key if points_system_key != OMIT
86
+ @points_system_name = points_system_name if points_system_name != OMIT
87
+ @description = description if description != OMIT
88
+ @start = start
89
+ @end_ = end_ if end_ != OMIT
90
+ @max_participants = max_participants
91
+ @run_unit = run_unit if run_unit != OMIT
92
+ @run_interval = run_interval
93
+ @additional_properties = additional_properties
94
+ @_field_set = {
95
+ "rankings": rankings,
96
+ "id": id,
97
+ "name": name,
98
+ "key": key,
99
+ "status": status,
100
+ "rankBy": rank_by,
101
+ "metricKey": metric_key,
102
+ "metricName": metric_name,
103
+ "pointsSystemKey": points_system_key,
104
+ "pointsSystemName": points_system_name,
105
+ "description": description,
106
+ "start": start,
107
+ "end": end_,
108
+ "maxParticipants": max_participants,
109
+ "runUnit": run_unit,
110
+ "runInterval": run_interval
111
+ }.reject do |_k, v|
112
+ v == OMIT
113
+ end
114
+ end
115
+
116
+ # Deserialize a JSON object to an instance of LeaderboardResponseWithRankings
117
+ #
118
+ # @param json_object [String]
119
+ # @return [TrophyApiClient::LeaderboardResponseWithRankings]
120
+ def self.from_json(json_object:)
121
+ struct = JSON.parse(json_object, object_class: OpenStruct)
122
+ parsed_json = JSON.parse(json_object)
123
+ rankings = parsed_json["rankings"]&.map do |item|
124
+ item = item.to_json
125
+ TrophyApiClient::LeaderboardRanking.from_json(json_object: item)
126
+ end
127
+ id = parsed_json["id"]
128
+ name = parsed_json["name"]
129
+ key = parsed_json["key"]
130
+ status = parsed_json["status"]
131
+ rank_by = parsed_json["rankBy"]
132
+ metric_key = parsed_json["metricKey"]
133
+ metric_name = parsed_json["metricName"]
134
+ points_system_key = parsed_json["pointsSystemKey"]
135
+ points_system_name = parsed_json["pointsSystemName"]
136
+ description = parsed_json["description"]
137
+ start = parsed_json["start"]
138
+ end_ = parsed_json["end"]
139
+ max_participants = parsed_json["maxParticipants"]
140
+ run_unit = parsed_json["runUnit"]
141
+ run_interval = parsed_json["runInterval"]
142
+ new(
143
+ rankings: rankings,
144
+ id: id,
145
+ name: name,
146
+ key: key,
147
+ status: status,
148
+ rank_by: rank_by,
149
+ metric_key: metric_key,
150
+ metric_name: metric_name,
151
+ points_system_key: points_system_key,
152
+ points_system_name: points_system_name,
153
+ description: description,
154
+ start: start,
155
+ end_: end_,
156
+ max_participants: max_participants,
157
+ run_unit: run_unit,
158
+ run_interval: run_interval,
159
+ additional_properties: struct
160
+ )
161
+ end
162
+
163
+ # Serialize an instance of LeaderboardResponseWithRankings to a JSON object
164
+ #
165
+ # @return [String]
166
+ def to_json(*_args)
167
+ @_field_set&.to_json
168
+ end
169
+
170
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
171
+ # hash and check each fields type against the current object's property
172
+ # definitions.
173
+ #
174
+ # @param obj [Object]
175
+ # @return [Void]
176
+ def self.validate_raw(obj:)
177
+ obj.rankings.is_a?(Array) != false || raise("Passed value for field obj.rankings is not the expected type, validation failed.")
178
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
179
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
180
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
181
+ obj.status&.is_a?(TrophyApiClient::LeaderboardResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
182
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
183
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
184
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
185
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
186
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
187
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
188
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
189
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
190
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
191
+ obj.run_unit&.is_a?(String) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
192
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
193
+ end
194
+ end
195
+ end
@@ -0,0 +1,213 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_response_status"
4
+ require_relative "leaderboard_response_rank_by"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ class MetricEventLeaderboardResponse
10
+ # @return [String] The end date of the current run of the leaderboard, or null if the run never
11
+ # ends.
12
+ attr_reader :end_
13
+ # @return [Integer] The user's rank in the leaderboard, or null if the user is not on the
14
+ # leaderboard.
15
+ attr_reader :rank
16
+ # @return [Integer] The user's rank in the leaderboard before the event, or null if the user was not
17
+ # on the leaderboard before the event.
18
+ attr_reader :previous_rank
19
+ # @return [Float] The minimum value required to enter the leaderboard according to its current
20
+ # rankings.
21
+ attr_reader :threshold
22
+ # @return [String] The unique ID of the leaderboard.
23
+ attr_reader :id
24
+ # @return [String] The user-facing name of the leaderboard.
25
+ attr_reader :name
26
+ # @return [String] The unique key used to reference the leaderboard in APIs.
27
+ attr_reader :key
28
+ # @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
29
+ attr_reader :status
30
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
31
+ attr_reader :rank_by
32
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
33
+ attr_reader :metric_key
34
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
35
+ attr_reader :metric_name
36
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
37
+ attr_reader :points_system_key
38
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
39
+ attr_reader :points_system_name
40
+ # @return [String] The user-facing description of the leaderboard.
41
+ attr_reader :description
42
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
43
+ attr_reader :start
44
+ # @return [Integer] The maximum number of participants in the leaderboard.
45
+ attr_reader :max_participants
46
+ # @return [String] The repetition type for recurring leaderboards, or null for one-time
47
+ # leaderboards.
48
+ attr_reader :run_unit
49
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
50
+ # type.
51
+ attr_reader :run_interval
52
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
53
+ attr_reader :additional_properties
54
+ # @return [Object]
55
+ attr_reader :_field_set
56
+ protected :_field_set
57
+
58
+ OMIT = Object.new
59
+
60
+ # @param end_ [String] The end date of the current run of the leaderboard, or null if the run never
61
+ # ends.
62
+ # @param rank [Integer] The user's rank in the leaderboard, or null if the user is not on the
63
+ # leaderboard.
64
+ # @param previous_rank [Integer] The user's rank in the leaderboard before the event, or null if the user was not
65
+ # on the leaderboard before the event.
66
+ # @param threshold [Float] The minimum value required to enter the leaderboard according to its current
67
+ # rankings.
68
+ # @param id [String] The unique ID of the leaderboard.
69
+ # @param name [String] The user-facing name of the leaderboard.
70
+ # @param key [String] The unique key used to reference the leaderboard in APIs.
71
+ # @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
72
+ # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
73
+ # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
74
+ # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
75
+ # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
76
+ # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
77
+ # @param description [String] The user-facing description of the leaderboard.
78
+ # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
79
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
80
+ # @param run_unit [String] The repetition type for recurring leaderboards, or null for one-time
81
+ # leaderboards.
82
+ # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
83
+ # type.
84
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
85
+ # @return [TrophyApiClient::MetricEventLeaderboardResponse]
86
+ def initialize(threshold:, id:, name:, key:, rank_by:, start:, max_participants:, run_interval:, end_: OMIT, rank: OMIT, previous_rank: OMIT, status: OMIT,
87
+ metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, run_unit: OMIT, additional_properties: nil)
88
+ @end_ = end_ if end_ != OMIT
89
+ @rank = rank if rank != OMIT
90
+ @previous_rank = previous_rank if previous_rank != OMIT
91
+ @threshold = threshold
92
+ @id = id
93
+ @name = name
94
+ @key = key
95
+ @status = status if status != OMIT
96
+ @rank_by = rank_by
97
+ @metric_key = metric_key if metric_key != OMIT
98
+ @metric_name = metric_name if metric_name != OMIT
99
+ @points_system_key = points_system_key if points_system_key != OMIT
100
+ @points_system_name = points_system_name if points_system_name != OMIT
101
+ @description = description if description != OMIT
102
+ @start = start
103
+ @max_participants = max_participants
104
+ @run_unit = run_unit if run_unit != OMIT
105
+ @run_interval = run_interval
106
+ @additional_properties = additional_properties
107
+ @_field_set = {
108
+ "end": end_,
109
+ "rank": rank,
110
+ "previousRank": previous_rank,
111
+ "threshold": threshold,
112
+ "id": id,
113
+ "name": name,
114
+ "key": key,
115
+ "status": status,
116
+ "rankBy": rank_by,
117
+ "metricKey": metric_key,
118
+ "metricName": metric_name,
119
+ "pointsSystemKey": points_system_key,
120
+ "pointsSystemName": points_system_name,
121
+ "description": description,
122
+ "start": start,
123
+ "maxParticipants": max_participants,
124
+ "runUnit": run_unit,
125
+ "runInterval": run_interval
126
+ }.reject do |_k, v|
127
+ v == OMIT
128
+ end
129
+ end
130
+
131
+ # Deserialize a JSON object to an instance of MetricEventLeaderboardResponse
132
+ #
133
+ # @param json_object [String]
134
+ # @return [TrophyApiClient::MetricEventLeaderboardResponse]
135
+ def self.from_json(json_object:)
136
+ struct = JSON.parse(json_object, object_class: OpenStruct)
137
+ parsed_json = JSON.parse(json_object)
138
+ end_ = parsed_json["end"]
139
+ rank = parsed_json["rank"]
140
+ previous_rank = parsed_json["previousRank"]
141
+ threshold = parsed_json["threshold"]
142
+ id = parsed_json["id"]
143
+ name = parsed_json["name"]
144
+ key = parsed_json["key"]
145
+ status = parsed_json["status"]
146
+ rank_by = parsed_json["rankBy"]
147
+ metric_key = parsed_json["metricKey"]
148
+ metric_name = parsed_json["metricName"]
149
+ points_system_key = parsed_json["pointsSystemKey"]
150
+ points_system_name = parsed_json["pointsSystemName"]
151
+ description = parsed_json["description"]
152
+ start = parsed_json["start"]
153
+ max_participants = parsed_json["maxParticipants"]
154
+ run_unit = parsed_json["runUnit"]
155
+ run_interval = parsed_json["runInterval"]
156
+ new(
157
+ end_: end_,
158
+ rank: rank,
159
+ previous_rank: previous_rank,
160
+ threshold: threshold,
161
+ id: id,
162
+ name: name,
163
+ key: key,
164
+ status: status,
165
+ rank_by: rank_by,
166
+ metric_key: metric_key,
167
+ metric_name: metric_name,
168
+ points_system_key: points_system_key,
169
+ points_system_name: points_system_name,
170
+ description: description,
171
+ start: start,
172
+ max_participants: max_participants,
173
+ run_unit: run_unit,
174
+ run_interval: run_interval,
175
+ additional_properties: struct
176
+ )
177
+ end
178
+
179
+ # Serialize an instance of MetricEventLeaderboardResponse to a JSON object
180
+ #
181
+ # @return [String]
182
+ def to_json(*_args)
183
+ @_field_set&.to_json
184
+ end
185
+
186
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
187
+ # hash and check each fields type against the current object's property
188
+ # definitions.
189
+ #
190
+ # @param obj [Object]
191
+ # @return [Void]
192
+ def self.validate_raw(obj:)
193
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
194
+ obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
195
+ obj.previous_rank&.is_a?(Integer) != false || raise("Passed value for field obj.previous_rank is not the expected type, validation failed.")
196
+ obj.threshold.is_a?(Float) != false || raise("Passed value for field obj.threshold is not the expected type, validation failed.")
197
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
198
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
199
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
200
+ obj.status&.is_a?(TrophyApiClient::LeaderboardResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
201
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
202
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
203
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
204
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
205
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
206
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
207
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
208
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
209
+ obj.run_unit&.is_a?(String) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
210
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
211
+ end
212
+ end
213
+ end