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,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "leaderboard_response_status"
4
3
  require_relative "leaderboard_response_rank_by"
4
+ require_relative "leaderboard_response_run_unit"
5
5
  require "ostruct"
6
6
  require "json"
7
7
 
@@ -14,10 +14,10 @@ module TrophyApiClient
14
14
  attr_reader :name
15
15
  # @return [String] The unique key used to reference the leaderboard in APIs.
16
16
  attr_reader :key
17
- # @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
18
- attr_reader :status
19
17
  # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
20
18
  attr_reader :rank_by
19
+ # @return [String] The key of the attribute to break down this leaderboard by.
20
+ attr_reader :breakdown_attribute
21
21
  # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
22
22
  attr_reader :metric_key
23
23
  # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -35,7 +35,7 @@ module TrophyApiClient
35
35
  attr_reader :end_
36
36
  # @return [Integer] The maximum number of participants in the leaderboard.
37
37
  attr_reader :max_participants
38
- # @return [String] The repetition type for recurring leaderboards, or null for one-time
38
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
39
39
  # leaderboards.
40
40
  attr_reader :run_unit
41
41
  # @return [Integer] The interval between repetitions, relative to the start date and repetition
@@ -52,8 +52,8 @@ module TrophyApiClient
52
52
  # @param id [String] The unique ID of the leaderboard.
53
53
  # @param name [String] The user-facing name of the leaderboard.
54
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
55
  # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
56
+ # @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
57
57
  # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
58
58
  # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
59
59
  # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -63,24 +63,24 @@ module TrophyApiClient
63
63
  # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
64
64
  # forever.
65
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
66
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
67
67
  # leaderboards.
68
68
  # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
69
69
  # type.
