trophy_api_client 1.1.2 → 1.3.4

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb +12 -4
  4. data/lib/trophy_api_client/points/client.rb +152 -0
  5. data/lib/trophy_api_client/types/achievement_response.rb +23 -11
  6. data/lib/trophy_api_client/types/achievement_response_event_attribute.rb +2 -2
  7. data/lib/trophy_api_client/types/achievement_response_event_attributes_item.rb +66 -0
  8. data/lib/trophy_api_client/types/achievement_with_stats_response.rb +23 -11
  9. data/lib/trophy_api_client/types/get_user_points_response.rb +38 -22
  10. data/lib/trophy_api_client/types/leaderboard_response.rb +12 -4
  11. data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +12 -4
  12. data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +30 -8
  13. data/lib/trophy_api_client/types/metric_event_leaderboard_response_breakdown_attribute_values_item.rb +67 -0
  14. data/lib/trophy_api_client/types/metric_event_points_response.rb +47 -31
  15. data/lib/trophy_api_client/types/points_level.rb +103 -0
  16. data/lib/trophy_api_client/types/points_level_summary_response.rb +7 -0
  17. data/lib/trophy_api_client/types/points_level_summary_response_item.rb +71 -0
  18. data/lib/trophy_api_client/types/points_response.rb +103 -0
  19. data/lib/trophy_api_client/types/points_system_response.rb +4 -4
  20. data/lib/trophy_api_client/types/points_trigger.rb +101 -9
  21. data/lib/trophy_api_client/types/{points_trigger_response_event_attribute.rb → points_trigger_event_attribute.rb} +7 -7
  22. data/lib/trophy_api_client/types/points_trigger_event_attributes_item.rb +65 -0
  23. data/lib/trophy_api_client/types/{points_trigger_response_status.rb → points_trigger_status.rb} +2 -1
  24. data/lib/trophy_api_client/types/{points_trigger_response_user_attributes_item.rb → points_trigger_user_attributes_item.rb} +7 -9
  25. data/lib/trophy_api_client/types/streak_response.rb +4 -2
  26. data/lib/trophy_api_client/types/user_achievement_response.rb +23 -11
  27. data/lib/trophy_api_client/types/user_achievement_with_stats_response.rb +23 -11
  28. data/lib/trophy_api_client/types/user_leaderboard_response.rb +12 -4
  29. data/lib/trophy_api_client/types/user_leaderboard_response_with_history.rb +12 -4
  30. data/lib/trophy_api_client/types/webhook_user_leaderboard_response.rb +11 -3
  31. data/lib/trophy_api_client/types/webhooks_points_level_changed_payload.rb +117 -0
  32. data/lib/trophy_api_client/types/webhooks_points_level_changed_payload_points.rb +114 -0
  33. data/lib/trophy_api_client/version.rb +1 -1
  34. data/lib/types_export.rb +12 -6
  35. metadata +14 -8
  36. data/lib/trophy_api_client/types/points_trigger_response.rb +0 -211
  37. data/lib/trophy_api_client/types/points_trigger_response_time_unit.rb +0 -9
  38. data/lib/trophy_api_client/types/points_trigger_response_type.rb +0 -12
@@ -1,11 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "points_level"
3
4
  require_relative "points_award"
4
5
  require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module TrophyApiClient
8
9
  class GetUserPointsResponse
10
+ # @return [Integer] The user's total points
11
+ attr_reader :total
12
+ # @return [TrophyApiClient::PointsLevel] The user's current level in this points system, or null if no levels are
13
+ # configured or the user hasn't reached any level yet.
14
+ attr_reader :level
15
+ # @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
16
+ attr_reader :awards
9
17
  # @return [String] The ID of the points system
10
18
  attr_reader :id
11
19
  # @return [String] The key of the points system
@@ -18,10 +26,6 @@ module TrophyApiClient
18
26
  attr_reader :badge_url
19
27
  # @return [Float] The maximum number of points a user can be awarded in this points system
20
28
  attr_reader :max_points
21
- # @return [Integer] The user's total points
22
- attr_reader :total
23
- # @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
24
- attr_reader :awards
25
29
  # @return [OpenStruct] Additional properties unmapped to the current class definition
26
30
  attr_reader :additional_properties
27
31
  # @return [Object]
@@ -30,36 +34,40 @@ module TrophyApiClient
30
34
 
