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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 057cf20c78c80caa66eff19b3a3252ba56e92d84645219cc40a996afda1b6a83
4
- data.tar.gz: 13b109f1d873161c2328189bfb54aebcf9f83dcc1d00570629a357f71ad34028
3
+ metadata.gz: ae06f4ad10f6292d25008af408ba0947190adfdda8bf9a243333e21b3d1b2bd8
4
+ data.tar.gz: c54d6136018d217c6236c43f9683d362903060538d5429e5a35266d2a7e0983c
5
5
  SHA512:
6
- metadata.gz: 597eba515aec1cb420d4de9cc034175a52872a494042f15ff6e05a76843ec6c953ef87f8431fae75a80195c55aaa6572982d069afb03b01eec600e4693b4252e
7
- data.tar.gz: 6ff81aa42cc68cccf65381bac4eddf79ce6eb7e36b194e3d5b0090126baffa3a311074b33c90575baadbde6030e02ea8eefe9528c30fa9dbe3beaea44d8064ac
6
+ metadata.gz: 255581f34cedb5460cbed75b5c8a946150f5e2c768c445fd01a532d0f4dc3986d3bf0318eb2580a1126229e1a88c0f1a53291708011e57623700c2aee1cf28dd
7
+ data.tar.gz: eedad3138a96ca0f72d3e661c03db489db53cde53cc9a8dc652600db1c9964ebdab6553daf089b791c54183d40bcf4db255db38d26f4819fdd67555dea592c28
data/lib/gemconfig.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  module Gemconfig
5
- VERSION = "1.0.29"
5
+ VERSION = "1.0.31"
6
6
  AUTHORS = ["Trophy Labs, Inc"].freeze
7
7
  EMAIL = ""
8
8
  SUMMARY = "Ruby library for the Trophy API."
@@ -20,6 +20,9 @@ module TrophyApiClient
20
20
 
21
21
  # Get all achievements and their completion stats.
22
22
  #
23
+ # @param user_attributes [String] Optional colon-delimited user attributes in the format
24
+ # attribute:value,attribute:value. Only achievements accessible to a user with the
25
+ # provided attributes will be returned.
23
26
  # @param request_options [TrophyApiClient::RequestOptions]
24
27
  # @return [Array<TrophyApiClient::AchievementWithStatsResponse>]
25
28
  # @example
@@ -28,8 +31,8 @@ module TrophyApiClient
28
31
  # environment: TrophyApiClient::Environment::PRODUCTION,
29
32
  # api_key: "YOUR_API_KEY"
30
33
  # )
31
- # api.achievements.all
32
- def all(request_options: nil)
34
+ # api.achievements.all(user_attributes: "plan-type:premium,region:us-east")
35
+ def all(user_attributes: nil, request_options: nil)
33
36
  response = @request_client.conn.get do |req|
34
37
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
35
38
  req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -38,9 +41,10 @@ module TrophyApiClient
38
41
  **@request_client.get_headers,
39
42
  **(request_options&.additional_headers || {})
40
43
  }.compact
41
- unless request_options.nil? || request_options&.additional_query_parameters.nil?
42
- req.params = { **(request_options&.additional_query_parameters || {}) }.compact
43
- end
44
+ req.params = {
45
+ **(request_options&.additional_query_parameters || {}),
46
+ "userAttributes": user_attributes
47
+ }.compact
44
48
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
45
49
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
46
50
  end
@@ -72,7 +76,7 @@ module TrophyApiClient
72
76
  # environment: TrophyApiClient::Environment::PRODUCTION,
73
77
  # api_key: "YOUR_API_KEY"
74
78
  # )
75
- # api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
79
+ # api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "user-id" })
76
80
  def complete(key:, user:, request_options: nil)
77
81
  response = @request_client.conn.post do |req|
78
82
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -105,6 +109,9 @@ module TrophyApiClient
105
109
 
106
110
  # Get all achievements and their completion stats.
