Skip to content

Commit 8d68ef8

Browse files
Automatically update Ruby SDK
1 parent 5c39ac7 commit 8d68ef8

12 files changed

Lines changed: 119 additions & 35 deletions

lib/gemconfig.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module TrophyApiClient
44
module Gemconfig
5-
VERSION = "1.0.30"
5+
VERSION = "1.0.31"
66
AUTHORS = ["Trophy Labs, Inc"].freeze
77
EMAIL = ""
88
SUMMARY = "Ruby library for the Trophy API."

lib/trophy_api_client/achievements/client.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def initialize(request_client:)
2020

2121
# Get all achievements and their completion stats.
2222
#
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.
2326
# @param request_options [TrophyApiClient::RequestOptions]
2427
# @return [Array<TrophyApiClient::AchievementWithStatsResponse>]
2528
# @example
@@ -28,8 +31,8 @@ def initialize(request_client:)
2831
# environment: TrophyApiClient::Environment::PRODUCTION,
2932
# api_key: "YOUR_API_KEY"
3033
# )
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)
3336
response = @request_client.conn.get do |req|
3437
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
3538
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -38,9 +41,10 @@ def all(request_options: nil)
3841
**@request_client.get_headers,
3942
**(request_options&.additional_headers || {})
4043
}.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
4448
unless request_options.nil? || request_options&.additional_body_parameters.nil?
4549
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
4650
end
@@ -105,6 +109,9 @@ def initialize(request_client:)
105109

106110
# Get all achievements and their completion stats.
107111
#
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.
108115
# @param request_options [TrophyApiClient::RequestOptions]
109116
# @return [Array<TrophyApiClient::AchievementWithStatsResponse>]
110117
# @example
@@ -113,8 +120,8 @@ def initialize(request_client:)
113120
# environment: TrophyApiClient::Environment::PRODUCTION,
114121
# api_key: "YOUR_API_KEY"
115122
# )
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)
118125
Async do
119126
response = @request_client.conn.get do |req|
120127
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -124,9 +131,10 @@ def all(request_options: nil)
124131
**@request_client.get_headers,
125132
**(request_options&.additional_headers || {})
126133
}.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
130138
unless request_options.nil? || request_options&.additional_body_parameters.nil?
131139
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
132140
end

lib/trophy_api_client/leaderboards/client.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def all(request_options: nil)
6161
# run.
6262
# @param user_id [String] When provided, offset is relative to this user's position on the leaderboard. If
6363
# 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.
6467
# @param request_options [TrophyApiClient::RequestOptions]
6568
# @return [TrophyApiClient::LeaderboardResponseWithRankings]
6669
# @example
@@ -74,9 +77,10 @@ def all(request_options: nil)
7477
# offset: 1,
7578
# limit: 1,
7679
# run: "2025-01-15",
77-
# user_id: "user-123"
80+
# user_id: "user-123",
81+
# user_attributes: "city:London"
7882
# )
79-
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)
8084
response = @request_client.conn.get do |req|
8185
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
8286
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -90,7 +94,8 @@ def get(key:, offset: nil, limit: nil, run: nil, user_id: nil, request_options:
9094
"offset": offset,
9195
"limit": limit,
9296
"run": run,
93-
"userId": user_id
97+
"userId": user_id,
98+
"userAttributes": user_attributes
9499
}.compact
95100
unless request_options.nil? || request_options&.additional_body_parameters.nil?
96101
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
@@ -157,6 +162,9 @@ def all(request_options: nil)
157162
# run.
158163
# @param user_id [String] When provided, offset is relative to this user's position on the leaderboard. If
159164
# 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.
160168
# @param request_options [TrophyApiClient::RequestOptions]
161169
# @return [TrophyApiClient::LeaderboardResponseWithRankings]
162170
# @example
@@ -170,9 +178,10 @@ def all(request_options: nil)
170178
# offset: 1,
171179
# limit: 1,
172180
# run: "2025-01-15",
173-
# user_id: "user-123"
181+
# user_id: "user-123",
182+
# user_attributes: "city:London"
174183
# )
175-
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)
176185
Async do
177186
response = @request_client.conn.get do |req|
178187
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -187,7 +196,8 @@ def get(key:, offset: nil, limit: nil, run: nil, user_id: nil, request_options:
187196
"offset": offset,
188197
"limit": limit,
189198
"run": run,
190-
"userId": user_id
199+
"userId": user_id,
200+
"userAttributes": user_attributes
191201
}.compact
192202
unless request_options.nil? || request_options&.additional_body_parameters.nil?
193203
req.body = { **(request_options&.additional_body_parameters || {}) }.compact

lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class LeaderboardsAllResponseItem
1919
attr_reader :key
2020
# @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
2121
attr_reader :rank_by
22+
# @return [String] The key of the attribute to break down this leaderboard by.
23+
attr_reader :breakdown_attribute
2224
# @return [String] The key of the metric to rank by, if rankBy is 'metric'.
2325
attr_reader :metric_key
2426
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -55,6 +57,7 @@ class LeaderboardsAllResponseItem
5557
# @param name [String] The user-facing name of the leaderboard.
5658
# @param key [String] The unique key used to reference the leaderboard in APIs.
5759
# @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.
5861
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
5962
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
6063
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -70,13 +73,14 @@ class LeaderboardsAllResponseItem
7073
# type.
7174
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
7275
# @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem]
73-
def initialize(status:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT,
74-
points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
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)
7578
@status = status
7679
@id = id
7780
@name = name
7881
@key = key
7982
@rank_by = rank_by
83+
@breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
8084
@metric_key = metric_key if metric_key != OMIT
8185
@metric_name = metric_name if metric_name != OMIT
8286
@points_system_key = points_system_key if points_system_key != OMIT
@@ -94,6 +98,7 @@ def initialize(status:, id:, name:, key:, rank_by:, description:, start:, max_pa
9498
"name": name,
9599
"key": key,
96100
"rankBy": rank_by,
101+
"breakdownAttribute": breakdown_attribute,
97102
"metricKey": metric_key,
98103
"metricName": metric_name,
99104
"pointsSystemKey": points_system_key,
@@ -121,6 +126,7 @@ def self.from_json(json_object:)
121126
name = parsed_json["name"]
122127
key = parsed_json["key"]
123128
rank_by = parsed_json["rankBy"]
129+
breakdown_attribute = parsed_json["breakdownAttribute"]
124130
metric_key = parsed_json["metricKey"]
125131
metric_name = parsed_json["metricName"]
126132
points_system_key = parsed_json["pointsSystemKey"]
@@ -137,6 +143,7 @@ def self.from_json(json_object:)
137143
name: name,
138144
key: key,
139145
rank_by: rank_by,
146+
breakdown_attribute: breakdown_attribute,
140147
metric_key: metric_key,
141148
metric_name: metric_name,
142149
points_system_key: points_system_key,
@@ -170,6 +177,7 @@ def self.validate_raw(obj:)
170177
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
171178
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
172179
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.")
173181
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
174182
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
175183
obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")

lib/trophy_api_client/points/client.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def initialize(request_client:)
2121
#
2222
# @param key [String] Key of the points system.
2323
# @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.
2626
# @param request_options [TrophyApiClient::RequestOptions]
2727
# @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
2828
# @example
@@ -104,8 +104,8 @@ def initialize(request_client:)
104104
#
105105
# @param key [String] Key of the points system.
106106
# @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.
109109
# @param request_options [TrophyApiClient::RequestOptions]
110110
# @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
111111
# @example

lib/trophy_api_client/types/leaderboard_response.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class LeaderboardResponse
1616
attr_reader :key
1717
# @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
1818
attr_reader :rank_by
19+
# @return [String] The key of the attribute to break down this leaderboard by.
20+
attr_reader :breakdown_attribute
1921
# @return [String] The key of the metric to rank by, if rankBy is 'metric'.
2022
attr_reader :metric_key
2123
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -51,6 +53,7 @@ class LeaderboardResponse
5153
# @param name [String] The user-facing name of the leaderboard.
5254
# @param key [String] The unique key used to reference the leaderboard in APIs.
5355
# @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.
5457
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
5558
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
5659
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -66,12 +69,13 @@ class LeaderboardResponse
6669
# type.
6770
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
6871
# @return [TrophyApiClient::LeaderboardResponse]
69-
def initialize(id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT,
70-
points_system_name: 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)
7174
@id = id
7275
@name = name
7376
@key = key
7477
@rank_by = rank_by
78+
@breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
7579
@metric_key = metric_key if metric_key != OMIT
7680
@metric_name = metric_name if metric_name != OMIT
7781
@points_system_key = points_system_key if points_system_key != OMIT
@@ -88,6 +92,7 @@ def initialize(id:, name:, key:, rank_by:, description:, start:, max_participant
8892
"name": name,
8993
"key": key,
9094
"rankBy": rank_by,
95+
"breakdownAttribute": breakdown_attribute,
9196
"metricKey": metric_key,
9297
"metricName": metric_name,
9398
"pointsSystemKey": points_system_key,
@@ -114,6 +119,7 @@ def self.from_json(json_object:)
114119
name = parsed_json["name"]
115120
key = parsed_json["key"]
116121
rank_by = parsed_json["rankBy"]
122+
breakdown_attribute = parsed_json["breakdownAttribute"]
117123
metric_key = parsed_json["metricKey"]
118124
metric_name = parsed_json["metricName"]
119125
points_system_key = parsed_json["pointsSystemKey"]
@@ -129,6 +135,7 @@ def self.from_json(json_object:)
129135
name: name,
130136
key: key,
131137
rank_by: rank_by,
138+
breakdown_attribute: breakdown_attribute,
132139
metric_key: metric_key,
133140
metric_name: metric_name,
134141
points_system_key: points_system_key,
@@ -161,6 +168,7 @@ def self.validate_raw(obj:)
161168
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
162169
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
163170
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.")
164172
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
165173
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
166174
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 commit comments

Comments
 (0)