trophy_api_client 1.0.29 → 1.0.30
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/achievements/client.rb +2 -2
- data/lib/trophy_api_client/leaderboards/client.rb +9 -5
- data/lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb +186 -0
- data/lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item_status.rb +12 -0
- data/lib/trophy_api_client/metrics/client.rb +2 -2
- data/lib/trophy_api_client/streaks/client.rb +2 -2
- data/lib/trophy_api_client/types/achievement_completion_response.rb +9 -11
- data/lib/trophy_api_client/types/achievement_completion_response_achievement.rb +171 -0
- data/lib/trophy_api_client/types/achievement_response.rb +5 -19
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +9 -23
- data/lib/trophy_api_client/types/bulk_streak_response_item.rb +4 -6
- data/lib/trophy_api_client/types/completed_achievement_response.rb +7 -21
- data/lib/trophy_api_client/types/event_response.rb +10 -10
- data/lib/trophy_api_client/types/get_user_points_response.rb +21 -4
- data/lib/trophy_api_client/types/leaderboard_response.rb +8 -16
- data/lib/trophy_api_client/types/leaderboard_response_run_unit.rb +11 -0
- data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +17 -16
- data/lib/trophy_api_client/types/{leaderboard_response_status.rb → leaderboard_response_with_rankings_status.rb} +1 -1
- data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +11 -19
- data/lib/trophy_api_client/types/metric_event_points_response.rb +24 -8
- data/lib/trophy_api_client/types/metric_event_streak_response.rb +4 -4
- data/lib/trophy_api_client/types/points_award.rb +6 -6
- data/lib/trophy_api_client/types/points_range.rb +14 -16
- data/lib/trophy_api_client/types/points_system_response.rb +10 -1
- data/lib/trophy_api_client/types/points_trigger.rb +30 -11
- data/lib/trophy_api_client/types/points_trigger_response.rb +39 -22
- data/lib/trophy_api_client/types/points_trigger_response_time_unit.rb +9 -0
- data/lib/trophy_api_client/types/points_trigger_response_type.rb +2 -0
- data/lib/trophy_api_client/types/points_trigger_time_unit.rb +9 -0
- data/lib/trophy_api_client/types/points_trigger_type.rb +2 -0
- data/lib/trophy_api_client/types/updated_user.rb +11 -11
- data/lib/trophy_api_client/types/upserted_user.rb +12 -12
- data/lib/trophy_api_client/types/user.rb +18 -18
- data/lib/trophy_api_client/types/user_leaderboard_response.rb +8 -28
- data/lib/trophy_api_client/types/user_leaderboard_response_with_history.rb +208 -0
- data/lib/trophy_api_client/types/webhook_user_leaderboard_response.rb +212 -0
- data/lib/trophy_api_client/types/webhooks_achievement_completed_payload.rb +84 -0
- data/lib/trophy_api_client/types/webhooks_leaderboard_changed_payload.rb +71 -0
- data/lib/trophy_api_client/types/webhooks_leaderboard_finished_payload.rb +71 -0
- data/lib/trophy_api_client/types/webhooks_leaderboard_rank_changed_payload.rb +85 -0
- data/lib/trophy_api_client/types/webhooks_leaderboard_started_payload.rb +71 -0
- data/lib/trophy_api_client/types/webhooks_points_changed_payload.rb +84 -0
- data/lib/trophy_api_client/types/webhooks_streak_extended_payload.rb +84 -0
- data/lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb +85 -0
- data/lib/trophy_api_client/types/webhooks_streak_freeze_earned_payload.rb +85 -0
- data/lib/trophy_api_client/types/webhooks_streak_lost_payload.rb +78 -0
- data/lib/trophy_api_client/types/webhooks_streak_started_payload.rb +84 -0
- data/lib/trophy_api_client/users/client.rb +25 -17
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +20 -1
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c25a821fcf1f05012a279bf8ad031328a32bf4e485600e4b6f1db1484de8daa8
|
4
|
+
data.tar.gz: b2b975f8d431ec31f8ddec8bb2f73803dee6a45ebcbb4b92103ea904b7f5ae6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33c5da328d9511d8a1f0231d1697ebf671b9463b426fcf575a9be4037f5963f5a23347e358e38ef12a05fbc9da9a6c27f2ad36b134a07d07887605ae8d44c86a
|
7
|
+
data.tar.gz: 01dbb928522b7d992d4788e3112f058455a143f870215824a2c1336cb165ace1bb5a5469ec4cbfade09c31cc49987931119156b05efb1ad2c9ebeb8b97339a0a
|
data/lib/gemconfig.rb
CHANGED
@@ -72,7 +72,7 @@ module TrophyApiClient
|
|
72
72
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
73
73
|
# api_key: "YOUR_API_KEY"
|
74
74
|
# )
|
75
|
-
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
|
75
|
+
# 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
76
|
def complete(key:, user:, request_options: nil)
|
77
77
|
response = @request_client.conn.post do |req|
|
78
78
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
@@ -159,7 +159,7 @@ module TrophyApiClient
|
|
159
159
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
160
160
|
# api_key: "YOUR_API_KEY"
|
161
161
|
# )
|
162
|
-
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
|
162
|
+
# 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
163
|
def complete(key:, user:, request_options: nil)
|
164
164
|
Async do
|
165
165
|
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 "
|
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::
|
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::
|
51
|
+
TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem.from_json(json_object: item)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -71,6 +71,8 @@ module TrophyApiClient
|
|
71
71
|
# )
|
72
72
|
# api.leaderboards.get(
|
73
73
|
# key: "weekly-words",
|
74
|
+
# offset: 1,
|
75
|
+
# limit: 1,
|
74
76
|
# run: "2025-01-15",
|
75
77
|
# user_id: "user-123"
|
76
78
|
# )
|
@@ -112,7 +114,7 @@ module TrophyApiClient
|
|
112
114
|
# Get all active leaderboards for your organization.
|
113
115
|
#
|
114
116
|
# @param request_options [TrophyApiClient::RequestOptions]
|
115
|
-
# @return [Array<TrophyApiClient::
|
117
|
+
# @return [Array<TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem>]
|
116
118
|
# @example
|
117
119
|
# api = TrophyApiClient::Client.new(
|
118
120
|
# base_url: "https://api.example.com",
|
@@ -141,7 +143,7 @@ module TrophyApiClient
|
|
141
143
|
parsed_json = JSON.parse(response.body)
|
142
144
|
parsed_json&.map do |item|
|
143
145
|
item = item.to_json
|
144
|
-
TrophyApiClient::
|
146
|
+
TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem.from_json(json_object: item)
|
145
147
|
end
|
146
148
|
end
|
147
149
|
end
|
@@ -165,6 +167,8 @@ module TrophyApiClient
|
|
165
167
|
# )
|
166
168
|
# api.leaderboards.get(
|
167
169
|
# key: "weekly-words",
|
170
|
+
# offset: 1,
|
171
|
+
# limit: 1,
|
168
172
|
# run: "2025-01-15",
|
169
173
|
# user_id: "user-123"
|
170
174
|
# )
|
@@ -0,0 +1,186 @@
|
|
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 metric to rank by, if rankBy is 'metric'.
|
23
|
+
attr_reader :metric_key
|
24
|
+
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
|
25
|
+
attr_reader :metric_name
|
26
|
+
# @return [String] The key of the points system to rank by, if rankBy is 'points'.
|
27
|
+
attr_reader :points_system_key
|
28
|
+
# @return [String] The name of the points system to rank by, if rankBy is 'points'.
|
29
|
+
attr_reader :points_system_name
|
30
|
+
# @return [String] The user-facing description of the leaderboard.
|
31
|
+
attr_reader :description
|
32
|
+
# @return [String] The start date of the leaderboard in YYYY-MM-DD format.
|
33
|
+
attr_reader :start
|
34
|
+
# @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
|
35
|
+
# forever.
|
36
|
+
attr_reader :end_
|
37
|
+
# @return [Integer] The maximum number of participants in the leaderboard.
|
38
|
+
attr_reader :max_participants
|
39
|
+
# @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
|
40
|
+
# leaderboards.
|
41
|
+
attr_reader :run_unit
|
42
|
+
# @return [Integer] The interval between repetitions, relative to the start date and repetition
|
43
|
+
# type.
|
44
|
+
attr_reader :run_interval
|
45
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
46
|
+
attr_reader :additional_properties
|
47
|
+
# @return [Object]
|
48
|
+
attr_reader :_field_set
|
49
|
+
protected :_field_set
|
50
|
+
|
51
|
+
OMIT = Object.new
|
52
|
+
|
53
|
+
# @param status [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus] The status of the leaderboard.
|
54
|
+
# @param id [String] The unique ID of the leaderboard.
|
55
|
+
# @param name [String] The user-facing name of the leaderboard.
|
56
|
+
# @param key [String] The unique key used to reference the leaderboard in APIs.
|
57
|
+
# @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
|
58
|
+
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
|
59
|
+
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
|
60
|
+
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
|
61
|
+
# @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
|
62
|
+
# @param description [String] The user-facing description of the leaderboard.
|
63
|
+
# @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
|
64
|
+
# @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
|
65
|
+
# forever.
|
66
|
+
# @param max_participants [Integer] The maximum number of participants in the leaderboard.
|
67
|
+
# @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
|
68
|
+
# leaderboards.
|
69
|
+
# @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
|
70
|
+
# type.
|
71
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
72
|
+
# @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)
|
75
|
+
@status = status
|
76
|
+
@id = id
|
77
|
+
@name = name
|
78
|
+
@key = key
|
79
|
+
@rank_by = rank_by
|
80
|
+
@metric_key = metric_key if metric_key != OMIT
|
81
|
+
@metric_name = metric_name if metric_name != OMIT
|
82
|
+
@points_system_key = points_system_key if points_system_key != OMIT
|
83
|
+
@points_system_name = points_system_name if points_system_name != OMIT
|
84
|
+
@description = description
|
85
|
+
@start = start
|
86
|
+
@end_ = end_ if end_ != OMIT
|
87
|
+
@max_participants = max_participants
|
88
|
+
@run_unit = run_unit if run_unit != OMIT
|
89
|
+
@run_interval = run_interval
|
90
|
+
@additional_properties = additional_properties
|
91
|
+
@_field_set = {
|
92
|
+
"status": status,
|
93
|
+
"id": id,
|
94
|
+
"name": name,
|
95
|
+
"key": key,
|
96
|
+
"rankBy": rank_by,
|
97
|
+
"metricKey": metric_key,
|
98
|
+
"metricName": metric_name,
|
99
|
+
"pointsSystemKey": points_system_key,
|
100
|
+
"pointsSystemName": points_system_name,
|
101
|
+
"description": description,
|
102
|
+
"start": start,
|
103
|
+
"end": end_,
|
104
|
+
"maxParticipants": max_participants,
|
105
|
+
"runUnit": run_unit,
|
106
|
+
"runInterval": run_interval
|
107
|
+
}.reject do |_k, v|
|
108
|
+
v == OMIT
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Deserialize a JSON object to an instance of LeaderboardsAllResponseItem
|
113
|
+
#
|
114
|
+
# @param json_object [String]
|
115
|
+
# @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem]
|
116
|
+
def self.from_json(json_object:)
|
117
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
118
|
+
parsed_json = JSON.parse(json_object)
|
119
|
+
status = parsed_json["status"]
|
120
|
+
id = parsed_json["id"]
|
121
|
+
name = parsed_json["name"]
|
122
|
+
key = parsed_json["key"]
|
123
|
+
rank_by = parsed_json["rankBy"]
|
124
|
+
metric_key = parsed_json["metricKey"]
|
125
|
+
metric_name = parsed_json["metricName"]
|
126
|
+
points_system_key = parsed_json["pointsSystemKey"]
|
127
|
+
points_system_name = parsed_json["pointsSystemName"]
|
128
|
+
description = parsed_json["description"]
|
129
|
+
start = parsed_json["start"]
|
130
|
+
end_ = parsed_json["end"]
|
131
|
+
max_participants = parsed_json["maxParticipants"]
|
132
|
+
run_unit = parsed_json["runUnit"]
|
133
|
+
run_interval = parsed_json["runInterval"]
|
134
|
+
new(
|
135
|
+
status: status,
|
136
|
+
id: id,
|
137
|
+
name: name,
|
138
|
+
key: key,
|
139
|
+
rank_by: rank_by,
|
140
|
+
metric_key: metric_key,
|
141
|
+
metric_name: metric_name,
|
142
|
+
points_system_key: points_system_key,
|
143
|
+
points_system_name: points_system_name,
|
144
|
+
description: description,
|
145
|
+
start: start,
|
146
|
+
end_: end_,
|
147
|
+
max_participants: max_participants,
|
148
|
+
run_unit: run_unit,
|
149
|
+
run_interval: run_interval,
|
150
|
+
additional_properties: struct
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Serialize an instance of LeaderboardsAllResponseItem to a JSON object
|
155
|
+
#
|
156
|
+
# @return [String]
|
157
|
+
def to_json(*_args)
|
158
|
+
@_field_set&.to_json
|
159
|
+
end
|
160
|
+
|
161
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
162
|
+
# hash and check each fields type against the current object's property
|
163
|
+
# definitions.
|
164
|
+
#
|
165
|
+
# @param obj [Object]
|
166
|
+
# @return [Void]
|
167
|
+
def self.validate_raw(obj:)
|
168
|
+
obj.status.is_a?(TrophyApiClient::Leaderboards::LeaderboardsAllResponseItemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
169
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
170
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
171
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
172
|
+
obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
|
173
|
+
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
|
174
|
+
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
175
|
+
obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
|
176
|
+
obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
|
177
|
+
obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
178
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
179
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
180
|
+
obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
|
181
|
+
obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
|
182
|
+
obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
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
|
# )
|
@@ -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 "
|
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::
|
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::
|
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
|
30
|
+
def initialize(completion_id:, achievement:, points:, additional_properties: nil)
|
31
31
|
@completion_id = completion_id
|
32
32
|
@achievement = achievement
|
33
|
-
@points = points
|
33
|
+
@points = points
|
34
34
|
@additional_properties = additional_properties
|
35
|
-
@_field_set = { "completionId": completion_id, "achievement": achievement, "points": points }
|
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::
|
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::
|
82
|
-
obj.points
|
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
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "metric_event_streak_response"
|
4
|
+
require "date"
|
5
|
+
require_relative "achievement_response_trigger"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module TrophyApiClient
|
10
|
+
class AchievementCompletionResponseAchievement
|
11
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
12
|
+
attr_reader :current_streak
|
13
|
+
# @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
|
14
|
+
attr_reader :achieved_at
|
15
|
+
# @return [String] The unique ID of the achievement.
|
16
|
+
attr_reader :id
|
17
|
+
# @return [String] The name of this achievement.
|
18
|
+
attr_reader :name
|
19
|
+
# @return [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
20
|
+
attr_reader :trigger
|
21
|
+
# @return [String] The description of this achievement.
|
22
|
+
attr_reader :description
|
23
|
+
# @return [String] The URL of the badge image for the achievement, if one has been uploaded.
|
24
|
+
attr_reader :badge_url
|
25
|
+
# @return [String] The key used to reference this achievement in the API (only applicable if
|
26
|
+
# trigger = 'api')
|
27
|
+
attr_reader :key
|
28
|
+
# @return [Integer] The length of the streak required to complete the achievement (only applicable
|
29
|
+
# if trigger = 'streak')
|
30
|
+
attr_reader :streak_length
|
31
|
+
# @return [String] The ID of the metric associated with this achievement (only applicable if
|
32
|
+
# trigger = 'metric')
|
33
|
+
attr_reader :metric_id
|
34
|
+
# @return [Float] The value of the metric required to complete the achievement (only applicable if
|
35
|
+
# trigger = 'metric')
|
36
|
+
attr_reader :metric_value
|
37
|
+
# @return [String] The name of the metric associated with this achievement (only applicable if
|
38
|
+
# trigger = 'metric')
|
39
|
+
attr_reader :metric_name
|
40
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
41
|
+
attr_reader :additional_properties
|
42
|
+
# @return [Object]
|
43
|
+
attr_reader :_field_set
|
44
|
+
protected :_field_set
|
45
|
+
|
46
|
+
OMIT = Object.new
|
47
|
+
|
48
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
49
|
+
# @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
|
50
|
+
# @param id [String] The unique ID of the achievement.
|
51
|
+
# @param name [String] The name of this achievement.
|
52
|
+
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
53
|
+
# @param description [String] The description of this achievement.
|
54
|
+
# @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
|
55
|
+
# @param key [String] The key used to reference this achievement in the API (only applicable if
|
56
|
+
# trigger = 'api')
|
57
|
+
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
58
|
+
# if trigger = 'streak')
|
59
|
+
# @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
|
60
|
+
# trigger = 'metric')
|
61
|
+
# @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
|
62
|
+
# trigger = 'metric')
|
63
|
+
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
64
|
+
# trigger = 'metric')
|
65
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
66
|
+
# @return [TrophyApiClient::AchievementCompletionResponseAchievement]
|
67
|
+
def initialize(achieved_at:, id:, name:, trigger:, key:, current_streak: OMIT, description: OMIT, badge_url: OMIT,
|
68
|
+
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
69
|
+
@current_streak = current_streak if current_streak != OMIT
|
70
|
+
@achieved_at = achieved_at
|
71
|
+
@id = id
|
72
|
+
@name = name
|
73
|
+
@trigger = trigger
|
74
|
+
@description = description if description != OMIT
|
75
|
+
@badge_url = badge_url if badge_url != OMIT
|
76
|
+
@key = key
|
77
|
+
@streak_length = streak_length if streak_length != OMIT
|
78
|
+
@metric_id = metric_id if metric_id != OMIT
|
79
|
+
@metric_value = metric_value if metric_value != OMIT
|
80
|
+
@metric_name = metric_name if metric_name != OMIT
|
81
|
+
@additional_properties = additional_properties
|
82
|
+
@_field_set = {
|
83
|
+
"currentStreak": current_streak,
|
84
|
+
"achievedAt": achieved_at,
|
85
|
+
"id": id,
|
86
|
+
"name": name,
|
87
|
+
"trigger": trigger,
|
88
|
+
"description": description,
|
89
|
+
"badgeUrl": badge_url,
|
90
|
+
"key": key,
|
91
|
+
"streakLength": streak_length,
|
92
|
+
"metricId": metric_id,
|
93
|
+
"metricValue": metric_value,
|
94
|
+
"metricName": metric_name
|
95
|
+
}.reject do |_k, v|
|
96
|
+
v == OMIT
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Deserialize a JSON object to an instance of
|
101
|
+
# AchievementCompletionResponseAchievement
|
102
|
+
#
|
103
|
+
# @param json_object [String]
|
104
|
+
# @return [TrophyApiClient::AchievementCompletionResponseAchievement]
|
105
|
+
def self.from_json(json_object:)
|
106
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
107
|
+
parsed_json = JSON.parse(json_object)
|
108
|
+
if parsed_json["currentStreak"].nil?
|
109
|
+
current_streak = nil
|
110
|
+
else
|
111
|
+
current_streak = parsed_json["currentStreak"].to_json
|
112
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
113
|
+
end
|
114
|
+
achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
|
115
|
+
id = parsed_json["id"]
|
116
|
+
name = parsed_json["name"]
|
117
|
+
trigger = parsed_json["trigger"]
|
118
|
+
description = parsed_json["description"]
|
119
|
+
badge_url = parsed_json["badgeUrl"]
|
120
|
+
key = parsed_json["key"]
|
121
|
+
streak_length = parsed_json["streakLength"]
|
122
|
+
metric_id = parsed_json["metricId"]
|
123
|
+
metric_value = parsed_json["metricValue"]
|
124
|
+
metric_name = parsed_json["metricName"]
|
125
|
+
new(
|
126
|
+
current_streak: current_streak,
|
127
|
+
achieved_at: achieved_at,
|
128
|
+
id: id,
|
129
|
+
name: name,
|
130
|
+
trigger: trigger,
|
131
|
+
description: description,
|
132
|
+
badge_url: badge_url,
|
133
|
+
key: key,
|
134
|
+
streak_length: streak_length,
|
135
|
+
metric_id: metric_id,
|
136
|
+
metric_value: metric_value,
|
137
|
+
metric_name: metric_name,
|
138
|
+
additional_properties: struct
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Serialize an instance of AchievementCompletionResponseAchievement to a JSON
|
143
|
+
# object
|
144
|
+
#
|
145
|
+
# @return [String]
|
146
|
+
def to_json(*_args)
|
147
|
+
@_field_set&.to_json
|
148
|
+
end
|
149
|
+
|
150
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
151
|
+
# hash and check each fields type against the current object's property
|
152
|
+
# definitions.
|
153
|
+
#
|
154
|
+
# @param obj [Object]
|
155
|
+
# @return [Void]
|
156
|
+
def self.validate_raw(obj:)
|
157
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
158
|
+
obj.achieved_at.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
|
159
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
160
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
161
|
+
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
162
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
163
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
164
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
165
|
+
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
166
|
+
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
167
|
+
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
168
|
+
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "achievement_response_trigger"
|
4
|
-
require_relative "metric_event_streak_response"
|
5
4
|
require "ostruct"
|
6
5
|
require "json"
|
7
6
|
|
@@ -32,8 +31,6 @@ module TrophyApiClient
|
|
32
31
|
# @return [String] The name of the metric associated with this achievement (only applicable if
|
33
32
|
# trigger = 'metric')
|
34
33
|
attr_reader :metric_name
|
35
|
-
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
36
|
-
attr_reader :current_streak
|
37
34
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
38
35
|
attr_reader :additional_properties
|
39
36
|
# @return [Object]
|
@@ -57,22 +54,20 @@ module TrophyApiClient
|
|
57
54
|
# trigger = 'metric')
|
58
55
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
59
56
|
# trigger = 'metric')
|
60
|
-
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
61
57
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
62
58
|
# @return [TrophyApiClient::AchievementResponse]
|
63
|
-
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT,
|
64
|
-
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT,
|
59
|
+
def initialize(id:, name:, trigger:, key:, description: OMIT, badge_url: OMIT, streak_length: OMIT,
|
60
|
+
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
65
61
|
@id = id
|
66
62
|
@name = name
|
67
63
|
@trigger = trigger
|
68
64
|
@description = description if description != OMIT
|
69
65
|
@badge_url = badge_url if badge_url != OMIT
|
70
|
-
@key = key
|
66
|
+
@key = key
|
71
67
|
@streak_length = streak_length if streak_length != OMIT
|
72
68
|
@metric_id = metric_id if metric_id != OMIT
|
73
69
|
@metric_value = metric_value if metric_value != OMIT
|
74
70
|
@metric_name = metric_name if metric_name != OMIT
|
75
|
-
@current_streak = current_streak if current_streak != OMIT
|
76
71
|
@additional_properties = additional_properties
|
77
72
|
@_field_set = {
|
78
73
|
"id": id,
|
@@ -84,8 +79,7 @@ module TrophyApiClient
|
|
84
79
|
"streakLength": streak_length,
|
85
80
|
"metricId": metric_id,
|
86
81
|
"metricValue": metric_value,
|
87
|
-
"metricName": metric_name
|
88
|
-
"currentStreak": current_streak
|
82
|
+
"metricName": metric_name
|
89
83
|
}.reject do |_k, v|
|
90
84
|
v == OMIT
|
91
85
|
end
|
@@ -108,12 +102,6 @@ module TrophyApiClient
|
|
108
102
|
metric_id = parsed_json["metricId"]
|
109
103
|
metric_value = parsed_json["metricValue"]
|
110
104
|
metric_name = parsed_json["metricName"]
|
111
|
-
if parsed_json["currentStreak"].nil?
|
112
|
-
current_streak = nil
|
113
|
-
else
|
114
|
-
current_streak = parsed_json["currentStreak"].to_json
|
115
|
-
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
116
|
-
end
|
117
105
|
new(
|
118
106
|
id: id,
|
119
107
|
name: name,
|
@@ -125,7 +113,6 @@ module TrophyApiClient
|
|
125
113
|
metric_id: metric_id,
|
126
114
|
metric_value: metric_value,
|
127
115
|
metric_name: metric_name,
|
128
|
-
current_streak: current_streak,
|
129
116
|
additional_properties: struct
|
130
117
|
)
|
131
118
|
end
|
@@ -149,12 +136,11 @@ module TrophyApiClient
|
|
149
136
|
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
150
137
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
151
138
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
152
|
-
obj.key
|
139
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
153
140
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
154
141
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
155
142
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
156
143
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
157
|
-
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
158
144
|
end
|
159
145
|
end
|
160
146
|
end
|