107
111
  #
112
+ # @param user_attributes [String] Optional colon-delimited user attributes in the format
113
+ # attribute:value,attribute:value. Only achievements accessible to a user with the
114
+ # provided attributes will be returned.
108
115
  # @param request_options [TrophyApiClient::RequestOptions]
109
116
  # @return [Array<TrophyApiClient::AchievementWithStatsResponse>]
110
117
  # @example
@@ -113,8 +120,8 @@ module TrophyApiClient
113
120
  # environment: TrophyApiClient::Environment::PRODUCTION,
114
121
  # api_key: "YOUR_API_KEY"
115
122
  # )
116
- # api.achievements.all
117
- def all(request_options: nil)
123
+ # api.achievements.all(user_attributes: "plan-type:premium,region:us-east")
124
+ def all(user_attributes: nil, request_options: nil)
118
125
  Async do
119
126
  response = @request_client.conn.get do |req|
120
127
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -124,9 +131,10 @@ module TrophyApiClient
124
131
  **@request_client.get_headers,
125
132
  **(request_options&.additional_headers || {})
126
133
  }.compact
127
- unless request_options.nil? || request_options&.additional_query_parameters.nil?
128
- req.params = { **(request_options&.additional_query_parameters || {}) }.compact
129
- end
134
+ req.params = {
135
+ **(request_options&.additional_query_parameters || {}),
136
+ "userAttributes": user_attributes
137
+ }.compact
130
138
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
131
139
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
132
140
  end
@@ -159,7 +167,7 @@ module TrophyApiClient
159
167
  # environment: TrophyApiClient::Environment::PRODUCTION,
160
168
  # api_key: "YOUR_API_KEY"
161
169
  # )
162
- # api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
170
+ # api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "user-id" })
163
171
  def complete(key:, user:, request_options: nil)
164
172
  Async do
165
173
  response = @request_client.conn.post do |req|
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../../requests"
4
- require_relative "../types/leaderboard_response"
4
+ require_relative "types/leaderboards_all_response_item"
5
5
  require "json"
6
6
  require_relative "../types/leaderboard_response_with_rankings"
7
7
  require "async"
@@ -20,7 +20,7 @@ module TrophyApiClient
20
20
  # Get all active leaderboards for your organization.
21
21
  #
22
22
  # @param request_options [TrophyApiClient::RequestOptions]
23
- # @return [Array<TrophyApiClient::LeaderboardResponse>]
23
+ # @return [Array<TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem>]
24
24
  # @example
25
25
  # api = TrophyApiClient::Client.new(
26
26
  # base_url: "https://api.example.com",
@@ -48,7 +48,7 @@ module TrophyApiClient
48
48
  parsed_json = JSON.parse(response.body)
49
49
  parsed_json&.map do |item|
50
50
  item = item.to_json
51
- TrophyApiClient::LeaderboardResponse.from_json(json_object: item)
51
+ TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem.from_json(json_object: item)
52
52
  end
53
53
  end
54
54
 
@@ -61,6 +61,9 @@ module TrophyApiClient
61
61
  # run.
62
62
  # @param user_id [String] When provided, offset is relative to this user's position on the leaderboard. If
63
63
  # the user is not found in the leaderboard, returns empty rankings array.
64
+ # @param user_attributes [String] Attribute key and value to filter the rankings by, separated by a colon. This
65
+ # parameter is required, and only valid for leaderboards with a breakdown
66
+ # attribute.
64
67
  # @param request_options [TrophyApiClient::RequestOptions]
65
68
  # @return [TrophyApiClient::LeaderboardResponseWithRankings]
66
69
  # @example
@@ -71,10 +74,13 @@ module TrophyApiClient
71
74
  # )
72
75
  # api.leaderboards.get(
73
76
  # key: "weekly-words",
77
+ # offset: 1,
78
+ # limit: 1,
74
79
  # run: "2025-01-15",