70
70
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
71
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)
72
+ def initialize(id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT,
73
+ points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
74
74
  @id = id
75
75
  @name = name
76
76
  @key = key
77
- @status = status if status != OMIT
78
77
  @rank_by = rank_by
78
+ @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
79
79
  @metric_key = metric_key if metric_key != OMIT
80
80
  @metric_name = metric_name if metric_name != OMIT
81
81
  @points_system_key = points_system_key if points_system_key != OMIT
82
82
  @points_system_name = points_system_name if points_system_name != OMIT
83
- @description = description if description != OMIT
83
+ @description = description
84
84
  @start = start
85
85
  @end_ = end_ if end_ != OMIT
86
86
  @max_participants = max_participants
@@ -91,8 +91,8 @@ module TrophyApiClient
91
91
  "id": id,
92
92
  "name": name,
93
93
  "key": key,
94
- "status": status,
95
94
  "rankBy": rank_by,
95
+ "breakdownAttribute": breakdown_attribute,
96
96
  "metricKey": metric_key,
97
97
  "metricName": metric_name,
98
98
  "pointsSystemKey": points_system_key,
@@ -118,8 +118,8 @@ module TrophyApiClient
118
118
  id = parsed_json["id"]
119
119
  name = parsed_json["name"]
120
120
  key = parsed_json["key"]
121
- status = parsed_json["status"]
122
121
  rank_by = parsed_json["rankBy"]
122
+ breakdown_attribute = parsed_json["breakdownAttribute"]
123
123
  metric_key = parsed_json["metricKey"]
124
124
  metric_name = parsed_json["metricName"]
125
125
  points_system_key = parsed_json["pointsSystemKey"]
@@ -134,8 +134,8 @@ module TrophyApiClient
134
134
  id: id,
135
135
  name: name,
136
136
  key: key,
137
- status: status,
138
137
  rank_by: rank_by,
138
+ breakdown_attribute: breakdown_attribute,
139
139
  metric_key: metric_key,
140
140
  metric_name: metric_name,
141
141
  points_system_key: points_system_key,
@@ -167,17 +167,17 @@ module TrophyApiClient
167
167
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
168
168
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
169
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
170
  obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
171
+ obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
172
172
  obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
173
173
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
174
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
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.")
176
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
177
177
  obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
178
178
  obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
179
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.")
180
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
181
181
  obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
182
182
  end
183
183
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The repetition type for recurring leaderboards, or null for one-time
5
+ # leaderboards.
6
+ class LeaderboardResponseRunUnit
7
+ DAY = "day"
8
+ MONTH = "month"
9
+ YEAR = "year"
10
+ end
11
+ end
@@ -1,13 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "leaderboard_response_with_rankings_status"
3
4
  require_relative "leaderboard_ranking"
4
- require_relative "leaderboard_response_status"
5
5
  require_relative "leaderboard_response_rank_by"
6
+ require_relative "leaderboard_response_run_unit"
6
7
  require "ostruct"
7
8
  require "json"
8
9
 
9
10
  module TrophyApiClient
10
11
  class LeaderboardResponseWithRankings
12
+ # @return [TrophyApiClient::LeaderboardResponseWithRankingsStatus] The status of the leaderboard.
13
+ attr_reader :status
11
14
  # @return [Array<TrophyApiClient::LeaderboardRanking>] Array of user rankings for the leaderboard.
12
15
  attr_reader :rankings
13
16
  # @return [String] The unique ID of the leaderboard.
@@ -16,10 +19,10 @@ module TrophyApiClient
16
19
  attr_reader :name
17
20
  # @return [String] The unique key used to reference the leaderboard in APIs.
18
21
  attr_reader :key
19
- # @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
20
- attr_reader :status
21
22
  # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
22
23
  attr_reader :rank_by
24
+ # @return [String] The key of the attribute to break down this leaderboard by.
25
+ attr_reader :breakdown_attribute
23
26
  # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
24
27
  attr_reader :metric_key
25
28
  # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -37,7 +40,7 @@ module TrophyApiClient
37
40
  attr_reader :end_
38
41
  # @return [Integer] The maximum number of participants in the leaderboard.
39
42
  attr_reader :max_participants
40
- # @return [String] The repetition type for recurring leaderboards, or null for one-time
43
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
41
44
  # leaderboards.
42
45
  attr_reader :run_unit
43
46
  # @return [Integer] The interval between repetitions, relative to the start date and repetition
@@ -51,12 +54,13 @@ module TrophyApiClient
51
54
 
52
55
  OMIT = Object.new
53
56
 
57
+ # @param status [TrophyApiClient::LeaderboardResponseWithRankingsStatus] The status of the leaderboard.
54
58
  # @param rankings [Array<TrophyApiClient::LeaderboardRanking>] Array of user rankings for the leaderboard.
55
59
  # @param id [String] The unique ID of the leaderboard.
56
60
  # @param name [String] The user-facing name of the leaderboard.
57
61
  # @param key [String] The unique key used to reference the leaderboard in APIs.
58
- # @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
59
62
  # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
63
+ # @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
60
64
  # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
61
65
  # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
62
66
  # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -66,25 +70,26 @@ module TrophyApiClient
66
70
  # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
67
71
  # forever.
68
72
  # @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
73
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
70
74
  # leaderboards.
71
75
  # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
72
76
  # type.
73
77
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
74
78
  # @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)
79
+ def initialize(status:, rankings:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, breakdown_attribute: OMIT, metric_key: OMIT,
80
+ metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
81
+ @status = status
77
82
  @rankings = rankings
78
83
  @id = id
79
84
  @name = name
80
85
  @key = key
81
- @status = status if status != OMIT
82
86
  @rank_by = rank_by
87
+ @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
83
88
  @metric_key = metric_key if metric_key != OMIT
84
89
  @metric_name = metric_name if metric_name != OMIT
85
90
  @points_system_key = points_system_key if points_system_key != OMIT
86
91
  @points_system_name = points_system_name if points_system_name != OMIT
87
- @description = description if description != OMIT
92
+ @description = description
88
93
  @start = start
89
94
  @end_ = end_ if end_ != OMIT
90
95
  @max_participants = max_participants
@@ -92,12 +97,13 @@ module TrophyApiClient
92
97
  @run_interval = run_interval
93
98
  @additional_properties = additional_properties
94
99
  @_field_set = {
100
+ "status": status,
95
101
  "rankings": rankings,
96
102
  "id": id,
97
103
  "name": name,
98
104
  "key": key,
99
- "status": status,
100
105
  "rankBy": rank_by,
106
+ "breakdownAttribute": breakdown_attribute,
101
107
  "metricKey": metric_key,
102
108
  "metricName": metric_name,
103
109
  "pointsSystemKey": points_system_key,
@@ -120,6 +126,7 @@ module TrophyApiClient
120
126
  def self.from_json(json_object:)
121
127
  struct = JSON.parse(json_object, object_class: OpenStruct)
122
128
  parsed_json = JSON.parse(json_object)
129
+ status = parsed_json["status"]
123
130
  rankings = parsed_json["rankings"]&.map do |item|
124
131
  item = item.to_json
125
132
  TrophyApiClient::LeaderboardRanking.from_json(json_object: item)
@@ -127,8 +134,8 @@ module TrophyApiClient
127
134
  id = parsed_json["id"]
128
135
  name = parsed_json["name"]
129
136
  key = parsed_json["key"]
130
- status = parsed_json["status"]
131
137
  rank_by = parsed_json["rankBy"]
138
+ breakdown_attribute = parsed_json["breakdownAttribute"]
132
139
  metric_key = parsed_json["metricKey"]
133
140
  metric_name = parsed_json["metricName"]
134
141
  points_system_key = parsed_json["pointsSystemKey"]
@@ -140,12 +147,13 @@ module TrophyApiClient
140
147
  run_unit = parsed_json["runUnit"]
141
148
  run_interval = parsed_json["runInterval"]
142
149
  new(
150
+ status: status,
143
151
  rankings: rankings,
144
152
  id: id,
145
153
  name: name,
146
154
  key: key,
147
- status: status,
148
155
  rank_by: rank_by,
156
+ breakdown_attribute: breakdown_attribute,
149
157
  metric_key: metric_key,
150
158
  metric_name: metric_name,
151
159
  points_system_key: points_system_key,
@@ -174,21 +182,22 @@ module TrophyApiClient
174
182
  # @param obj [Object]
175
183
  # @return [Void]
176
184
  def self.validate_raw(obj:)
185
+ obj.status.is_a?(TrophyApiClient::LeaderboardResponseWithRankingsStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
177
186
  obj.rankings.is_a?(Array) != false || raise("Passed value for field obj.rankings is not the expected type, validation failed.")
178
187
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
179
188
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
180
189
  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
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.")
183
192
  obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
184
193
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
185
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.")
186
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.")
187
- 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.")
188
197
  obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
189
198
  obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
190
199
  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.")
200
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
192
201
  obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
193
202
  end
194
203
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  # The status of the leaderboard.
5
- class LeaderboardResponseStatus
5
+ class LeaderboardResponseWithRankingsStatus
6
6
  ACTIVE = "active"
7
7
  SCHEDULED = "scheduled"
8
8
  FINISHED = "finished"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "leaderboard_response_status"
4
3
  require_relative "leaderboard_response_rank_by"
4
+ require_relative "leaderboard_response_run_unit"
5
5
  require "ostruct"
6
6
  require "json"
7
7
 
@@ -16,19 +16,22 @@ module TrophyApiClient
16
16
  # @return [Integer] The user's rank in the leaderboard before the event, or null if the user was not
17
17
  # on the leaderboard before the event.
18
18
  attr_reader :previous_rank
19
- # @return [Float] The minimum value required to enter the leaderboard according to its current
19
+ # @return [Integer] The minimum value required to enter the leaderboard according to its current
20
20
  # rankings.
21
21
  attr_reader :threshold
22
+ # @return [String] For leaderboards with a breakdown attribute, the value of the attribute for the
23
+ # user.
24
+ attr_reader :breakdown_attribute_value
22
25
  # @return [String] The unique ID of the leaderboard.
23
26
  attr_reader :id
24
27
  # @return [String] The user-facing name of the leaderboard.
25
28
  attr_reader :name
26
29
  # @return [String] The unique key used to reference the leaderboard in APIs.
27
30
  attr_reader :key
28
- # @return [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
29
- attr_reader :status
30
31
  # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
31
32
  attr_reader :rank_by
33
+ # @return [String] The key of the attribute to break down this leaderboard by.
34
+ attr_reader :breakdown_attribute
32
35
  # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
33
36
  attr_reader :metric_key
34
37
  # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -43,7 +46,7 @@ module TrophyApiClient
43
46
  attr_reader :start
44
47
  # @return [Integer] The maximum number of participants in the leaderboard.
45
48
  attr_reader :max_participants
46
- # @return [String] The repetition type for recurring leaderboards, or null for one-time
49
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
47
50
  # leaderboards.
48
51
  attr_reader :run_unit
49
52
  # @return [Integer] The interval between repetitions, relative to the start date and repetition
@@ -63,13 +66,15 @@ module TrophyApiClient
63
66
  # leaderboard.
64
67
  # @param previous_rank [Integer] The user's rank in the leaderboard before the event, or null if the user was not
65
68
  # on the leaderboard before the event.
66
- # @param threshold [Float] The minimum value required to enter the leaderboard according to its current
69
+ # @param threshold [Integer] The minimum value required to enter the leaderboard according to its current
67
70
  # rankings.
71
+ # @param breakdown_attribute_value [String] For leaderboards with a breakdown attribute, the value of the attribute for the
72
+ # user.
68
73
  # @param id [String] The unique ID of the leaderboard.
69
74
  # @param name [String] The user-facing name of the leaderboard.
70
75
  # @param key [String] The unique key used to reference the leaderboard in APIs.
71
- # @param status [TrophyApiClient::LeaderboardResponseStatus] The status of the leaderboard.
72
76
  # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
77
+ # @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
73
78
  # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
74
79
  # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
75
80
  # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -77,28 +82,29 @@ module TrophyApiClient
77
82
  # @param description [String] The user-facing description of the leaderboard.
78
83
  # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
79
84
  # @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
85
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
81
86
  # leaderboards.
82
87
  # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
83
88
  # type.
84
89
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
85
90
  # @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)
91
+ def initialize(threshold:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:,
92
+ end_: OMIT, rank: OMIT, previous_rank: OMIT, breakdown_attribute_value: OMIT, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, run_unit: OMIT, additional_properties: nil)
88
93
  @end_ = end_ if end_ != OMIT
89
94
  @rank = rank if rank != OMIT
90
95
  @previous_rank = previous_rank if previous_rank != OMIT
91
96
  @threshold = threshold
97
+ @breakdown_attribute_value = breakdown_attribute_value if breakdown_attribute_value != OMIT
92
98
  @id = id
93
99
  @name = name
94
100
  @key = key
95
- @status = status if status != OMIT
96
101
  @rank_by = rank_by
102
+ @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
97
103
  @metric_key = metric_key if metric_key != OMIT
98
104
  @metric_name = metric_name if metric_name != OMIT
99
105
  @points_system_key = points_system_key if points_system_key != OMIT
100
106
  @points_system_name = points_system_name if points_system_name != OMIT
101
- @description = description if description != OMIT
107
+ @description = description
102
108
  @start = start
103
109
  @max_participants = max_participants
104
110
  @run_unit = run_unit if run_unit != OMIT
@@ -109,11 +115,12 @@ module TrophyApiClient
109
115
  "rank": rank,
110
116
  "previousRank": previous_rank,
111
117
  "threshold": threshold,
118
+ "breakdownAttributeValue": breakdown_attribute_value,
112
119
  "id": id,
113
120
  "name": name,
114
121
  "key": key,
115
- "status": status,
116
122
  "rankBy": rank_by,
123
+ "breakdownAttribute": breakdown_attribute,
117
124
  "metricKey": metric_key,
118
125
  "metricName": metric_name,
119
126
  "pointsSystemKey": points_system_key,
@@ -139,11 +146,12 @@ module TrophyApiClient
139
146
  rank = parsed_json["rank"]
140
147
  previous_rank = parsed_json["previousRank"]
141
148
  threshold = parsed_json["threshold"]
149
+ breakdown_attribute_value = parsed_json["breakdownAttributeValue"]
142
150
  id = parsed_json["id"]
143
151
  name = parsed_json["name"]
144
152
  key = parsed_json["key"]
145
- status = parsed_json["status"]
146
153
  rank_by = parsed_json["rankBy"]
154
+ breakdown_attribute = parsed_json["breakdownAttribute"]
147
155
  metric_key = parsed_json["metricKey"]
148
156
  metric_name = parsed_json["metricName"]
149
157
  points_system_key = parsed_json["pointsSystemKey"]
@@ -158,11 +166,12 @@ module TrophyApiClient
158
166
  rank: rank,
159
167
  previous_rank: previous_rank,
160
168
  threshold: threshold,
169
+ breakdown_attribute_value: breakdown_attribute_value,
161
170
  id: id,
162
171
  name: name,
163
172
  key: key,
164
- status: status,
165
173
  rank_by: rank_by,
174
+ breakdown_attribute: breakdown_attribute,
166
175
  metric_key: metric_key,
167
176
  metric_name: metric_name,
168
177
  points_system_key: points_system_key,
@@ -193,20 +202,21 @@ module TrophyApiClient
193
202
  obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
194
203
  obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
195
204
  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.")
205
+ obj.threshold.is_a?(Integer) != false || raise("Passed value for field obj.threshold is not the expected type, validation failed.")
206
+ obj.breakdown_attribute_value&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute_value is not the expected type, validation failed.")
197
207
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
198
208
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
199
209
  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
210
  obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
211
+ obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
202
212
  obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
203
213
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
204
214
  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
215
  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.")
216
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
207
217
  obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
208
218
  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.")
219
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
210
220
  obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
211
221
  end
212
222
  end
@@ -6,17 +6,21 @@ require "json"
6
6
 
7
7
  module TrophyApiClient
8
8
  class MetricEventPointsResponse
9
- # @return [Float] The points added by this event.
9
+ # @return [Integer] The points added by this event.
10
10
  attr_reader :added
11
11
  # @return [String] The ID of the points system
12
12
  attr_reader :id
13
+ # @return [String] The key of the points system
14
+ attr_reader :key
13
15
  # @return [String] The name of the points system
14
16
  attr_reader :name
15
17
  # @return [String] The description of the points system
16
18
  attr_reader :description
17
19
  # @return [String] The URL of the badge image for the points system
18
20
  attr_reader :badge_url
19
- # @return [Float] The user's total points
21
+ # @return [Float] The maximum number of points a user can be awarded in this points system
22
+ attr_reader :max_points
23
+ # @return [Integer] The user's total points
20
24
  attr_reader :total
21
25
  # @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
22
26
  attr_reader :awards
@@ -28,31 +32,37 @@ module TrophyApiClient
28
32
 
29
33
  OMIT = Object.new
30
34
 
31
- # @param added [Float] The points added by this event.
35
+ # @param added [Integer] The points added by this event.
32
36
  # @param id [String] The ID of the points system
37
+ # @param key [String] The key of the points system
33
38
  # @param name [String] The name of the points system
34
39
  # @param description [String] The description of the points system
35
40
  # @param badge_url [String] The URL of the badge image for the points system
36
- # @param total [Float] The user's total points
41
+ # @param max_points [Float] The maximum number of points a user can be awarded in this points system
42
+ # @param total [Integer] The user's total points
37
43
  # @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
38
44
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
39
45
  # @return [TrophyApiClient::MetricEventPointsResponse]
40
- def initialize(id:, name:, total:, awards:, added: OMIT, description: OMIT, badge_url: OMIT,
46
+ def initialize(added:, id:, key:, name:, total:, awards:, description: OMIT, badge_url: OMIT, max_points: OMIT,
41
47
  additional_properties: nil)
42
- @added = added if added != OMIT
48
+ @added = added
43
49
  @id = id
50
+ @key = key
44
51
  @name = name
45
52
  @description = description if description != OMIT
46
53
  @badge_url = badge_url if badge_url != OMIT
54
+ @max_points = max_points if max_points != OMIT
47
55
  @total = total
48
56
  @awards = awards
49
57
  @additional_properties = additional_properties
50
58
  @_field_set = {
51
59
  "added": added,
52
60
  "id": id,
61
+ "key": key,
53
62
  "name": name,
54
63
  "description": description,
55
64
  "badgeUrl": badge_url,
65
+ "maxPoints": max_points,
56
66
  "total": total,
57
67
  "awards": awards
58
68
  }.reject do |_k, v|
@@ -69,9 +79,11 @@ module TrophyApiClient
69
79
  parsed_json = JSON.parse(json_object)
70
80
  added = parsed_json["added"]
71
81
  id = parsed_json["id"]
82
+ key = parsed_json["key"]
72
83
  name = parsed_json["name"]
73
84
  description = parsed_json["description"]
74
85
  badge_url = parsed_json["badgeUrl"]
86
+ max_points = parsed_json["maxPoints"]
75
87
  total = parsed_json["total"]
76
88
  awards = parsed_json["awards"]&.map do |item|
77
89
  item = item.to_json
@@ -80,9 +92,11 @@ module TrophyApiClient
80
92
  new(
81
93
  added: added,
82
94
  id: id,
95
+ key: key,
83
96
  name: name,
84
97
  description: description,
85
98
  badge_url: badge_url,
99
+ max_points: max_points,
86
100
  total: total,
87
101
  awards: awards,
88
102
  additional_properties: struct
@@ -103,12 +117,14 @@ module TrophyApiClient
103
117
  # @param obj [Object]
104
118
  # @return [Void]
105
119
  def self.validate_raw(obj:)
106
- obj.added&.is_a?(Float) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
120
+ obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
107
121
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
122
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
108
123
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
109
124
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
110
125
  obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
111
- obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
126
+ obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
127
+ obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
112
128
  obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
113
129
  end
114
130
  end
@@ -58,9 +58,9 @@ module TrophyApiClient
58
58
  # the organization has enabled streak freeze auto-earn.
59
59
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
60
60
  # @return [TrophyApiClient::MetricEventStreakResponse]
61
- def initialize(length:, frequency:, extended: OMIT, started: OMIT, period_start: OMIT, period_end: OMIT,
62
- expires: OMIT, freezes: OMIT, max_freezes: OMIT, freeze_auto_earn_interval: OMIT, freeze_auto_earn_amount: OMIT, additional_properties: nil)
63
- @extended = extended if extended != OMIT
61
+ def initialize(extended:, length:, frequency:, started: OMIT, period_start: OMIT, period_end: OMIT, expires: OMIT,
62
+ freezes: OMIT, max_freezes: OMIT, freeze_auto_earn_interval: OMIT, freeze_auto_earn_amount: OMIT, additional_properties: nil)
63
+ @extended = extended
64
64
  @length = length
65
65
  @frequency = frequency
66
66
  @started = started if started != OMIT
@@ -137,7 +137,7 @@ module TrophyApiClient
137
137
  # @param obj [Object]
138
138
  # @return [Void]
139
139
  def self.validate_raw(obj:)
140
- obj.extended&.is_a?(Boolean) != false || raise("Passed value for field obj.extended is not the expected type, validation failed.")
140
+ obj.extended.is_a?(Boolean) != false || raise("Passed value for field obj.extended is not the expected type, validation failed.")
141
141
  obj.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.")
142
142
  obj.frequency.is_a?(TrophyApiClient::StreakFrequency) != false || raise("Passed value for field obj.frequency is not the expected type, validation failed.")
143
143
  obj.started&.is_a?(String) != false || raise("Passed value for field obj.started is not the expected type, validation failed.")
@@ -8,11 +8,11 @@ module TrophyApiClient
8
8
  class PointsAward
9
9
  # @return [String] The ID of the trigger award
10
10
  attr_reader :id
11
- # @return [Float] The points awarded by this trigger
11
+ # @return [Integer] The points awarded by this trigger
12
12
  attr_reader :awarded
13
13
  # @return [String] The date these points were awarded, in ISO 8601 format.
14
14
  attr_reader :date
15
- # @return [Float] The user's total points after this award occurred.
15
+ # @return [Integer] The user's total points after this award occurred.
16
16
  attr_reader :total
17
17
  # @return [TrophyApiClient::PointsTrigger]
18
18
  attr_reader :trigger
@@ -25,9 +25,9 @@ module TrophyApiClient
25
25
  OMIT = Object.new
26
26
 
27
27
  # @param id [String] The ID of the trigger award
28
- # @param awarded [Float] The points awarded by this trigger
28
+ # @param awarded [Integer] The points awarded by this trigger
29
29
  # @param date [String] The date these points were awarded, in ISO 8601 format.
30
- # @param total [Float] The user's total points after this award occurred.
30
+ # @param total [Integer] The user's total points after this award occurred.
31
31
  # @param trigger [TrophyApiClient::PointsTrigger]
32
32
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
33
33
  # @return [TrophyApiClient::PointsAward]
@@ -91,9 +91,9 @@ module TrophyApiClient
91
91
  # @return [Void]
92
92
  def self.validate_raw(obj:)
93
93
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
94
- obj.awarded&.is_a?(Float) != false || raise("Passed value for field obj.awarded is not the expected type, validation failed.")
94
+ obj.awarded&.is_a?(Integer) != false || raise("Passed value for field obj.awarded is not the expected type, validation failed.")
95
95
  obj.date&.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
96
- obj.total&.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
96
+ obj.total&.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
97
97
  obj.trigger.nil? || TrophyApiClient::PointsTrigger.validate_raw(obj: obj.trigger)
98
98
  end
99
99
  end