31
35
  OMIT = Object.new
32
36
 
37
+ # @param total [Integer] The user's total points
38
+ # @param level [TrophyApiClient::PointsLevel] The user's current level in this points system, or null if no levels are
39
+ # configured or the user hasn't reached any level yet.
40
+ # @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
33
41
  # @param id [String] The ID of the points system
34
42
  # @param key [String] The key of the points system
35
43
  # @param name [String] The name of the points system
36
44
  # @param description [String] The description of the points system
37
45
  # @param badge_url [String] The URL of the badge image for the points system
38
46
  # @param max_points [Float] The maximum number of points a user can be awarded in this points system
39
- # @param total [Integer] The user's total points
40
- # @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
41
47
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
42
48
  # @return [TrophyApiClient::GetUserPointsResponse]
43
- def initialize(id:, key:, name:, total:, awards:, description: OMIT, badge_url: OMIT, max_points: OMIT,
44
- additional_properties: nil)
49
+ def initialize(total:, awards:, id:, key:, name:, level: OMIT, description: OMIT, badge_url: OMIT,
50
+ max_points: OMIT, additional_properties: nil)
51
+ @total = total
52
+ @level = level if level != OMIT
53
+ @awards = awards
45
54
  @id = id
46
55
  @key = key
47
56
  @name = name
48
57
  @description = description if description != OMIT
49
58
  @badge_url = badge_url if badge_url != OMIT
50
59
  @max_points = max_points if max_points != OMIT
51
- @total = total
52
- @awards = awards
53
60
  @additional_properties = additional_properties
54
61
  @_field_set = {
62
+ "total": total,
63
+ "level": level,
64
+ "awards": awards,
55
65
  "id": id,
56
66
  "key": key,
57
67
  "name": name,
58
68
  "description": description,
59
69
  "badgeUrl": badge_url,
60
- "maxPoints": max_points,
61
- "total": total,
62
- "awards": awards
70
+ "maxPoints": max_points
63
71
  }.reject do |_k, v|
64
72
  v == OMIT
65
73
  end
@@ -72,26 +80,33 @@ module TrophyApiClient
72
80
  def self.from_json(json_object:)
73
81
  struct = JSON.parse(json_object, object_class: OpenStruct)
74
82
  parsed_json = JSON.parse(json_object)
83
+ total = parsed_json["total"]
84
+ if parsed_json["level"].nil?
85
+ level = nil
86
+ else
87
+ level = parsed_json["level"].to_json
88
+ level = TrophyApiClient::PointsLevel.from_json(json_object: level)
89
+ end
90
+ awards = parsed_json["awards"]&.map do |item|
91
+ item = item.to_json
92
+ TrophyApiClient::PointsAward.from_json(json_object: item)
93
+ end
75
94
  id = parsed_json["id"]
76
95
  key = parsed_json["key"]
77
96
  name = parsed_json["name"]
78
97
  description = parsed_json["description"]
79
98
  badge_url = parsed_json["badgeUrl"]
80
99
  max_points = parsed_json["maxPoints"]
81
- total = parsed_json["total"]
82
- awards = parsed_json["awards"]&.map do |item|
83
- item = item.to_json
84
- TrophyApiClient::PointsAward.from_json(json_object: item)
85
- end
86
100
  new(
101
+ total: total,
102
+ level: level,
103
+ awards: awards,
87
104
  id: id,
88
105
  key: key,
89
106
  name: name,
90
107
  description: description,
91
108
  badge_url: badge_url,
92
109
  max_points: max_points,
93
- total: total,
94
- awards: awards,
95
110
  additional_properties: struct
96
111
  )
97
112
  end
@@ -110,14 +125,15 @@ module TrophyApiClient
110
125
  # @param obj [Object]
111
126
  # @return [Void]
112
127
  def self.validate_raw(obj:)
128
+ obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
129
+ obj.level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
130
+ obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
113
131
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
114
132
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
115
133
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
116
134
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
117
135
  obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
118
136
  obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
119
- obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
120
- obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
121
137
  end
122
138
  end
123
139
  end
@@ -16,8 +16,10 @@ module TrophyApiClient
16
16
  attr_reader :key
17
17
  # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
18
18
  attr_reader :rank_by