75
- # user_id: "user-123"
80
+ # user_id: "user-123",
81
+ # user_attributes: "city:London"
76
82
  # )
77
- def get(key:, offset: nil, limit: nil, run: nil, user_id: nil, request_options: nil)
83
+ def get(key:, offset: nil, limit: nil, run: nil, user_id: nil, user_attributes: nil, request_options: nil)
78
84
  response = @request_client.conn.get do |req|
79
85
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
80
86
  req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -88,7 +94,8 @@ module TrophyApiClient
88
94
  "offset": offset,
89
95
  "limit": limit,
90
96
  "run": run,
91
- "userId": user_id
97
+ "userId": user_id,
98
+ "userAttributes": user_attributes
92
99
  }.compact
93
100
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
94
101
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
@@ -112,7 +119,7 @@ module TrophyApiClient
112
119
  # Get all active leaderboards for your organization.
113
120
  #
114
121
  # @param request_options [TrophyApiClient::RequestOptions]
115
- # @return [Array<TrophyApiClient::LeaderboardResponse>]
122
+ # @return [Array<TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem>]
116
123
  # @example
117
124
  # api = TrophyApiClient::Client.new(
118
125
  # base_url: "https://api.example.com",
@@ -141,7 +148,7 @@ module TrophyApiClient
141
148
  parsed_json = JSON.parse(response.body)
142
149
  parsed_json&.map do |item|
143
150
  item = item.to_json
144
- TrophyApiClient::LeaderboardResponse.from_json(json_object: item)
151
+ TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem.from_json(json_object: item)
145
152
  end
146
153
  end
147
154
  end
@@ -155,6 +162,9 @@ module TrophyApiClient
155
162
  # run.
156
163
  # @param user_id [String] When provided, offset is relative to this user's position on the leaderboard. If
157
164
  # the user is not found in the leaderboard, returns empty rankings array.
165
+ # @param user_attributes [String] Attribute key and value to filter the rankings by, separated by a colon. This
166
+ # parameter is required, and only valid for leaderboards with a breakdown
167
+ # attribute.
158
168
  # @param request_options [TrophyApiClient::RequestOptions]
159
169
  # @return [TrophyApiClient::LeaderboardResponseWithRankings]
160
170
  # @example
@@ -165,10 +175,13 @@ module TrophyApiClient
165
175
  # )
166
176
  # api.leaderboards.get(
167
177
  # key: "weekly-words",
178
+ # offset: 1,
179
+ # limit: 1,
168
180
  # run: "2025-01-15",
169
- # user_id: "user-123"
181
+ # user_id: "user-123",
182
+ # user_attributes: "city:London"
170
183
  # )
171
- def get(key:, offset: nil, limit: nil, run: nil, user_id: nil, request_options: nil)
184
+ def get(key:, offset: nil, limit: nil, run: nil, user_id: nil, user_attributes: nil, request_options: nil)
172
185
  Async do
173
186
  response = @request_client.conn.get do |req|
174
187
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -183,7 +196,8 @@ module TrophyApiClient
183
196
  "offset": offset,
184
197
  "limit": limit,
185
198
  "run": run,
186
- "userId": user_id
199
+ "userId": user_id,
200
+ "userAttributes": user_attributes
187
201
  }.compact
