trophy_api_client 1.0.29 → 1.0.31

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/achievements/client.rb +20 -12
  4. data/lib/trophy_api_client/leaderboards/client.rb +25 -11
  5. data/lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb +194 -0
  6. data/lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item_status.rb +12 -0
  7. data/lib/trophy_api_client/metrics/client.rb +2 -2
  8. data/lib/trophy_api_client/points/client.rb +4 -4
  9. data/lib/trophy_api_client/streaks/client.rb +2 -2
  10. data/lib/trophy_api_client/types/achievement_completion_response.rb +9 -11
  11. data/lib/trophy_api_client/types/achievement_completion_response_achievement.rb +171 -0
  12. data/lib/trophy_api_client/types/achievement_response.rb +5 -19
  13. data/lib/trophy_api_client/types/achievement_with_stats_response.rb +9 -23
  14. data/lib/trophy_api_client/types/bulk_streak_response_item.rb +4 -6
  15. data/lib/trophy_api_client/types/completed_achievement_response.rb +7 -21
  16. data/lib/trophy_api_client/types/event_response.rb +10 -10
  17. data/lib/trophy_api_client/types/get_user_points_response.rb +21 -4
  18. data/lib/trophy_api_client/types/leaderboard_response.rb +16 -16
  19. data/lib/trophy_api_client/types/leaderboard_response_run_unit.rb +11 -0
  20. data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +25 -16
  21. data/lib/trophy_api_client/types/{leaderboard_response_status.rb → leaderboard_response_with_rankings_status.rb} +1 -1
  22. data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +29 -19
  23. data/lib/trophy_api_client/types/metric_event_points_response.rb +24 -8
  24. data/lib/trophy_api_client/types/metric_event_streak_response.rb +4 -4
  25. data/lib/trophy_api_client/types/points_award.rb +6 -6
  26. data/lib/trophy_api_client/types/points_range.rb +14 -16
  27. data/lib/trophy_api_client/types/points_system_response.rb +10 -1
  28. data/lib/trophy_api_client/types/points_trigger.rb +30 -11
  29. data/lib/trophy_api_client/types/points_trigger_response.rb +39 -22
  30. data/lib/trophy_api_client/types/points_trigger_response_time_unit.rb +9 -0
  31. data/lib/trophy_api_client/types/points_trigger_response_type.rb +2 -0
  32. data/lib/trophy_api_client/types/points_trigger_time_unit.rb +9 -0
  33. data/lib/trophy_api_client/types/points_trigger_type.rb +2 -0
  34. data/lib/trophy_api_client/types/updated_user.rb +11 -11
  35. data/lib/trophy_api_client/types/upserted_user.rb +12 -12
  36. data/lib/trophy_api_client/types/user.rb +18 -18
  37. data/lib/trophy_api_client/types/user_leaderboard_response.rb +16 -28
  38. data/lib/trophy_api_client/types/user_leaderboard_response_with_history.rb +216 -0
  39. data/lib/trophy_api_client/types/webhook_user_leaderboard_response.rb +220 -0
  40. data/lib/trophy_api_client/types/webhooks_achievement_completed_payload.rb +84 -0
  41. data/lib/trophy_api_client/types/webhooks_leaderboard_changed_payload.rb +71 -0
  42. data/lib/trophy_api_client/types/webhooks_leaderboard_finished_payload.rb +71 -0
  43. data/lib/trophy_api_client/types/webhooks_leaderboard_rank_changed_payload.rb +85 -0
  44. data/lib/trophy_api_client/types/webhooks_leaderboard_started_payload.rb +71 -0
  45. data/lib/trophy_api_client/types/webhooks_points_changed_payload.rb +84 -0
  46. data/lib/trophy_api_client/types/webhooks_streak_extended_payload.rb +84 -0
  47. data/lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb +85 -0
  48. data/lib/trophy_api_client/types/webhooks_streak_freeze_earned_payload.rb +85 -0
  49. data/lib/trophy_api_client/types/webhooks_streak_lost_payload.rb +78 -0
  50. data/lib/trophy_api_client/types/webhooks_streak_started_payload.rb +84 -0
  51. data/lib/trophy_api_client/users/client.rb +25 -17
  52. data/lib/trophy_api_client/version.rb +1 -1
  53. data/lib/types_export.rb +20 -1
  54. metadata +21 -2
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "leaderboard_event"
4
- require_relative "leaderboard_response_status"
5
3
  require_relative "leaderboard_response_rank_by"
