trophy_api_client 1.0.23 → 1.0.25
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.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/leaderboards/client.rb +197 -0
- data/lib/trophy_api_client/types/event_response.rb +16 -5
- data/lib/trophy_api_client/types/leaderboard_event.rb +101 -0
- data/lib/trophy_api_client/types/leaderboard_ranking.rb +82 -0
- data/lib/trophy_api_client/types/leaderboard_response.rb +184 -0
- data/lib/trophy_api_client/types/leaderboard_response_rank_by.rb +10 -0
- data/lib/trophy_api_client/types/leaderboard_response_status.rb +10 -0
- data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +195 -0
- data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +213 -0
- data/lib/trophy_api_client/types/user_leaderboard_response.rb +216 -0
- data/lib/trophy_api_client/users/client.rb +77 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/trophy_api_client.rb +7 -0
- data/lib/types_export.rb +8 -0
- metadata +10 -1
@@ -13,6 +13,7 @@ require_relative "../types/streak_response"
|
|
13
13
|
require_relative "../types/get_user_points_response"
|
14
14
|
require_relative "types/users_points_event_summary_request_aggregation"
|
15
15
|
require_relative "types/users_points_event_summary_response_item"
|
16
|
+
require_relative "../types/user_leaderboard_response"
|
16
17
|
require "async"
|
17
18
|
|
18
19
|
module TrophyApiClient
|
@@ -447,6 +448,43 @@ module TrophyApiClient
|
|
447
448
|
TrophyApiClient::Users::UsersPointsEventSummaryResponseItem.from_json(json_object: item)
|
448
449
|
end
|
449
450
|
end
|
451
|
+
|
452
|
+
# Get a user's rank, value, and history for a specific leaderboard.
|
453
|
+
#
|
454
|
+
# @param id [String] The user's ID in your database.
|
455
|
+
# @param key [String] Unique key of the leaderboard as set when created.
|
456
|
+
# @param run [String] Specific run date in YYYY-MM-DD format. If not provided, returns the current
|
457
|
+
# run.
|
458
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
459
|
+
# @return [TrophyApiClient::UserLeaderboardResponse]
|
460
|
+
# @example
|
461
|
+
# api = TrophyApiClient::Client.new(
|
462
|
+
# base_url: "https://api.example.com",
|
463
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
464
|
+
# api_key: "YOUR_API_KEY"
|
465
|
+
# )
|
466
|
+
# api.users.leaderboards(
|
467
|
+
# id: "user-123",
|
468
|
+
# key: "weekly-words",
|
469
|
+
# run: "2025-01-15"
|
470
|
+
# )
|
471
|
+
def leaderboards(id:, key:, run: nil, request_options: nil)
|
472
|
+
response = @request_client.conn.get do |req|
|
473
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
474
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
475
|
+
req.headers = {
|
476
|
+
**(req.headers || {}),
|
477
|
+
**@request_client.get_headers,
|
478
|
+
**(request_options&.additional_headers || {})
|
479
|
+
}.compact
|
480
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "run": run }.compact
|
481
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
482
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
483
|
+
end
|
484
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/leaderboards/#{key}"
|
485
|
+
end
|
486
|
+
TrophyApiClient::UserLeaderboardResponse.from_json(json_object: response.body)
|
487
|
+
end
|
450
488
|
end
|
451
489
|
|
452
490
|
class AsyncUsersClient
|
@@ -902,5 +940,44 @@ module TrophyApiClient
|
|
902
940
|
end
|
903
941
|
end
|
904
942
|
end
|
943
|
+
|
944
|
+
# Get a user's rank, value, and history for a specific leaderboard.
|
945
|
+
#
|
946
|
+
# @param id [String] The user's ID in your database.
|
947
|
+
# @param key [String] Unique key of the leaderboard as set when created.
|
948
|
+
# @param run [String] Specific run date in YYYY-MM-DD format. If not provided, returns the current
|
949
|
+
# run.
|
950
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
951
|
+
# @return [TrophyApiClient::UserLeaderboardResponse]
|
952
|
+
# @example
|
953
|
+
# api = TrophyApiClient::Client.new(
|
954
|
+
# base_url: "https://api.example.com",
|
955
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
956
|
+
# api_key: "YOUR_API_KEY"
|
957
|
+
# )
|
958
|
+
# api.users.leaderboards(
|
959
|
+
# id: "user-123",
|
960
|
+
# key: "weekly-words",
|
961
|
+
# run: "2025-01-15"
|
962
|
+
# )
|
963
|
+
def leaderboards(id:, key:, run: nil, request_options: nil)
|
964
|
+
Async do
|
965
|
+
response = @request_client.conn.get do |req|
|
966
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
967
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
968
|
+
req.headers = {
|
969
|
+
**(req.headers || {}),
|
970
|
+
**@request_client.get_headers,
|
971
|
+
**(request_options&.additional_headers || {})
|
972
|
+
}.compact
|
973
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "run": run }.compact
|
974
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
975
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
976
|
+
end
|
977
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/leaderboards/#{key}"
|
978
|
+
end
|
979
|
+
TrophyApiClient::UserLeaderboardResponse.from_json(json_object: response.body)
|
980
|
+
end
|
981
|
+
end
|
905
982
|
end
|
906
983
|
end
|
data/lib/trophy_api_client.rb
CHANGED
@@ -8,6 +8,7 @@ require_relative "trophy_api_client/metrics/client"
|
|
8
8
|
require_relative "trophy_api_client/users/client"
|
9
9
|
require_relative "trophy_api_client/streaks/client"
|
10
10
|
require_relative "trophy_api_client/points/client"
|
11
|
+
require_relative "trophy_api_client/leaderboards/client"
|
11
12
|
|
12
13
|
module TrophyApiClient
|
13
14
|
class Client
|
@@ -21,6 +22,8 @@ module TrophyApiClient
|
|
21
22
|
attr_reader :streaks
|
22
23
|
# @return [TrophyApiClient::PointsClient]
|
23
24
|
attr_reader :points
|
25
|
+
# @return [TrophyApiClient::LeaderboardsClient]
|
26
|
+
attr_reader :leaderboards
|
24
27
|
|
25
28
|
# @param base_url [String]
|
26
29
|
# @param environment [TrophyApiClient::Environment]
|
@@ -42,6 +45,7 @@ module TrophyApiClient
|
|
42
45
|
@users = TrophyApiClient::UsersClient.new(request_client: @request_client)
|
43
46
|
@streaks = TrophyApiClient::StreaksClient.new(request_client: @request_client)
|
44
47
|
@points = TrophyApiClient::PointsClient.new(request_client: @request_client)
|
48
|
+
@leaderboards = TrophyApiClient::LeaderboardsClient.new(request_client: @request_client)
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
@@ -56,6 +60,8 @@ module TrophyApiClient
|
|
56
60
|
attr_reader :streaks
|
57
61
|
# @return [TrophyApiClient::AsyncPointsClient]
|
58
62
|
attr_reader :points
|
63
|
+
# @return [TrophyApiClient::AsyncLeaderboardsClient]
|
64
|
+
attr_reader :leaderboards
|
59
65
|
|
60
66
|
# @param base_url [String]
|
61
67
|
# @param environment [TrophyApiClient::Environment]
|
@@ -77,6 +83,7 @@ module TrophyApiClient
|
|
77
83
|
@users = TrophyApiClient::AsyncUsersClient.new(request_client: @async_request_client)
|
78
84
|
@streaks = TrophyApiClient::AsyncStreaksClient.new(request_client: @async_request_client)
|
79
85
|
@points = TrophyApiClient::AsyncPointsClient.new(request_client: @async_request_client)
|
86
|
+
@leaderboards = TrophyApiClient::AsyncLeaderboardsClient.new(request_client: @async_request_client)
|
80
87
|
end
|
81
88
|
end
|
82
89
|
end
|
data/lib/types_export.rb
CHANGED
@@ -17,7 +17,12 @@ require_relative "trophy_api_client/types/points_trigger_type"
|
|
17
17
|
require_relative "trophy_api_client/types/points_trigger"
|
18
18
|
require_relative "trophy_api_client/types/points_award"
|
19
19
|
require_relative "trophy_api_client/types/get_user_points_response"
|
20
|
+
require_relative "trophy_api_client/types/leaderboard_response_status"
|
21
|
+
require_relative "trophy_api_client/types/leaderboard_response_rank_by"
|
22
|
+
require_relative "trophy_api_client/types/leaderboard_response"
|
23
|
+
require_relative "trophy_api_client/types/leaderboard_response_with_rankings"
|
20
24
|
require_relative "trophy_api_client/types/metric_event_points_response"
|
25
|
+
require_relative "trophy_api_client/types/metric_event_leaderboard_response"
|
21
26
|
require_relative "trophy_api_client/types/achievement_response_trigger"
|
22
27
|
require_relative "trophy_api_client/types/achievement_response"
|
23
28
|
require_relative "trophy_api_client/types/completed_achievement_response"
|
@@ -40,3 +45,6 @@ require_relative "trophy_api_client/types/points_trigger_response_event_attribut
|
|
40
45
|
require_relative "trophy_api_client/types/points_trigger_response"
|
41
46
|
require_relative "trophy_api_client/types/points_system_response"
|
42
47
|
require_relative "trophy_api_client/types/streak_ranking_user"
|
48
|
+
require_relative "trophy_api_client/types/leaderboard_ranking"
|
49
|
+
require_relative "trophy_api_client/types/leaderboard_event"
|
50
|
+
require_relative "trophy_api_client/types/user_leaderboard_response"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trophy_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trophy Labs, Inc
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/requests.rb
|
101
101
|
- lib/trophy_api_client.rb
|
102
102
|
- lib/trophy_api_client/achievements/client.rb
|
103
|
+
- lib/trophy_api_client/leaderboards/client.rb
|
103
104
|
- lib/trophy_api_client/metrics/client.rb
|
104
105
|
- lib/trophy_api_client/points/client.rb
|
105
106
|
- lib/trophy_api_client/streaks/client.rb
|
@@ -117,6 +118,13 @@ files:
|
|
117
118
|
- lib/trophy_api_client/types/error_body.rb
|
118
119
|
- lib/trophy_api_client/types/event_response.rb
|
119
120
|
- lib/trophy_api_client/types/get_user_points_response.rb
|
121
|
+
- lib/trophy_api_client/types/leaderboard_event.rb
|
122
|
+
- lib/trophy_api_client/types/leaderboard_ranking.rb
|
123
|
+
- lib/trophy_api_client/types/leaderboard_response.rb
|
124
|
+
- lib/trophy_api_client/types/leaderboard_response_rank_by.rb
|
125
|
+
- lib/trophy_api_client/types/leaderboard_response_status.rb
|
126
|
+
- lib/trophy_api_client/types/leaderboard_response_with_rankings.rb
|
127
|
+
- lib/trophy_api_client/types/metric_event_leaderboard_response.rb
|
120
128
|
- lib/trophy_api_client/types/metric_event_points_response.rb
|
121
129
|
- lib/trophy_api_client/types/metric_event_streak_response.rb
|
122
130
|
- lib/trophy_api_client/types/metric_response.rb
|
@@ -139,6 +147,7 @@ files:
|
|
139
147
|
- lib/trophy_api_client/types/updated_user.rb
|
140
148
|
- lib/trophy_api_client/types/upserted_user.rb
|
141
149
|
- lib/trophy_api_client/types/user.rb
|
150
|
+
- lib/trophy_api_client/types/user_leaderboard_response.rb
|
142
151
|
- lib/trophy_api_client/users/client.rb
|
143
152
|
- lib/trophy_api_client/users/types/users_metric_event_summary_request_aggregation.rb
|
144
153
|
- lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb
|