19
- # @return [String] The key of the attribute to break down this leaderboard by.
19
+ # @return [String] Deprecated. The key of the attribute to break down this leaderboard by.
20
20
  attr_reader :breakdown_attribute
21
+ # @return [Array<String>] The user attribute keys that this leaderboard is broken down by.
22
+ attr_reader :breakdown_attributes
21
23
  # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
22
24
  attr_reader :metric_key
23
25
  # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -53,7 +55,8 @@ module TrophyApiClient
53
55
  # @param name [String] The user-facing name of the leaderboard.
54
56
  # @param key [String] The unique key used to reference the leaderboard in APIs.
55
57
  # @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.
58
+ # @param breakdown_attribute [String] Deprecated. The key of the attribute to break down this leaderboard by.
59
+ # @param breakdown_attributes [Array<String>] The user attribute keys that this leaderboard is broken down by.
57
60
  # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
58
61
  # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
59
62
  # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -69,13 +72,14 @@ module TrophyApiClient
69
72
  # type. Null for one-time leaderboards.
70
73
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
71
74
  # @return [TrophyApiClient::LeaderboardResponse]
72
- def initialize(id:, name:, key:, rank_by:, start:, max_participants:, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT,
73
- points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
75
+ def initialize(id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, breakdown_attribute: OMIT, metric_key: OMIT,
76
+ metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
74
77
  @id = id
75
78
  @name = name
76
79
  @key = key
77
80
  @rank_by = rank_by
78
81
  @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
82
+ @breakdown_attributes = breakdown_attributes
79
83
  @metric_key = metric_key if metric_key != OMIT
80
84
  @metric_name = metric_name if metric_name != OMIT
81
85
  @points_system_key = points_system_key if points_system_key != OMIT
@@ -93,6 +97,7 @@ module TrophyApiClient
93
97
  "key": key,
94
98
  "rankBy": rank_by,
95
99
  "breakdownAttribute": breakdown_attribute,
100
+ "breakdownAttributes": breakdown_attributes,
96
101
  "metricKey": metric_key,
97
102
  "metricName": metric_name,
98
103
  "pointsSystemKey": points_system_key,
@@ -120,6 +125,7 @@ module TrophyApiClient
120
125
  key = parsed_json["key"]
121
126
  rank_by = parsed_json["rankBy"]
122
127
  breakdown_attribute = parsed_json["breakdownAttribute"]
128
+ breakdown_attributes = parsed_json["breakdownAttributes"]
123
129
  metric_key = parsed_json["metricKey"]
124
130
  metric_name = parsed_json["metricName"]
125
131
  points_system_key = parsed_json["pointsSystemKey"]
@@ -136,6 +142,7 @@ module TrophyApiClient
136
142
  key: key,
137
143
  rank_by: rank_by,
138
144
  breakdown_attribute: breakdown_attribute,
145
+ breakdown_attributes: breakdown_attributes,
139
146
  metric_key: metric_key,
140
147
  metric_name: metric_name,
141
148
  points_system_key: points_system_key,
@@ -169,6 +176,7 @@ module TrophyApiClient
169
176
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
170
177
  obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
171
178
  obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
179
+ obj.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
172
180
  obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
173
181
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
174
182
  obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
@@ -21,8 +21,10 @@ module TrophyApiClient
21
21
  attr_reader :key
22
22
  # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
23
23
  attr_reader :rank_by
24
- # @return [String] The key of the attribute to break down this leaderboard by.
24
+ # @return [String] Deprecated. The key of the attribute to break down this leaderboard by.
25
25
  attr_reader :breakdown_attribute
26
+ # @return [Array<String>] The user attribute keys that this leaderboard is broken down by.
27
+ attr_reader :breakdown_attributes
26
28
  # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
27
29
  attr_reader :metric_key
28
30
  # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -60,7 +62,8 @@ module TrophyApiClient
60
62
  # @param name [String] The user-facing name of the leaderboard.
61
63
  # @param key [String] The unique key used to reference the leaderboard in APIs.
62
64
  # @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.
65
+ # @param breakdown_attribute [String] Deprecated. The key of the attribute to break down this leaderboard by.
66
+ # @param breakdown_attributes [Array<String>] The user attribute keys that this leaderboard is broken down by.
64
67
  # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
65
68
  # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
66
69
  # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -76,8 +79,8 @@ module TrophyApiClient
76
79
  # type. Null for one-time leaderboards.
77
80
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
78
81
  # @return [TrophyApiClient::LeaderboardResponseWithRankings]
79
- def initialize(status:, rankings:, id:, name:, key:, rank_by:, start:, max_participants:, breakdown_attribute: OMIT, metric_key: OMIT,
80
- metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
82
+ def initialize(status:, rankings:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, breakdown_attribute: OMIT,
83
+ metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
81
84
  @status = status
82
85
  @rankings = rankings
83
86
  @id = id
@@ -85,6 +88,7 @@ module TrophyApiClient
85
88
  @key = key
86
89
  @rank_by = rank_by
87
90
  @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
91
+ @breakdown_attributes = breakdown_attributes
88
92
  @metric_key = metric_key if metric_key != OMIT
89
93
  @metric_name = metric_name if metric_name != OMIT
90
94
  @points_system_key = points_system_key if points_system_key != OMIT
@@ -104,6 +108,7 @@ module TrophyApiClient
104
108
  "key": key,
105
109
  "rankBy": rank_by,
106
110
  "breakdownAttribute": breakdown_attribute,
111
+ "breakdownAttributes": breakdown_attributes,
107
112
  "metricKey": metric_key,
108
113
  "metricName": metric_name,
109
114
  "pointsSystemKey": points_system_key,
@@ -136,6 +141,7 @@ module TrophyApiClient
136
141
  key = parsed_json["key"]
137
142
  rank_by = parsed_json["rankBy"]
138
143
  breakdown_attribute = parsed_json["breakdownAttribute"]
144
+ breakdown_attributes = parsed_json["breakdownAttributes"]
139
145
  metric_key = parsed_json["metricKey"]
140
146
  metric_name = parsed_json["metricName"]
141
147
  points_system_key = parsed_json["pointsSystemKey"]
@@ -154,6 +160,7 @@ module TrophyApiClient
154
160
  key: key,
155
161
  rank_by: rank_by,
156
162
  breakdown_attribute: breakdown_attribute,
163
+ breakdown_attributes: breakdown_attributes,
157
164
  metric_key: metric_key,
158
165
  metric_name: metric_name,
159
166
  points_system_key: points_system_key,
@@ -189,6 +196,7 @@ module TrophyApiClient
189
196
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
190
197
  obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
191
198
  obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
199
+ obj.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
192
200
  obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
193
201
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
194
202
  obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "metric_event_leaderboard_response_breakdown_attribute_values_item"
3
4
  require_relative "leaderboard_response_rank_by"
4
5
  require_relative "leaderboard_response_run_unit"
5
6
  require "ostruct"
@@ -19,9 +20,12 @@ module TrophyApiClient
19
20
  # @return [Integer] The minimum value required to enter the leaderboard according to its current
20
21
  # rankings.
21
22
  attr_reader :threshold
22
- # @return [String] For leaderboards with a breakdown attribute, the value of the attribute for the
23
- # user.
23
+ # @return [String] Deprecated. For leaderboards with a single breakdown attribute, the value of
24
+ # that attribute for the user.
24
25
  attr_reader :breakdown_attribute_value
26
+ # @return [Array<TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem>] For leaderboards with breakdown attributes, the user's values for each breakdown
27
+ # attribute.
28
+ attr_reader :breakdown_attribute_values
25
29
  # @return [String] The unique ID of the leaderboard.
26
30
  attr_reader :id
27
31
  # @return [String] The user-facing name of the leaderboard.
@@ -30,8 +34,10 @@ module TrophyApiClient
30
34
  attr_reader :key
31
35
  # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
32
36
  attr_reader :rank_by
33
- # @return [String] The key of the attribute to break down this leaderboard by.
37
+ # @return [String] Deprecated. The key of the attribute to break down this leaderboard by.
34
38
  attr_reader :breakdown_attribute
39
+ # @return [Array<String>] The user attribute keys that this leaderboard is broken down by.
40
+ attr_reader :breakdown_attributes
35
41
  # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
36
42
  attr_reader :metric_key
37
43
  # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -68,13 +74,16 @@ module TrophyApiClient
68
74
  # on the leaderboard before the event.
69
75
  # @param threshold [Integer] The minimum value required to enter the leaderboard according to its current
70
76
  # rankings.
71
- # @param breakdown_attribute_value [String] For leaderboards with a breakdown attribute, the value of the attribute for the
72
- # user.
77
+ # @param breakdown_attribute_value [String] Deprecated. For leaderboards with a single breakdown attribute, the value of
78
+ # that attribute for the user.
79
+ # @param breakdown_attribute_values [Array<TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem>] For leaderboards with breakdown attributes, the user's values for each breakdown
80
+ # attribute.
73
81
  # @param id [String] The unique ID of the leaderboard.
74
82
  # @param name [String] The user-facing name of the leaderboard.
75
83
  # @param key [String] The unique key used to reference the leaderboard in APIs.
76
84
  # @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.
85
+ # @param breakdown_attribute [String] Deprecated. The key of the attribute to break down this leaderboard by.
86
+ # @param breakdown_attributes [Array<String>] The user attribute keys that this leaderboard is broken down by.
78
87
  # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
79
88
  # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
80
89
  # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -88,18 +97,20 @@ module TrophyApiClient
88
97
  # type. Null for one-time leaderboards.
89
98
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
90
99
  # @return [TrophyApiClient::MetricEventLeaderboardResponse]
91
- def initialize(threshold:, id:, name:, key:, rank_by:, start:, max_participants:, end_: OMIT, rank: OMIT,
92
- previous_rank: OMIT, breakdown_attribute_value: OMIT, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
100
+ def initialize(threshold:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, end_: OMIT, rank: OMIT, previous_rank: OMIT, breakdown_attribute_value: OMIT,
101
+ breakdown_attribute_values: OMIT, breakdown_attribute: OMIT, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
93
102
  @end_ = end_ if end_ != OMIT
94
103
  @rank = rank if rank != OMIT
95
104
  @previous_rank = previous_rank if previous_rank != OMIT
96
105
  @threshold = threshold
97
106
  @breakdown_attribute_value = breakdown_attribute_value if breakdown_attribute_value != OMIT
107
+ @breakdown_attribute_values = breakdown_attribute_values if breakdown_attribute_values != OMIT
98
108
  @id = id
99
109
  @name = name
100
110
  @key = key
101
111
  @rank_by = rank_by
102
112
  @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
113
+ @breakdown_attributes = breakdown_attributes
103
114
  @metric_key = metric_key if metric_key != OMIT
104
115
  @metric_name = metric_name if metric_name != OMIT
105
116
  @points_system_key = points_system_key if points_system_key != OMIT
@@ -116,11 +127,13 @@ module TrophyApiClient
116
127
  "previousRank": previous_rank,
117
128
  "threshold": threshold,
118
129
  "breakdownAttributeValue": breakdown_attribute_value,
130
+ "breakdownAttributeValues": breakdown_attribute_values,
119
131
  "id": id,
120
132
  "name": name,
121
133
  "key": key,
122
134
  "rankBy": rank_by,
123
135
  "breakdownAttribute": breakdown_attribute,
136
+ "breakdownAttributes": breakdown_attributes,
124
137
  "metricKey": metric_key,
125
138
  "metricName": metric_name,
126
139
  "pointsSystemKey": points_system_key,
@@ -147,11 +160,16 @@ module TrophyApiClient
147
160
  previous_rank = parsed_json["previousRank"]
148
161
  threshold = parsed_json["threshold"]
149
162
  breakdown_attribute_value = parsed_json["breakdownAttributeValue"]
163
+ breakdown_attribute_values = parsed_json["breakdownAttributeValues"]&.map do |item|
164
+ item = item.to_json
165
+ TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem.from_json(json_object: item)
166
+ end
150
167
  id = parsed_json["id"]
151
168
  name = parsed_json["name"]
152
169
  key = parsed_json["key"]
153
170
  rank_by = parsed_json["rankBy"]
154
171
  breakdown_attribute = parsed_json["breakdownAttribute"]
172
+ breakdown_attributes = parsed_json["breakdownAttributes"]
155
173
  metric_key = parsed_json["metricKey"]
156
174
  metric_name = parsed_json["metricName"]
157
175
  points_system_key = parsed_json["pointsSystemKey"]
@@ -167,11 +185,13 @@ module TrophyApiClient
167
185
  previous_rank: previous_rank,
168
186
  threshold: threshold,
169
187
  breakdown_attribute_value: breakdown_attribute_value,
188
+ breakdown_attribute_values: breakdown_attribute_values,
170
189
  id: id,
171
190
  name: name,
172
191
  key: key,
173
192
  rank_by: rank_by,
174
193
  breakdown_attribute: breakdown_attribute,
194
+ breakdown_attributes: breakdown_attributes,
175
195
  metric_key: metric_key,
176
196
  metric_name: metric_name,
177
197
  points_system_key: points_system_key,
@@ -204,11 +224,13 @@ module TrophyApiClient
204
224
  obj.previous_rank&.is_a?(Integer) != false || raise("Passed value for field obj.previous_rank is not the expected type, validation failed.")
205
225
  obj.threshold.is_a?(Integer) != false || raise("Passed value for field obj.threshold is not the expected type, validation failed.")
206
226
  obj.breakdown_attribute_value&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute_value is not the expected type, validation failed.")
227
+ obj.breakdown_attribute_values&.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attribute_values is not the expected type, validation failed.")
207
228
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
208
229
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
209
230
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
210
231
  obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
211
232
  obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
233
+ obj.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
212
234
  obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
213
235
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
214
236
  obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ class MetricEventLeaderboardResponseBreakdownAttributeValuesItem
8
+ # @return [String] The key of the breakdown attribute.
9
+ attr_reader :key
10
+ # @return [String] The user's value for the breakdown attribute.
11
+ attr_reader :value
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param key [String] The key of the breakdown attribute.
21
+ # @param value [String] The user's value for the breakdown attribute.
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem]
24
+ def initialize(key:, value:, additional_properties: nil)
25
+ @key = key
26
+ @value = value
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "key": key, "value": value }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of
32
+ # MetricEventLeaderboardResponseBreakdownAttributeValuesItem
33
+ #
34
+ # @param json_object [String]
35
+ # @return [TrophyApiClient::MetricEventLeaderboardResponseBreakdownAttributeValuesItem]
36
+ def self.from_json(json_object:)
37
+ struct = JSON.parse(json_object, object_class: OpenStruct)
38
+ parsed_json = JSON.parse(json_object)
39
+ key = parsed_json["key"]
40
+ value = parsed_json["value"]
41
+ new(
42
+ key: key,
43
+ value: value,
44
+ additional_properties: struct
45
+ )
46
+ end
47
+
48
+ # Serialize an instance of
49
+ # MetricEventLeaderboardResponseBreakdownAttributeValuesItem to a JSON object
50
+ #
51
+ # @return [String]
52
+ def to_json(*_args)
53
+ @_field_set&.to_json
54
+ end
55
+
56
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
57
+ # hash and check each fields type against the current object's property
58
+ # definitions.
59
+ #
60
+ # @param obj [Object]
61
+ # @return [Void]
62
+ def self.validate_raw(obj:)
63
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
64
+ obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
65
+ end
66
+ end
67
+ end
@@ -1,12 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "points_level"
3
4
  require_relative "points_award"
4
5
  require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module TrophyApiClient
8
- # Points system response for metric events.
9
+ # Points system response for metric events and achievement completions.
9
10
  class MetricEventPointsResponse
11
+ # @return [Integer] The user's total points
12
+ attr_reader :total
13
+ # @return [TrophyApiClient::PointsLevel] The user's new level, included only when the level changed as a result of this
14
+ # event.
15
+ attr_reader :level
16
+ # @return [Integer] The points added by this event.
17
+ attr_reader :added
18
+ # @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
19
+ attr_reader :awards
10
20
  # @return [String] The ID of the points system
11
21
  attr_reader :id
12
22
  # @return [String] The key of the points system
@@ -19,12 +29,6 @@ module TrophyApiClient
19
29
  attr_reader :badge_url
20
30
  # @return [Float] The maximum number of points a user can be awarded in this points system
21
31
  attr_reader :max_points
22
- # @return [Integer] The user's total points
23
- attr_reader :total
24
- # @return [Integer] The points added by this event.
25
- attr_reader :added
26
- # @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
27
- attr_reader :awards
28
32
  # @return [OpenStruct] Additional properties unmapped to the current class definition
29
33
  attr_reader :additional_properties
30
34
  # @return [Object]
@@ -33,39 +37,43 @@ module TrophyApiClient
33
37
 
34
38
  OMIT = Object.new
35
39
 
40
+ # @param total [Integer] The user's total points
41
+ # @param level [TrophyApiClient::PointsLevel] The user's new level, included only when the level changed as a result of this
42
+ # event.
43
+ # @param added [Integer] The points added by this event.
44
+ # @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
36
45
  # @param id [String] The ID of the points system
37
46
  # @param key [String] The key of the points system
38
47
  # @param name [String] The name of the points system
39
48
  # @param description [String] The description of the points system
40
49
  # @param badge_url [String] The URL of the badge image for the points system
41
50
  # @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
43
- # @param added [Integer] The points added by this event.
44
- # @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
45
51
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
46
52
  # @return [TrophyApiClient::MetricEventPointsResponse]
47
- def initialize(id:, key:, name:, total:, added:, awards:, description: OMIT, badge_url: OMIT, max_points: OMIT,
48
- additional_properties: nil)
53
+ def initialize(total:, added:, awards:, id:, key:, name:, level: OMIT, description: OMIT, badge_url: OMIT,
54
+ max_points: OMIT, additional_properties: nil)
55
+ @total = total
56
+ @level = level if level != OMIT
57
+ @added = added
58
+ @awards = awards
49
59
  @id = id
50
60
  @key = key
51
61
  @name = name
52
62
  @description = description if description != OMIT
53
63
  @badge_url = badge_url if badge_url != OMIT
54
64
  @max_points = max_points if max_points != OMIT
55
- @total = total
56
- @added = added
57
- @awards = awards
58
65
  @additional_properties = additional_properties
59
66
  @_field_set = {
67
+ "total": total,
68
+ "level": level,
69
+ "added": added,
70
+ "awards": awards,
60
71
  "id": id,
61
72
  "key": key,
62
73
  "name": name,
63
74
  "description": description,
64
75
  "badgeUrl": badge_url,
65
- "maxPoints": max_points,
66
- "total": total,
67
- "added": added,
68
- "awards": awards
76
+ "maxPoints": max_points
69
77
  }.reject do |_k, v|
70
78
  v == OMIT
71
79
  end
@@ -78,28 +86,35 @@ module TrophyApiClient
78
86
  def self.from_json(json_object:)
79
87
  struct = JSON.parse(json_object, object_class: OpenStruct)
80
88
  parsed_json = JSON.parse(json_object)
81
- id = parsed_json["id"]
82
- key = parsed_json["key"]
83
- name = parsed_json["name"]
84
- description = parsed_json["description"]
85
- badge_url = parsed_json["badgeUrl"]
86
- max_points = parsed_json["maxPoints"]
87
89
  total = parsed_json["total"]
90
+ if parsed_json["level"].nil?
91
+ level = nil
92
+ else
93
+ level = parsed_json["level"].to_json
94
+ level = TrophyApiClient::PointsLevel.from_json(json_object: level)
95
+ end
88
96
  added = parsed_json["added"]
89
97
  awards = parsed_json["awards"]&.map do |item|
90
98
  item = item.to_json
91
99
  TrophyApiClient::PointsAward.from_json(json_object: item)
92
100
  end
101
+ id = parsed_json["id"]
102
+ key = parsed_json["key"]
103
+ name = parsed_json["name"]
104
+ description = parsed_json["description"]
105
+ badge_url = parsed_json["badgeUrl"]
106
+ max_points = parsed_json["maxPoints"]
93
107
  new(
108
+ total: total,
109
+ level: level,
110
+ added: added,
111
+ awards: awards,
94
112
  id: id,
95
113
  key: key,
96
114
  name: name,
97
115
  description: description,
98
116
  badge_url: badge_url,
99
117
  max_points: max_points,
100
- total: total,
101
- added: added,
102
- awards: awards,
103
118
  additional_properties: struct
104
119
  )
105
120
  end
@@ -118,15 +133,16 @@ module TrophyApiClient
118
133
  # @param obj [Object]
119
134
  # @return [Void]
120
135
  def self.validate_raw(obj:)
136
+ obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
137
+ obj.level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
138
+ obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
139
+ obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
121
140
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
122
141
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
123
142
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
124
143
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
125
144
  obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
126
145
  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.")
128
- obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
129
- obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
130
146
  end
131
147
  end
132
148
  end