4
+ require_relative "leaderboard_response_run_unit"
6
5
  require "ostruct"
7
6
  require "json"
8
7
 
@@ -15,18 +14,16 @@ module TrophyApiClient
15
14
  # @return [Integer] The user's current value in this leaderboard. Null if the user is not on the
16
15
  # leaderboard.
17
16
  attr_reader :value
18
- # @return [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
19
- attr_reader :history
20
17
  # @return [String] The unique ID of the leaderboard.
21
18
  attr_reader :id
22
19
  # @return [String] The user-facing name of the leaderboard.
23
20
  attr_reader :name
24
21
  # @return [String] The unique key used to reference the leaderboard in APIs.
25
22
  attr_reader :key
26
- # @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
27
- attr_reader :status
28
23
  # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
29
24
  attr_reader :rank_by
25
+ # @return [String] The key of the attribute to break down this leaderboard by.
26
+ attr_reader :breakdown_attribute
30
27
  # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
31
28
  attr_reader :metric_key
32
29
  # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -44,7 +41,7 @@ module TrophyApiClient
44
41
  attr_reader :end_
45
42
  # @return [Integer] The maximum number of participants in the leaderboard.
46
43
  attr_reader :max_participants
47
- # @return [String] The repetition type for recurring leaderboards, or null for one-time
44
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
48
45
  # leaderboards.
49
46
  attr_reader :run_unit
50
47
  # @return [Integer] The interval between repetitions, relative to the start date and repetition
@@ -62,12 +59,11 @@ module TrophyApiClient
62
59
  # leaderboard.
63
60
  # @param value [Integer] The user's current value in this leaderboard. Null if the user is not on the
64
61
  # leaderboard.
65
- # @param history [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
66
62
  # @param id [String] The unique ID of the leaderboard.
67
63
  # @param name [String] The user-facing name of the leaderboard.
68
64
  # @param key [String] The unique key used to reference the leaderboard in APIs.
69
- # @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
70
65
  # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
66
+ # @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
71
67
  # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
72
68
  # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
73
69
  # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -77,27 +73,26 @@ module TrophyApiClient
77
73
  # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
78
74
  # forever.
79
75
  # @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
76
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
81
77
  # leaderboards.
82
78
  # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
83
79
  # type.
84
80
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
85
81
  # @return [TrophyApiClient::UserLeaderboardResponse]