188
202
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
189
203
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
@@ -0,0 +1,194 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboards_all_response_item_status"
4
+ require_relative "../../types/leaderboard_response_rank_by"
5
+ require_relative "../../types/leaderboard_response_run_unit"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module TrophyApiClient
10
+ class Leaderboards
11
+ class LeaderboardsAllResponseItem
12
+ # @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus] The status of the leaderboard.
13
+ attr_reader :status
14
+ # @return [String] The unique ID of the leaderboard.
15
+ attr_reader :id
16
+ # @return [String] The user-facing name of the leaderboard.
17
+ attr_reader :name
18
+ # @return [String] The unique key used to reference the leaderboard in APIs.
19
+ attr_reader :key
20
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
21
+ attr_reader :rank_by
22
+ # @return [String] The key of the attribute to break down this leaderboard by.
23
+ attr_reader :breakdown_attribute
24
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
25
+ attr_reader :metric_key
26
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
27
+ attr_reader :metric_name
28
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
29
+ attr_reader :points_system_key
30
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
31
+ attr_reader :points_system_name
32
+ # @return [String] The user-facing description of the leaderboard.
33
+ attr_reader :description
34
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
35
+ attr_reader :start
36
+ # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
37
+ # forever.
38
+ attr_reader :end_
39
+ # @return [Integer] The maximum number of participants in the leaderboard.
40
+ attr_reader :max_participants
41
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
42
+ # leaderboards.
43
+ attr_reader :run_unit
44
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
45
+ # type.
46
+ attr_reader :run_interval
47
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
48
+ attr_reader :additional_properties
49
+ # @return [Object]
50
+ attr_reader :_field_set
51
+ protected :_field_set
52
+
53
+ OMIT = Object.new
54
+
55
+ # @param status [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus] The status of the leaderboard.
56
+ # @param id [String] The unique ID of the leaderboard.
57
+ # @param name [String] The user-facing name of the leaderboard.
58
+ # @param key [String] The unique key used to reference the leaderboard in APIs.
59
+ # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
60
+ # @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
61
+ # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
62
+ # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
63
+ # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
64
+ # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
65
+ # @param description [String] The user-facing description of the leaderboard.
66
+ # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
67
+ # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
68
+ # forever.
69
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
70
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
71
+ # leaderboards.
72
+ # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
73
+ # type.
74
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
75
+ # @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem]
76
+ def initialize(status:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, breakdown_attribute: OMIT, metric_key: OMIT,
77
+ metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
78
+ @status = status
79
+ @id = id
80
+ @name = name
81
+ @key = key
82
+ @rank_by = rank_by
83
+ @breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
84
+ @metric_key = metric_key if metric_key != OMIT
85
+ @metric_name = metric_name if metric_name != OMIT
86
+ @points_system_key = points_system_key if points_system_key != OMIT
87
+ @points_system_name = points_system_name if points_system_name != OMIT
88
+ @description = description
89
+ @start = start
90
+ @end_ = end_ if end_ != OMIT
91
+ @max_participants = max_participants
92
+ @run_unit = run_unit if run_unit != OMIT
93
+ @run_interval = run_interval
94
+ @additional_properties = additional_properties
95
+ @_field_set = {
96
+ "status": status,
97
+ "id": id,
98
+ "name": name,
99
+ "key": key,
100
+ "rankBy": rank_by,
101
+ "breakdownAttribute": breakdown_attribute,
102
+ "metricKey": metric_key,
103
+ "metricName": metric_name,
104
+ "pointsSystemKey": points_system_key,
105
+ "pointsSystemName": points_system_name,
106
+ "description": description,
107
+ "start": start,
108
+ "end": end_,
109
+ "maxParticipants": max_participants,
110
+ "runUnit": run_unit,
111
+ "runInterval": run_interval
112
+ }.reject do |_k, v|
113
+ v == OMIT
114
+ end
115
+ end
116
+
117
+ # Deserialize a JSON object to an instance of LeaderboardsAllResponseItem
118
+ #
119
+ # @param json_object [String]
120
+ # @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem]
121
+ def self.from_json(json_object:)
122
+ struct = JSON.parse(json_object, object_class: OpenStruct)
123
+ parsed_json = JSON.parse(json_object)
124
+ status = parsed_json["status"]
125
+ id = parsed_json["id"]
126
+ name = parsed_json["name"]
127
+ key = parsed_json["key"]
128
+ rank_by = parsed_json["rankBy"]
129
+ breakdown_attribute = parsed_json["breakdownAttribute"]
130
+ metric_key = parsed_json["metricKey"]
131
+ metric_name = parsed_json["metricName"]
132
+ points_system_key = parsed_json["pointsSystemKey"]
133
+ points_system_name = parsed_json["pointsSystemName"]
134
+ description = parsed_json["description"]
135
+ start = parsed_json["start"]
136
+ end_ = parsed_json["end"]
137
+ max_participants = parsed_json["maxParticipants"]
138
+ run_unit = parsed_json["runUnit"]
139
+ run_interval = parsed_json["runInterval"]
140
+ new(
141
+ status: status,
142
+ id: id,
143
+ name: name,
144
+ key: key,
145
+ rank_by: rank_by,
146
+ breakdown_attribute: breakdown_attribute,
147
+ metric_key: metric_key,
148
+ metric_name: metric_name,
149
+ points_system_key: points_system_key,
150
+ points_system_name: points_system_name,
151
+ description: description,
152
+ start: start,
153
+ end_: end_,
154
+ max_participants: max_participants,
155
+ run_unit: run_unit,
156
+ run_interval: run_interval,
157
+ additional_properties: struct
158
+ )
159
+ end
160
+
161
+ # Serialize an instance of LeaderboardsAllResponseItem to a JSON object
162
+ #
163
+ # @return [String]
164
+ def to_json(*_args)
165
+ @_field_set&.to_json
166
+ end
167
+
168
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
169
+ # hash and check each fields type against the current object's property
170
+ # definitions.
171
+ #
172
+ # @param obj [Object]
173
+ # @return [Void]
174
+ def self.validate_raw(obj:)
175
+ obj.status.is_a?(TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
176
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
177
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
178
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
179
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
180
+ obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
181
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
182
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
183
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
184
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
185
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
186
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
187
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
188
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
189
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
190
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
191
+ end
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ class Leaderboards
5
+ # The status of the leaderboard.
6
+ class LeaderboardsAllResponseItemStatus
7
+ ACTIVE = "active"
8
+ SCHEDULED = "scheduled"
9
+ FINISHED = "finished"
10
+ end
11
+ end
12
+ end
@@ -42,7 +42,7 @@ module TrophyApiClient
42
42
  # api.metrics.event(
43
43
  # idempotency_key: "e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
44
44
  # key: "words-written",
45
- # user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
45
+ # user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "18" },
46
46
  # value: 750,
47
47
  # attributes: { "category": "writing", "source": "mobile-app" }
48
48
  # )
@@ -107,7 +107,7 @@ module TrophyApiClient
107
107
  # api.metrics.event(
108
108
  # idempotency_key: "e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
109
109
  # key: "words-written",
110
- # user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
110
+ # user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "18" },
111
111
  # value: 750,
112
112
  # attributes: { "category": "writing", "source": "mobile-app" }
113
113
  # )
@@ -21,8 +21,8 @@ module TrophyApiClient
21
21
  #
22
22
  # @param key [String] Key of the points system.
23
23
  # @param user_attributes [String] Optional colon-delimited user attribute filters in the format
24
- # attributeKey:value,attributeKey:value. Only users matching ALL specified
25
- # attributes will be included in the points breakdown.
24
+ # attribute:value,attribute:value. Only users matching ALL specified attributes
25
+ # will be included in the points breakdown.
26
26
  # @param request_options [TrophyApiClient::RequestOptions]
27
27
  # @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
28
28
  # @example
@@ -104,8 +104,8 @@ module TrophyApiClient
104
104
  #
105
105
  # @param key [String] Key of the points system.
106
106
  # @param user_attributes [String] Optional colon-delimited user attribute filters in the format
107
- # attributeKey:value,attributeKey:value. Only users matching ALL specified
108
- # attributes will be included in the points breakdown.
107
+ # attribute:value,attribute:value. Only users matching ALL specified attributes
108
+ # will be included in the points breakdown.
109
109
  # @param request_options [TrophyApiClient::RequestOptions]
110
110
  # @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
111
111
  # @example
@@ -65,7 +65,7 @@ module TrophyApiClient
65
65
  # environment: TrophyApiClient::Environment::PRODUCTION,
66
66
  # api_key: "YOUR_API_KEY"
67
67
  # )
68
- # api.streaks.rankings
68
+ # api.streaks.rankings(limit: 1, type: ACTIVE)
69
69
  def rankings(limit: nil, type: nil, request_options: nil)
70
70
  response = @request_client.conn.get do |req|
71
71
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -148,7 +148,7 @@ module TrophyApiClient
148
148
  # environment: TrophyApiClient::Environment::PRODUCTION,
149
149
  # api_key: "YOUR_API_KEY"
150
150
  # )
151
- # api.streaks.rankings
151
+ # api.streaks.rankings(limit: 1, type: ACTIVE)
152
152
  def rankings(limit: nil, type: nil, request_options: nil)
153
153
  Async do
154
154
  response = @request_client.conn.get do |req|
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "completed_achievement_response"
3
+ require_relative "achievement_completion_response_achievement"
4
4
  require "ostruct"
5
5
  require "json"
6
6
 
@@ -8,7 +8,7 @@ module TrophyApiClient
8
8
  class AchievementCompletionResponse
9
9
  # @return [String] The unique ID of the completion.
10
10
  attr_reader :completion_id
11
- # @return [TrophyApiClient::CompletedAchievementResponse]
11
+ # @return [TrophyApiClient::AchievementCompletionResponseAchievement]
12
12
  attr_reader :achievement
13
13
  # @return [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
14
14
  # completion.
@@ -22,19 +22,17 @@ module TrophyApiClient
22
22
  OMIT = Object.new
23
23
 
24
24
  # @param completion_id [String] The unique ID of the completion.
25
- # @param achievement [TrophyApiClient::CompletedAchievementResponse]
25
+ # @param achievement [TrophyApiClient::AchievementCompletionResponseAchievement]
26
26
  # @param points [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
27
27
  # completion.
28
28
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
29
29
  # @return [TrophyApiClient::AchievementCompletionResponse]
30
- def initialize(completion_id:, achievement:, points: OMIT, additional_properties: nil)
30
+ def initialize(completion_id:, achievement:, points:, additional_properties: nil)
31
31
  @completion_id = completion_id
32
32
  @achievement = achievement
33
- @points = points if points != OMIT
33
+ @points = points
34
34
  @additional_properties = additional_properties
35
- @_field_set = { "completionId": completion_id, "achievement": achievement, "points": points }.reject do |_k, v|
36
- v == OMIT
37
- end
35
+ @_field_set = { "completionId": completion_id, "achievement": achievement, "points": points }
38
36
  end
39
37
 
40
38
  # Deserialize a JSON object to an instance of AchievementCompletionResponse
@@ -49,7 +47,7 @@ module TrophyApiClient
49
47
  achievement = nil
50
48
  else
51
49
  achievement = parsed_json["achievement"].to_json
52
- achievement = TrophyApiClient::CompletedAchievementResponse.from_json(json_object: achievement)
50
+ achievement = TrophyApiClient::AchievementCompletionResponseAchievement.from_json(json_object: achievement)
53
51
  end
54
52
  points = parsed_json["points"]&.transform_values do |value|
55
53
  value = value.to_json
@@ -78,8 +76,8 @@ module TrophyApiClient
78
76
  # @return [Void]
79
77
  def self.validate_raw(obj:)
80
78
  obj.completion_id.is_a?(String) != false || raise("Passed value for field obj.completion_id is not the expected type, validation failed.")
81
- TrophyApiClient::CompletedAchievementResponse.validate_raw(obj: obj.achievement)
82
- obj.points&.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
79
+ TrophyApiClient::AchievementCompletionResponseAchievement.validate_raw(obj: obj.achievement)
80
+ obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
83
81
  end
84
82
  end
85
83
  end