86
- def initialize(history:, id:, name:, key:, rank_by:, start:, max_participants:, run_interval:, rank: OMIT, value: OMIT, status: OMIT, metric_key: OMIT,
87
- metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
82
+ def initialize(id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, rank: OMIT, value: OMIT, breakdown_attribute: OMIT, metric_key: OMIT,
83
+ metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
88
84
  @rank = rank if rank != OMIT
89
85
  @value = value if value != OMIT
90
- @history = history
91
86
  @id = id
92
87
  @name = name
93
88
  @key = key
94
- @status = status if status != OMIT
95
89
  @rank_by = rank_by
90
+ @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
96
91
  @metric_key = metric_key if metric_key != OMIT
97
92
  @metric_name = metric_name if metric_name != OMIT
98
93
  @points_system_key = points_system_key if points_system_key != OMIT
99
94
  @points_system_name = points_system_name if points_system_name != OMIT
100
- @description = description if description != OMIT
95
+ @description = description
101
96
  @start = start
102
97
  @end_ = end_ if end_ != OMIT
103
98
  @max_participants = max_participants
@@ -107,12 +102,11 @@ module TrophyApiClient
107
102
  @_field_set = {
108
103
  "rank": rank,
109
104
  "value": value,
110
- "history": history,
111
105
  "id": id,
112
106
  "name": name,
113
107
  "key": key,
114
- "status": status,
115
108
  "rankBy": rank_by,
109
+ "breakdownAttribute": breakdown_attribute,
116
110
  "metricKey": metric_key,
117
111
  "metricName": metric_name,
118
112
  "pointsSystemKey": points_system_key,
@@ -137,15 +131,11 @@ module TrophyApiClient
137
131
  parsed_json = JSON.parse(json_object)
138
132
  rank = parsed_json["rank"]
139
133
  value = parsed_json["value"]
140
- history = parsed_json["history"]&.map do |item|
141
- item = item.to_json
142
- TrophyApiClient::LeaderboardEvent.from_json(json_object: item)
143
- end
144
134
  id = parsed_json["id"]
145
135
  name = parsed_json["name"]
146
136
  key = parsed_json["key"]
147
- status = parsed_json["status"]
148
137
  rank_by = parsed_json["rankBy"]
138
+ breakdown_attribute = parsed_json["breakdownAttribute"]
149
139
  metric_key = parsed_json["metricKey"]
150
140
  metric_name = parsed_json["metricName"]
151
141
  points_system_key = parsed_json["pointsSystemKey"]
@@ -159,12 +149,11 @@ module TrophyApiClient
159
149
  new(
160
150
  rank: rank,
161
151
  value: value,
162
- history: history,
163
152
  id: id,
164
153
  name: name,
165
154
  key: key,
166
- status: status,
167
155
  rank_by: rank_by,
156
+ breakdown_attribute: breakdown_attribute,
168
157
  metric_key: metric_key,
169
158
  metric_name: metric_name,
170
159
  points_system_key: points_system_key,
@@ -195,21 +184,20 @@ module TrophyApiClient
195
184
  def self.validate_raw(obj:)
196
185
  obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
197
186
  obj.value&.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
198
- obj.history.is_a?(Array) != false || raise("Passed value for field obj.history is not the expected type, validation failed.")
199
187
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
200
188
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
201
189
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
202
- obj.status&.is_a?(TrophyApiClient::LeaderboardResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
203
190
  obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
191
+ obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
204
192
  obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
205
193
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
206
194
  obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
207
195
  obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
208
- obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
196
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
209
197
  obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
210
198
  obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
211
199
  obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
212
- obj.run_unit&.is_a?(String) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
200
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
213
201
  obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
214
202
  end
215
203
  end
@@ -0,0 +1,216 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_event"
4
+ require_relative "leaderboard_response_rank_by"
5
+ require_relative "leaderboard_response_run_unit"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module TrophyApiClient
10
+ # A user's data for a specific leaderboard including rank, value, and history.
11
+ class UserLeaderboardResponseWithHistory
12
+ # @return [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
13
+ attr_reader :history
14
+ # @return [Integer] The user's current rank in this leaderboard. Null if the user is not on the
15
+ # leaderboard.
16
+ attr_reader :rank
17
+ # @return [Integer] The user's current value in this leaderboard. Null if the user is not on the
18
+ # leaderboard.
19
+ attr_reader :value
20
+ # @return [String] The unique ID of the leaderboard.
21
+ attr_reader :id
22
+ # @return [String] The user-facing name of the leaderboard.
23
+ attr_reader :name
24
+ # @return [String] The unique key used to reference the leaderboard in APIs.
25
+ attr_reader :key
26
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
27
+ attr_reader :rank_by
28
+ # @return [String] The key of the attribute to break down this leaderboard by.
29
+ attr_reader :breakdown_attribute
30
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
31
+ attr_reader :metric_key
32
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
33
+ attr_reader :metric_name
34
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
35
+ attr_reader :points_system_key
36
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
37
+ attr_reader :points_system_name
38
+ # @return [String] The user-facing description of the leaderboard.
39
+ attr_reader :description
40
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
41
+ attr_reader :start
42
+ # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
43
+ # forever.
44
+ attr_reader :end_
45
+ # @return [Integer] The maximum number of participants in the leaderboard.
46
+ attr_reader :max_participants
47
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
48
+ # leaderboards.
49
+ attr_reader :run_unit
50
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
51
+ # type.
52
+ attr_reader :run_interval
53
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
54
+ attr_reader :additional_properties
55
+ # @return [Object]
56
+ attr_reader :_field_set
57
+ protected :_field_set
58
+
59
+ OMIT = Object.new
60
+
61
+ # @param history [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
62
+ # @param rank [Integer] The user's current rank in this leaderboard. Null if the user is not on the
63
+ # leaderboard.
64
+ # @param value [Integer] The user's current value in this leaderboard. Null if the user is not on the
65
+ # leaderboard.
66
+ # @param id [String] The unique ID of the leaderboard.
67
+ # @param name [String] The user-facing name of the leaderboard.
68
+ # @param key [String] The unique key used to reference the leaderboard in APIs.
69
+ # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
70
+ # @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
71
+ # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
72
+ # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
73
+ # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
74
+ # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
75
+ # @param description [String] The user-facing description of the leaderboard.
76
+ # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
77
+ # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
78
+ # forever.
79
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
80
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] 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::UserLeaderboardResponseWithHistory]
86
+ def initialize(history:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, rank: OMIT, value: OMIT, breakdown_attribute: OMIT,
87
+ metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
88
+ @history = history
89
+ @rank = rank if rank != OMIT
90
+ @value = value if value != OMIT
91
+ @id = id
92
+ @name = name
93
+ @key = key
94
+ @rank_by = rank_by
95
+ @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
96
+ @metric_key = metric_key if metric_key != OMIT
97
+ @metric_name = metric_name if metric_name != OMIT
98
+ @points_system_key = points_system_key if points_system_key != OMIT
99
+ @points_system_name = points_system_name if points_system_name != OMIT
100
+ @description = description
101
+ @start = start
102
+ @end_ = end_ if end_ != OMIT
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
+ "history": history,
109
+ "rank": rank,
110
+ "value": value,
111
+ "id": id,
112
+ "name": name,
113
+ "key": key,
114
+ "rankBy": rank_by,
115
+ "breakdownAttribute": breakdown_attribute,
116
+ "metricKey": metric_key,
117
+ "metricName": metric_name,
118
+ "pointsSystemKey": points_system_key,
119
+ "pointsSystemName": points_system_name,
120
+ "description": description,
121
+ "start": start,
122
+ "end": end_,
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 UserLeaderboardResponseWithHistory
132
+ #
133
+ # @param json_object [String]
134
+ # @return [TrophyApiClient::UserLeaderboardResponseWithHistory]
135
+ def self.from_json(json_object:)
136
+ struct = JSON.parse(json_object, object_class: OpenStruct)
137
+ parsed_json = JSON.parse(json_object)
138
+ history = parsed_json["history"]&.map do |item|
139
+ item = item.to_json
140
+ TrophyApiClient::LeaderboardEvent.from_json(json_object: item)
141
+ end
142
+ rank = parsed_json["rank"]
143
+ value = parsed_json["value"]
144
+ id = parsed_json["id"]
145
+ name = parsed_json["name"]
146
+ key = parsed_json["key"]
147
+ rank_by = parsed_json["rankBy"]
148
+ breakdown_attribute = parsed_json["breakdownAttribute"]
149
+ metric_key = parsed_json["metricKey"]
150
+ metric_name = parsed_json["metricName"]
151
+ points_system_key = parsed_json["pointsSystemKey"]
152
+ points_system_name = parsed_json["pointsSystemName"]
153
+ description = parsed_json["description"]
154
+ start = parsed_json["start"]
155
+ end_ = parsed_json["end"]
156
+ max_participants = parsed_json["maxParticipants"]
157
+ run_unit = parsed_json["runUnit"]
158
+ run_interval = parsed_json["runInterval"]
159
+ new(
160
+ history: history,
161
+ rank: rank,
162
+ value: value,
163
+ id: id,
164
+ name: name,
165
+ key: key,
166
+ rank_by: rank_by,
167
+ breakdown_attribute: breakdown_attribute,
168
+ metric_key: metric_key,
169
+ metric_name: metric_name,
170
+ points_system_key: points_system_key,
171
+ points_system_name: points_system_name,
172
+ description: description,
173
+ start: start,
174
+ end_: end_,
175
+ max_participants: max_participants,
176
+ run_unit: run_unit,
177
+ run_interval: run_interval,
178
+ additional_properties: struct
179
+ )
180
+ end
181
+
182
+ # Serialize an instance of UserLeaderboardResponseWithHistory to a JSON object
183
+ #
184
+ # @return [String]
185
+ def to_json(*_args)
186
+ @_field_set&.to_json
187
+ end
188
+
189
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
190
+ # hash and check each fields type against the current object's property
191
+ # definitions.
192
+ #
193
+ # @param obj [Object]
194
+ # @return [Void]
195
+ def self.validate_raw(obj:)
196
+ obj.history.is_a?(Array) != false || raise("Passed value for field obj.history is not the expected type, validation failed.")
197
+ obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
198
+ obj.value&.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
199
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
200
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
201
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
202
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
203
+ obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
204
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
205
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
206
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
207
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
208
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
209
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
210
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
211
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
212
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
213
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
214
+ end
215
+ end
216
+ end
@@ -0,0 +1,220 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_response_rank_by"
4
+ require_relative "leaderboard_response_run_unit"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ # A user's data for a specific leaderboard including rank, value, and history.
10
+ class WebhookUserLeaderboardResponse
11
+ # @return [Integer] The user's rank before this event, or null if they were not on the leaderboard.
12
+ attr_reader :previous_rank
13
+ # @return [Integer] The user's value before this event, or null if they were not on the leaderboard.
14
+ attr_reader :previous_value
15
+ # @return [Integer] The user's current rank in this leaderboard. Null if the user is not on the
16
+ # leaderboard.
17
+ attr_reader :rank
18
+ # @return [Integer] The user's current value in this leaderboard. Null if the user is not on the
19
+ # leaderboard.
20
+ attr_reader :value
21
+ # @return [String] The unique ID of the leaderboard.
22
+ attr_reader :id
23
+ # @return [String] The user-facing name of the leaderboard.
24
+ attr_reader :name
25
+ # @return [String] The unique key used to reference the leaderboard in APIs.
26
+ attr_reader :key
27
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
28
+ attr_reader :rank_by
29
+ # @return [String] The key of the attribute to break down this leaderboard by.
30
+ attr_reader :breakdown_attribute
31
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
32
+ attr_reader :metric_key
33
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
34
+ attr_reader :metric_name
35
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
36
+ attr_reader :points_system_key
37
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
38
+ attr_reader :points_system_name
39
+ # @return [String] The user-facing description of the leaderboard.
40
+ attr_reader :description
41
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
42
+ attr_reader :start
43
+ # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
44
+ # forever.
45
+ attr_reader :end_
46
+ # @return [Integer] The maximum number of participants in the leaderboard.
47
+ attr_reader :max_participants
48
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
49
+ # leaderboards.
50
+ attr_reader :run_unit
51
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
52
+ # type.
53
+ attr_reader :run_interval
54
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
55
+ attr_reader :additional_properties
56
+ # @return [Object]
57
+ attr_reader :_field_set
58
+ protected :_field_set
59
+
60
+ OMIT = Object.new
61
+
62
+ # @param previous_rank [Integer] The user's rank before this event, or null if they were not on the leaderboard.
63
+ # @param previous_value [Integer] The user's value before this event, or null if they were not on the leaderboard.
64
+ # @param rank [Integer] The user's current rank in this leaderboard. Null if the user is not on the
65
+ # leaderboard.
66
+ # @param value [Integer] The user's current value in this leaderboard. Null if the user is not on the
67
+ # leaderboard.
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 rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
72
+ # @param breakdown_attribute [String] The key of the attribute to break down this leaderboard 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 end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
80
+ # forever.
81
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
82
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
83
+ # leaderboards.
84
+ # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
85
+ # type.
86
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
87
+ # @return [TrophyApiClient::WebhookUserLeaderboardResponse]
88
+ def initialize(id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, previous_rank: OMIT, previous_value: OMIT, rank: OMIT, value: OMIT,
89
+ 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)
90
+ @previous_rank = previous_rank if previous_rank != OMIT
91
+ @previous_value = previous_value if previous_value != OMIT
92
+ @rank = rank if rank != OMIT
93
+ @value = value if value != OMIT
94
+ @id = id
95
+ @name = name
96
+ @key = key
97
+ @rank_by = rank_by
98
+ @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
99
+ @metric_key = metric_key if metric_key != OMIT
100
+ @metric_name = metric_name if metric_name != OMIT
101
+ @points_system_key = points_system_key if points_system_key != OMIT
102
+ @points_system_name = points_system_name if points_system_name != OMIT
103
+ @description = description
104
+ @start = start
105
+ @end_ = end_ if end_ != OMIT
106
+ @max_participants = max_participants
107
+ @run_unit = run_unit if run_unit != OMIT
108
+ @run_interval = run_interval
109
+ @additional_properties = additional_properties
110
+ @_field_set = {
111
+ "previousRank": previous_rank,
112
+ "previousValue": previous_value,
113
+ "rank": rank,
114
+ "value": value,
115
+ "id": id,
116
+ "name": name,
117
+ "key": key,
118
+ "rankBy": rank_by,
119
+ "breakdownAttribute": breakdown_attribute,
120
+ "metricKey": metric_key,
121
+ "metricName": metric_name,
122
+ "pointsSystemKey": points_system_key,
123
+ "pointsSystemName": points_system_name,
124
+ "description": description,
125
+ "start": start,
126
+ "end": end_,
127
+ "maxParticipants": max_participants,
128
+ "runUnit": run_unit,
129
+ "runInterval": run_interval
130
+ }.reject do |_k, v|
131
+ v == OMIT
132
+ end
133
+ end
134
+
135
+ # Deserialize a JSON object to an instance of WebhookUserLeaderboardResponse
136
+ #
137
+ # @param json_object [String]
138
+ # @return [TrophyApiClient::WebhookUserLeaderboardResponse]
139
+ def self.from_json(json_object:)
140
+ struct = JSON.parse(json_object, object_class: OpenStruct)
141
+ parsed_json = JSON.parse(json_object)
142
+ previous_rank = parsed_json["previousRank"]
143
+ previous_value = parsed_json["previousValue"]
144
+ rank = parsed_json["rank"]
145
+ value = parsed_json["value"]
146
+ id = parsed_json["id"]
147
+ name = parsed_json["name"]
148
+ key = parsed_json["key"]
149
+ rank_by = parsed_json["rankBy"]
150
+ breakdown_attribute = parsed_json["breakdownAttribute"]
151
+ metric_key = parsed_json["metricKey"]
152
+ metric_name = parsed_json["metricName"]
153
+ points_system_key = parsed_json["pointsSystemKey"]
154
+ points_system_name = parsed_json["pointsSystemName"]
155
+ description = parsed_json["description"]
156
+ start = parsed_json["start"]
157
+ end_ = parsed_json["end"]
158
+ max_participants = parsed_json["maxParticipants"]
159
+ run_unit = parsed_json["runUnit"]
160
+ run_interval = parsed_json["runInterval"]
161
+ new(
162
+ previous_rank: previous_rank,
163
+ previous_value: previous_value,
164
+ rank: rank,
165
+ value: value,
166
+ id: id,
167
+ name: name,
168
+ key: key,
169
+ rank_by: rank_by,
170
+ breakdown_attribute: breakdown_attribute,
171
+ metric_key: metric_key,
172
+ metric_name: metric_name,
173
+ points_system_key: points_system_key,
174
+ points_system_name: points_system_name,
175
+ description: description,
176
+ start: start,
177
+ end_: end_,
178
+ max_participants: max_participants,
179
+ run_unit: run_unit,
180
+ run_interval: run_interval,
181
+ additional_properties: struct
182
+ )
183
+ end
184
+
185
+ # Serialize an instance of WebhookUserLeaderboardResponse to a JSON object
186
+ #
187
+ # @return [String]
188
+ def to_json(*_args)
189
+ @_field_set&.to_json
190
+ end
191
+
192
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
193
+ # hash and check each fields type against the current object's property
194
+ # definitions.
195
+ #
196
+ # @param obj [Object]
197
+ # @return [Void]
198
+ def self.validate_raw(obj:)
199
+ obj.previous_rank&.is_a?(Integer) != false || raise("Passed value for field obj.previous_rank is not the expected type, validation failed.")
200
+ obj.previous_value&.is_a?(Integer) != false || raise("Passed value for field obj.previous_value is not the expected type, validation failed.")
201
+ obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
202
+ obj.value&.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
203
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
204
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
205
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
206
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
207
+ obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
208
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
209
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
210
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
211
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
212
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
213
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
214
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
215
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
216
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
217
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
218
+ end
219
+ end
220
+ end